SecurityToken null in Sonata Admin class - symfony

I have a problem with getting the logged in user in and Admin class. What I would like to do is to restrict a choice field to logged in users organization (so that he is not able to pick another organization when creating an event). Therefore I've injected TokenStorage into my CalendarAdmin, but $tokenStorage->getToken() is null even if I'm logged in.
Here is my relevant code:
security.yml:
providers:
in_memory:
memory: ~
fos_userbundle:
id: fos_user.user_manager
admin:
pattern: /admin(.*)
context: user
form_login:
provider: fos_userbundle
login_path: /admin/login
use_forward: false
check_path: /admin/login_check
failure_path: null
logout:
path: /admin/logout
anonymous: true
services.yml:
pozsonyba.calendar_bundle.admin.calendar:
class: Pozsonyba\Bundle\CalendarBundle\Admin\CalendarAdmin
arguments: [~, Pozsonyba\Bundle\CalendarBundle\Entity\Calendar, SonataAdminBundle:CRUD, #security.token_storage, #pozsonyba_organization.repository.organization_repository]
tags:
- {name: sonata.admin, manager_type: orm, group: admin, label: Calendar}
I read that this security.yml might have been set up wrong, that the firewall is missing something, I just can't figure out what.
Thank you for help.
CalendarAdmin.php:
public function __construct($code, $class, $baseControllerName, TokenStorage $tokenStorage, OrganizationRepository $organizationRepository)
{
parent::__construct($code, $class, $baseControllerName);
VarDumper::dump($tokenStorage->getToken());die;
$this->organizationRepository = $organizationRepository;
}

Check out the \Sonata\AdminBundle\Admin\AbstractAdmin class. You can get access to the container and the token storage via the configuration pool:
$this->getConfigurationPool()->getContainer()->get('security.token_storage')->getToken()->getUser()
I guess, the token is not set when the admin object is created, so as an alternative way you can try to inject the TokenStorage via setter injection:
# CalendarAdmin.php
/** #var TokenStorageInterface */
private $tokenStorage;
/**
* #param TokenStorageInterface $tokenStorage
*/
public function setTokenStorage($tokenStorage)
{
$this->tokenStorage = $tokenStorage;
}
update services definition
# services.yml
pozsonyba.calendar_bundle.admin.calendar:
class: Pozsonyba\Bundle\CalendarBundle\Admin\CalendarAdmin
arguments: [~, Pozsonyba\Bundle\CalendarBundle\Entity\Calendar, SonataAdminBundle:CRUD, #security.token_storage, #pozsonyba_organization.repository.organization_repository]
calls:
- [setTokenStorage, ["#security.token_storage"]]
tags:
- {name: sonata.admin, manager_type: orm, group: admin, label: Calendar}

Related

Symfony 5 - I can't login after logout on Heroku

When I login for the first time with the main login (login form), I have no problem with connecting.
Afterwards, if I logout, it seems I'm logout with no problem also.
But when I try to connect after the logout, I get an invalid credential message.
I don't have this problem in local.
I really don't see where the problem is coming from.
Here is my security.yaml
security:
enable_authenticator_manager: true
encoders:
App\Entity\User:
algorithm: auto
password_hashers:
# Use native password hasher, which auto-selects and migrates the best
# possible hashing algorithm (starting from Symfony 5.3 this is "bcrypt")
Symfony\Component\Security\Core\User\PasswordAuthenticatedUserInterface: 'auto'
# https://symfony.com/doc/current/security.html#where-do-users-come-from-user-providers
providers:
# used to reload user from session & other features (e.g. switch_user)
app_user_provider:
entity:
class: App\Entity\User
property: email
firewalls:
dev:
pattern: ^/(_(profiler|wdt)|css|images|js)/
security: false
main:
lazy: true
json_login:
check_path: app_login_json
username_path: email
password_path: password
provider: app_user_provider
entry_point: App\Security\LoginFormAuthenticator
logout:
path: app_logout
invalidate_session: true
# where to redirect after logout
# target: app_any_route
oauth:
resource_owners:
facebook: "/login/check-facebook"
google: "/login/check-google"
my_custom_provider: "/login/check-custom"
my_github: "/login/check-github"
login_path: /login
use_forward: false
failure_path: /login
oauth_user_provider:
service: my.oauth_aware.user_provider.service
custom_authenticator: App\Security\LoginFormAuthenticator
# activate different ways to authenticate
# https://symfony.com/doc/current/security.html#firewalls-authentication
# https://symfony.com/doc/current/security/impersonating_user.html
# switch_user: true
# Easy way to control access for large sections of your site
# Note: Only the *first* access control that matches will be used
access_control:
# - { path: ^/admin, roles: ROLE_ADMIN }
# - { path: ^/profile, roles: ROLE_USER }
- { path: ^/login, roles: IS_AUTHENTICATED_ANONYMOUSLY }
- { path: ^/connect, roles: IS_AUTHENTICATED_ANONYMOUSLY }
Here my LoginFormAuthenticator
<?php
namespace App\Security;
use Symfony\Component\HttpFoundation\RedirectResponse;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
use Symfony\Component\Security\Core\Security;
use Symfony\Component\Security\Http\Authenticator\AbstractLoginFormAuthenticator;
use Symfony\Component\Security\Http\Authenticator\Passport\Badge\CsrfTokenBadge;
use Symfony\Component\Security\Http\Authenticator\Passport\Badge\UserBadge;
use Symfony\Component\Security\Http\Authenticator\Passport\Credentials\PasswordCredentials;
use Symfony\Component\Security\Http\Authenticator\Passport\Passport;
use Symfony\Component\Security\Http\Authenticator\Passport\PassportInterface;
use Symfony\Component\Security\Http\Util\TargetPathTrait;
class LoginFormAuthenticator extends AbstractLoginFormAuthenticator
{
use TargetPathTrait;
public const LOGIN_ROUTE = 'app_login';
private UrlGeneratorInterface $urlGenerator;
public function __construct(UrlGeneratorInterface $urlGenerator)
{
$this->urlGenerator = $urlGenerator;
}
public function supports(Request $request): bool
{
return self::LOGIN_ROUTE === $request->attributes->get('_route')
&& $request->isMethod('POST');
}
public function authenticate(Request $request): PassportInterface
{
$email = $request->request->get('email', '');
$request->getSession()->set(Security::LAST_USERNAME, $email);
return new Passport(
new UserBadge($email),
new PasswordCredentials($request->request->get('password', '')),
[
new CsrfTokenBadge('authenticate', $request->request->get('_csrf_token')),
]
);
}
public function onAuthenticationSuccess(Request $request, TokenInterface $token, string $firewallName): ?Response
{
if ($targetPath = $this->getTargetPath($request->getSession(), $firewallName)) {
return new RedirectResponse($targetPath);
}
// For example:
return new RedirectResponse($this->urlGenerator->generate('home'));
throw new \Exception('TODO: provide a valid redirect inside '.__FILE__);
}
protected function getLoginUrl(Request $request): string
{
return $this->urlGenerator->generate(self::LOGIN_ROUTE);
}
}
I'm really stuck so I hope someone will see what's wrong.
I found the problem. I changed the template twig for the login with some of the elements I had in the Bootstrap theme I bought.
Thanks for those who read at least the question :)

How to extend LdapUserProvider and use a custom LDAP user provider in Symfony?

I'm struggeling to replace the LdapUserProvider.
I created my own provider (App\Security\MyLdapUserProvider based on LdapUserProvider but retrieves more information) and my own UserInterface (App\Security\MyUser) with more attributes to store the data.
In the end I want to retrieve the groups and the displayName of the user.
Here is my config:
services.yaml:
# add more service definitions when explicit configuration is needed
# please note that last definitions always *replace* previous ones
Symfony\Component\Ldap\Ldap:
arguments: ['#Symfony\Component\Ldap\Adapter\ExtLdap\Adapter']
Symfony\Component\Ldap\Adapter\ExtLdap\Adapter:
arguments:
- host: 10.106.1.1
port: 389
#encryption: tls
options:
protocol_version: 3
referrals: false
security.yaml:
providers:
#in_memory: { memory: ~ }
my_ldap:
ldap:
service: Symfony\Component\Ldap\Ldap
base_dn: "dc=XXXXXX,dc=com"
search_dn: "CN=XXXXXXXXXX,OU=LDAP,OU=Services Accounts,OU=Administration,DC=XXXXXXXXX,DC=com"
search_password: "ergergergergerg"
default_roles: ROLE_USER
filter: "({uid_key}={username})"
uid_key: samAccountName
#password_attribute: displayName
firewalls:
dev:
pattern: ^/(_(profiler|wdt)|css|images|js)/
security: false
main:
pattern: ^/
security: true
anonymous: true
provider: my_ldap
form_login_ldap:
login_path: /login
check_path: /login
service: Symfony\Component\Ldap\Ldap
dn_string: 'dc=XXXXXX,dc=com'
query_string: '(samAccountName={username})'
logout:
path: /logout
target: /
Where can I tell the security provider to use my own ldap provider instead of the default one ?
Symfony processes are still a bit complicated to me so if someone can take time to explain..
Symfony docs is an endless loop of redirecting between CustomUserProvider > Ldap config > CustomeUSerProvider...
As described in the documentation chapter Creating A Custom User Provider you need to add your User Provider as a new key under security.providers and configure it's id.
This id is the name of of your custom User Provider service which - in recent versions of symfony - equals the FQCN .
# security.yaml
security:
providers:
# the name of your user provider can be anything
my_ldap_provider:
id: 'App\Security\MyLdapUserProvider'
Then you can use this provider for one of the firewalls like this:
security:
# [..]
firewalls:
main:
pattern: '^/'
provider: 'my_ldap_provider'
Symfony's LdapUserProvider looks like this:
class LdapUserProvider implements UserProviderInterface
{
private $ldap;
private $baseDn;
private $searchDn;
private $searchPassword;
private $defaultRoles;
private $uidKey;
private $defaultSearch;
private $passwordAttribute;
private $extraFields;
public function __construct(
LdapInterface $ldap,
string $baseDn,
string $searchDn = null,
string $searchPassword = null,
array $defaultRoles = [],
string $uidKey = null,
string $filter = null,
string $passwordAttribute = null,
array $extraFields = []
)
{
In order to create your MyLdapUserProvider service that extends LdapUserProvider correctly you need a service-definition like this:
# services.yaml
services:
App\Security\MyLdapUserProvider:
arguments:
$adminEmail: '%admin_email%'
$ldap: '#Symfony\Component\Ldap\Ldap'
$baseDn: 'dc=XXXXXX,dc=com'
$searchDn: 'CN=XXXXXXXXXX,OU=LDAP,OU=Services Accounts,OU=Administration,DC=XXXXXXXXX,DC=com'
$searchPassword: 'ergergergergerg'
$defaultRoles: ['ROLE_USER']
$filter: '({uid_key}={username})'
$uidKey: 'samAccountName'

My Synfony2 app can't resolve a service dependency

I'm trying to integrate FOSUserBundle with HWIBundle, to add the social media connections to my app. The FOSUser is working perfectly, but I get a problem with the integration with HWIOAuthBundle.
Bundles are loaded in AppKernel, perfectly.
This is my config.yml
hwi_oauth:
connect:
account_connector: my_user_provider
firewall_name: name
fosub:
username_iterations: 30
properties:
facebook: facebook_id
google: google_id
resource_owners:
facebook:
type: facebook
client_id: "%facebook_app_id%"
client_secret: "%facebook_app_secret%"
scope: ""
google:
type: google
client_id: "%google_app_id%"
client_secret: "%google_app_secret%"
scope: "https://www.googleapis.com/auth/userinfo.email https://www.googleapis.com/auth/userinfo.profile"
This is my security.yml:
security:
encoders:
FOS\UserBundle\Model\UserInterface: sha512
role_hierarchy:
ROLE_ADMIN: ROLE_USER
ROLE_SUPER_ADMIN: ROLE_USER
providers:
fos_userbundle:
id: fos_user.user_provider.username_email
firewalls:
dev:
pattern: ^/(_(profiler|wdt)|css|images|js)/
security: false
main:
pattern: ^/
form_login:
provider: fos_userbundle
csrf_provider: form.csrf_provider
login_path: /login
check_path: /login_check
oauth:
resource_owners:
facebook: "/login/check-facebook"
google: "/login/check-google"
login_path: /login
failure_path: /login
oauth_user_provider:
service: my_user_provider
logout: true
anonymous: true
login:
pattern: ^/login$
security: false
remember_me:
key: "%secret%"
lifetime: 31536000 # 365 days in seconds
path: /
domain: ~ # Defaults to the current domain from $_SERVER
access_control:
- { path: ^/login$, role: IS_AUTHENTICATED_ANONYMOUSLY }
- { path: ^/register, role: IS_AUTHENTICATED_ANONYMOUSLY }
- { path: ^/resetting, role: IS_AUTHENTICATED_ANONYMOUSLY }
- { path: ^/backend/, role: ROLE_ADMIN }
This is my Bundle services.yml
parameters:
my_user_provider.class: Main\SiteBundle\Services\FOSUBUserProvider
services:
my_user_provider:
class: "%my_user_provider.class%"
arguments: [#fos_user.user_manager,{facebook: facebook_id, google: google_id}]
And this is the Service:
namespace Main\SiteBundle\Services;
use HWI\Bundle\OAuthBundle\OAuth\Response\UserResponseInterface;
use HWI\Bundle\OAuthBundle\Security\Core\User\FOSUBUserProvider as BaseClass;
use Symfony\Component\Security\Core\User\UserInterface;
class FOSUBUserProvider extends BaseClass
{
/**
* {#inheritDoc}
*/
public function connect(UserInterface $user, UserResponseInterface $response)
{
$property = $this->getProperty($response);
$username = $response->getUsername();
//on connect - get the access token and the user ID
$service = $response->getResourceOwner()->getName();
$setter = 'set'.ucfirst($service);
$setter_id = $setter.'Id';
$setter_token = $setter.'AccessToken';
//we "disconnect" previously connected users
if (null !== $previousUser = $this->userManager->findUserBy(array($property => $username))) {
$previousUser->$setter_id(null);
$previousUser->$setter_token(null);
$this->userManager->updateUser($previousUser);
}
//we connect current user
$user->$setter_id($username);
$user->$setter_token($response->getAccessToken());
$this->userManager->updateUser($user);
}
/**
* {#inheritdoc}
*/
public function loadUserByOAuthUserResponse(UserResponseInterface $response)
{
$username = $response->getUsername();
$user = $this->userManager->findUserBy(array($this->getProperty($response) => $username));
//when the user is registrating
if (null === $user) {
$service = $response->getResourceOwner()->getName();
$setter = 'set'.ucfirst($service);
$setter_id = $setter.'Id';
$setter_token = $setter.'AccessToken';
// create new user here
$user = $this->userManager->createUser();
$user->$setter_id($username);
$user->$setter_token($response->getAccessToken());
//I have set all requested data with the user's username
//modify here with relevant data
$user->setUsername($username);
$user->setEmail($username);
$user->setPassword($username);
$user->setEnabled(true);
$this->userManager->updateUser($user);
return $user;
}
//if user exists - go with the HWIOAuth way
$user = parent::loadUserByOAuthUserResponse($response);
$serviceName = $response->getResourceOwner()->getName();
$setter = 'set' . ucfirst($serviceName) . 'AccessToken';
//update access token
$user->$setter($response->getAccessToken());
return $user;
}
}
Yeah, this is the error I get in the browser:
ServiceNotFoundException in
CheckExceptionOnInvalidReferenceBehaviorPass.php line 58: The service
"hwi_oauth.security.oauth_utils" has a dependency on a non-existent
service "hwi_oauth.resource_ownermap.name".
While doing a "composer update" I get this
[Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException]
The service "hwi_oauth.security.oauth_utils" has a dependency on a
non-existent service "hwi_oauth.resource_ownermap.name".
Script
Sensio\Bundle\DistributionBundle\Composer\ScriptHandler::clearCache
handling the post-update-cmd event terminated with an exception
[RuntimeException] An error occurred when executing the
"'cache:clear --no-warmup'" command.
In config.yml you have configured hwi_oauth with "firewall_name: name".
But in security.yml you have no firewall with that name "name" (but you have a "main" named firewall not mentioned under hwi_oauth in config.yml). This causes the error message you have.

Custom FOSUBUserProvider not working properly

I've been following the instruction here: https://gist.github.com/danvbe/4476697, I have read the entire thread more than once, but I'm not getting a solution for my problem.
I want to use the oauth bundle just for account linking, persisting the user data from oauth provider. My users will not be authenticated using oauth.
Nevertheless, I have implemented the whole thing to see if it works with github as provider, but nothing. I'm able to go to the authorization page, but when I click on Allow Access, I'm inevitable redirected to the login page with this error No oauth code in the request.
If stop using the custom FOSUBUserProvider and change to the default HWI one, then I get the app registered in Github but cannot persist the data.
Important: I tried replicating exactly the FOSUBUserProvider from HWI and the same problem remained, so probably is not related it's implementation but maybe with the service definition or the config.
Any help is greatly appreciated.
These are the relevant files:
FOSUBUserProvider.php
class FOSUBUserProvider extends BaseClass
{
/**
* {#inheritDoc}
*/
public function connect(UserInterface $user, UserResponseInterface $response)
{
$property = $this->getProperty($response);
$username = $response->getUsername();
//on connect - get the access token and the user ID
$service = $response->getResourceOwner()->getName();
$setter = 'set'.ucfirst($service);
$setter_id = $setter.'Id';
$setter_token = $setter.'AccessToken';
//we "disconnect" previously connected users
if (null !== $previousUser = $this->userManager->findUserBy(array($property => $username))) {
$previousUser->$setter_id(null);
$previousUser->$setter_token(null);
$this->userManager->updateUser($previousUser);
}
//we connect current user
$user->$setter_id($username);
$user->$setter_token($response->getAccessToken());
$this->userManager->updateUser($user);
}
/**
* {#inheritdoc}
*/
public function loadUserByOAuthUserResponse(UserResponseInterface $response)
{
$username = $response->getUsername();
$user = $this->userManager->findUserBy(array($this->getProperty($response) => $username));
//when the user is registrating
if (null === $user) {
$service = $response->getResourceOwner()->getName();
$setter = 'set'.ucfirst($service);
$setter_id = $setter.'Id';
$setter_token = $setter.'AccessToken';
// create new user here
$user = $this->userManager->createUser();
$user->$setter_id($username);
$user->$setter_token($response->getAccessToken());
//I have set all requested data with the user's username
//modify here with relevant data
$user->setUsername($username);
$user->setEmail($username);
$user->setPassword($username);
$user->setEnabled(true);
$this->userManager->updateUser($user);
return $user;
}
//if user exists - go with the HWIOAuth way
$user = parent::loadUserByOAuthUserResponse($response);
$serviceName = $response->getResourceOwner()->getName();
$setter = 'set' . ucfirst($serviceName) . 'AccessToken';
//update access token
$user->$setter($response->getAccessToken());
return $user;
}
}
config.yml
hwi_oauth:
#this is my custom user provider, created from FOSUBUserProvider - will manage the
#automatic user registration on your site, with data from the provider (facebook. google, etc.)
#and also, the connecting part (get the token and the user_id)
connect:
account_connector: custom.user.provider
# name of the firewall in which this bundle is active, this setting MUST be set
firewall_name: main
# optional FOSUserBundle integration
fosub:
# try 30 times to check if a username is available (foo, foo1, foo2 etc)
username_iterations: 30
# mapping between resource owners (see below) and properties
properties:
github: githubId
# optional HTTP Client configuration
http_client:
verify_peer: false
resource_owners:
github:
type: github
client_id: xxxxxxxxxxxxxxxxxxxxxx
client_secret: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
scope: "repo, delete_repo, notifications, gist"
options:
csrf: true
security.yml
providers:
fos_userbundle:
id: fos_user.user_provider.username_email
firewalls: #CAUTION! The order of the firewalls IS ON PURPOSE! DON'T CHANGE!
# Disabling the security for the web debug toolbar, the profiler and Assetic.
dev:
pattern: ^/(_(profiler|wdt)|css|images|js)/
security: false
# -> custom firewall for the admin area of the URL
admin:
pattern: /admin(.*)
context: user
form_login:
provider: fos_userbundle
login_path: /admin/login
use_forward: false
check_path: /admin/login_check
failure_path: null
logout:
path: /admin/logout
anonymous: true
# -> end custom configuration
# defaut login area for standard users
# This firewall is used to handle the public login area
# This part is handled by the FOS User Bundle
main:
pattern: .*
context: user
form_login:
provider: fos_userbundle
login_path: /login
use_forward: false
check_path: /login_check
failure_path: null
logout: true
anonymous: true
# Login path for OAuth providers
oauth:
resource_owners:
github: "/login/check-github"
trello: "/login/check-trello"
login_path: /login
failure_path: /login
# FOSUB integration
# oauth_user_provider:
# service: hwi_oauth.user.provider.fosub_bridge
oauth_user_provider:
#this is my custom user provider, created from FOSUBUserProvider - will manage the
#automatic user registration on website, with data from the provider (github. trello, etc.)
service: custom.user.provider
access_control:
# URL of FOSUserBundle which need to be available to anonymous users
- { path: ^/login$, role: IS_AUTHENTICATED_ANONYMOUSLY }
- { path: ^/register, role: IS_AUTHENTICATED_ANONYMOUSLY }
- { path: ^/resetting, role: IS_AUTHENTICATED_ANONYMOUSLY }
# Admin login page needs to be access without credential
- { path: ^/admin/login$, role: IS_AUTHENTICATED_ANONYMOUSLY }
- { path: ^/admin/logout$, role: IS_AUTHENTICATED_ANONYMOUSLY }
- { path: ^/admin/login_check$, role: IS_AUTHENTICATED_ANONYMOUSLY }
# Secured part of the site
# This config requires being logged for the whole site and having the admin role for the admin part.
# Change these rules to adapt them to your needs
- { path: ^/admin/, role: [ROLE_ADMIN, ROLE_SONATA_ADMIN] }
- { path: ^/.*, role: ROLE_USER } #This is on purpose.
routing.yml
hwi_oauth_security:
resource: "#HWIOAuthBundle/Resources/config/routing/login.xml"
prefix: /connect
hwi_oauth_connect:
resource: "#HWIOAuthBundle/Resources/config/routing/connect.xml"
prefix: /connect
hwi_oauth_redirect:
resource: "#HWIOAuthBundle/Resources/config/routing/redirect.xml"
prefix: /connect
services.yml
parameters:
custom.user.provider.class: My\Bundle\Path\Security\Core\User\FOSUBUserProvider
services:
sonata.admin.user:
class: My\Bundle\Path\Admin\Model\UserAdmin
tags:
# - { name: sonata.admin, manager_type: orm, group: users, label: users, label_translator_strategy: sonata.admin.label.strategy.underscore }
arguments:
- ~
- My\Bundle\Path\Entity\User
- SonataAdminBundle:CRUD
calls:
- [setTranslationDomain, [SonataUserBundle]]
- [setUserManager, [#fos_user.user_manager]]
- [setSecurityContext, [#security.context]]
custom.user.provider:
class: "%custom.user.provider.class%"
#this is the place where the properties are passed to the UserProvider - see config.yml
arguments: [#fos_user.user_manager,{github: github_id, trello: trello_id}]
Well, after a lot of try and error, I found the problem:
The callback URL in Github was: http://mywebsite/login/check-github but that was wrong. The truth is that I never found what this value had to be set up to, so I was guessing. By accident I discovered the right URL: http://mywebsite/connect/service/github applicable in my case, with my configuration.
I found it in one of the times in wich I tried the default HWI Provider, inspecting the redirects with the browser console.

Symfony 2 + JMSSecurityExtraBundle: #PreAuthorize('permitAll') doesn't work

I have a project with / put behind a firewall. However, I want one of my controllers to be "insecure", e.g display its contents regardless of authentication. But whatever I do, the bundle stays secure.
My current approach is:
security.yml:
jms_security_extra:
secure_all_services: true
expressions: true
security:
encoders:
BrokernetGroup\Platea\SecurityBundle\Entity\User:
id: brokernet_group_platea_security.crypt_encoder
role_hierarchy:
providers:
db_users:
entity:
class: BrokernetGroup\Platea\SecurityBundle\Entity\User
property: username
firewalls:
dev:
pattern: ^/(_(profiler|wdt)|css|images|js)/
security: false
login:
pattern: ^/login.html$
security: false
protected_area:
pattern: ^/
form_login:
check_path: /login-check.do
login_path: /login.html
logout:
path: /logout.do
target: /
access_control:
Controller skeleton:
<?php
namespace BrokernetGroup\Platea\InfoBundle\Controller;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template;
use JMS\SecurityExtraBundle\Annotation as SE;
/**
* Description of InfoController
*
* #author Gergely Polonkai
*
* #SE\PreAuthorize("permitAll")
*/
class InfoController
{
/**
* #Route("/", name="BrokernetGroupPlateaInfo_homepage", hostnamePattern="{hostname}", requirements={"hostname" = "%www_hostnames%"})
* #Template
*/
public function homepageAction()
{
return array();
}
}
add anonymous: ~ below the protected_area: in your security.yml file for enabling anonymous token

Resources