Skip to content

Instantly share code, notes, and snippets.

@MaximStrutinskiy
Created September 18, 2017 06:05
Show Gist options
  • Save MaximStrutinskiy/d07112c8920c7d80a0436b242c1e0fe8 to your computer and use it in GitHub Desktop.
Save MaximStrutinskiy/d07112c8920c7d80a0436b242c1e0fe8 to your computer and use it in GitHub Desktop.
$app->register(new Silex\Provider\SecurityServiceProvider(),
[
$app['security.firewalls'] = [
'secured' => [
'pattern' => '^/',
'anonymous' => true,
'form' => [
'login_path' => '/login',
'check_path' => '/admin/login_check',
],
'logout' => [
'logout_path' => '/admin/logout',
'invalidate_session' => true,
],
'users' => function () use ($app) {
return $app['user_repository'];
}
],
],
$app['security.role_hierarchy'] = [
'ROLE_ADMIN' => [
'ROLE_USER',
'ROLE_ALLOWED_TO_SWITCH',
],
],
$app['security.access_rules'] = [
['^/$', 'IS_AUTHENTICATED_ANONYMOUSLY'],
['^/admin', 'ROLE_ADMIN'],
],
]
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment