PHP code example of alejandroherr / silex-esngalaxysecurityserviceprovider
1. Go to this page and download the library: Download alejandroherr/silex-esngalaxysecurityserviceprovider library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
alejandroherr / silex-esngalaxysecurityserviceprovider example snippets
{
" "alejandroherr/silex-esngalaxysecurityserviceprovider": "0.1"
}
}
$app->register(new Silex\Provider\SessionServiceProvider());
$app->register(new SecurityServiceProvider());
$app->register(new AlejandroHerr\Silex\EsnGalaxy\EsnGalaxyServiceProvider());
$app['security.firewalls'] = [
'main' => [
'esn_galaxy' => array(
'pattern' => '^/.*$',
'anonymous' => true,
'esn_galaxy' => [
'cas_server' => [
//'base_url' => 'galaxy.esn.org',
//'context' => 'cas',
//'port' => 443
//'login_path' => '/login',
//'validation_path' => '/serviceValidate'
],
//'check_path' => '/cas/validation',
//'login_path' => '/login',
// 'first_login_path' => '/welcome_user'
'auth' => [
//'*' => [
// 'Local.activeMember' => 'ROLE_USER',
// 'Local.regularBoardMember' => 'ROLE_BOARD',
// ]
//]
]
]
],
'logout' => ['logout_path' => '/logout'], //if you want a logout
'users' => $app->share(function() use ($app){
return new Your\UserProvider();
})
]
];
$app['security.access_rules'] = array(
array('^\/(?!login)', 'ROLE_USER'),
);
'auth' => [
'section1' => [
'galaxy_role1' => 'app_role1',
'galaxy_role2' => 'app_role2',
],
'section2' => [
'galaxy_role1' => 'app_role1',
'galaxy_role3' => 'app_role2',
]
]
'auth' => [
'*' => [
'Local.activeMember' => 'ROLE_USER',
'Local.regularBoardMember' => 'ROLE_BOARD',
]
]
'auth' => [
'/^ES/' => [
'Local.activeMember' => 'ROLE_USER',
'Local.regularBoardMember' => 'ROLE_BOARD',
]
]
'auth' => [
'/^ES/' => [
'National.regularBoardMember' => 'ROLE_USER',
]
]
$app->match('/login', function () use ($app){
$errormsg = null;
if($app['session']->has(SecurityContextInterface::AUTHENTICATION_ERROR)){
$error = $app['session']->get(SecurityContextInterface::AUTHENTICATION_ERROR);
$errormsg = $error->getMessage();
}
return $app['twig']->render(
'login.twig',
array(
'loginUrl' => $app['jasig_cas_client']->getLoginUrl($app['request']),
'error' => $errormsg
)
);
});
$app->match('/validation', function() use ($app){});