main/core/Listener/AnonymousAuthenticationListener.php
public function handle(GetResponseEvent $event)
    {
        if (null !== $this->tokenStorage->getToken()) {
            // user is already authenticated, there is nothing to do.
            return;
        }

        // creates an anonymous token with a dedicated role.
        $this->tokenStorage->setToken(
            new AnonymousToken($this->secret, 'anon.', ['ROLE_ANONYMOUS'])
        );

        if (null !== $this->logger) {
            $this->logger->info(sprintf('Populated SecurityContext with an anonymous Token'));
        }
    }
public function handle(GetResponseEvent $event)
    {
        if (null !== $this->tokenStorage->getToken()) {
            // user is already authenticated, there is nothing to do.
            return;
        }

        // creates an anonymous token with a dedicated role.
        $this->tokenStorage->setToken(
            new AnonymousToken($this->secret, 'anon.', ['ROLE_ANONYMOUS'])
        );

        if (null !== $this->logger) {
            $this->logger->info(sprintf('Populated SecurityContext with an anonymous Token'));
        }
    }
public function handle ( GetResponseEvent $ event ) { if ( null !== $ this -> tokenStorage -> getToken ( ) ) { // user is already authenticated, there is nothing to do. return ; } // creates an anonymous token with a dedicated role. $ this -> tokenStorage -> setToken ( new AnonymousToken ( $ this -> secret , 'anon.' , [ 'ROLE_ANONYMOUS' ] ) ) ; if ( null !== $ this -> logger ) { $ this -> logger -> info ( sprintf ( 'Populated SecurityContext with an anonymous Token' ) ) ; } }
Authenticates anonymous with correct roles.

@param GetResponseEvent $event
Authenticates anonymous with correct roles .