protected function authenticate(Url $url)
    {
        if (
            !$url->getOption('role') ||
            !$url->getOption('firewall')
        ) {
            return $this;
        }

        $session = $this->session;
        $firewall = $url->getOption('firewall');
        $role = $url->getOption('role');
        $user = $this
            ->environmentBuilder
            ->getAuthenticationUser($url->getOption('role'));

        $token = new UsernamePasswordToken($user, null, $firewall, [$role]);
        $session->set('_security_' . $firewall, serialize($token));
        $session->save();

        $cookie = new Cookie(
            $session->getName(),
            $session->getId()
        );
        $this
            ->client
            ->getCookieJar()
            ->set($cookie);

        return $this;
    }