diff --git a/foo.php b/foo.php index 9ba1721656b9ca4845ca2c98d9c018b9ec4e81b5..3def053d853fd6dcaa2f9e5c8d7cb62fc3ab047d 100644 --- a/foo.php +++ b/foo.php @@ -7,24 +7,6 @@ $request = \Symfony\Component\HttpFoundation\Request::createFromGlobals(); $dispatcher = new \Symfony\Component\EventDispatcher\EventDispatcher(); - -///////////////////////// -/// AUTHENTICATION - -// Preparation - - -// Auth - -// Should happen in CustomAuthenticationListener -/* -$providers = [new \BiiG\SecurityTest\CustomAuthenticationProvider()]; -$authenticationManager = new \Symfony\Component\Security\Core\Authentication\AuthenticationProviderManager($providers); -$authenticatedToken = $authenticationManager->authenticate($unauthenticatedToken); -//*/ - - - /////////////////////// /// FIREWALL @@ -35,17 +17,13 @@ $requestMatcher = new \Symfony\Component\HttpFoundation\RequestMatcher('^/'); $tokenStorage = new \Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorage(); // instances of Symfony\Component\Security\Http\Firewall\ListenerInterface -$listeners = [new \BiiG\SecurityTest\CustomAuthenticationListener( - $tokenStorage, - new \BiiG\SecurityTest\CustomAuthenticationProvider(), - 'swagg' -)]; - - -$anonymousClass = \Symfony\Component\Security\Core\Authentication\Token\AnonymousToken::class; -$rememberMeClass = \Symfony\Component\Security\Core\Authentication\Token\RememberMeToken::class; - -$trustResolver = new \Symfony\Component\Security\Core\Authentication\AuthenticationTrustResolver($anonymousClass, $rememberMeClass); +$listeners = [ + new \BiiG\SecurityTest\CustomAuthenticationListener( + $tokenStorage, + new \BiiG\SecurityTest\CustomAuthenticationProvider(), + 'swagg' + ) +]; // The exception listener object is too complex for this example /* diff --git a/index.php b/index.php deleted file mode 100644 index 0d6d1e7e666ad03c4c9bb6b4309bc4591640b1a1..0000000000000000000000000000000000000000 --- a/index.php +++ /dev/null @@ -1,71 +0,0 @@ -<?php - -require __DIR__ . '/vendor/autoload.php'; - -use Symfony\Component\Security\Core\Authentication\AuthenticationProviderManager; -use Symfony\Component\Security\Core\Exception\AuthenticationException; -use Symfony\Component\Security\Core\User\InMemoryUserProvider; - -use Symfony\Component\Security\Core\Authentication\Provider\DaoAuthenticationProvider; -use Symfony\Component\Security\Core\User\UserChecker; - -use Symfony\Component\Security\Core\Encoder\EncoderFactory; -use Symfony\Component\Security\Core\Encoder\MessageDigestPasswordEncoder; -use Symfony\Component\Security\Core\User\User; - -$app = new Silex\Application(); - -$app['debug'] = true; - -$userProvider = new InMemoryUserProvider( - array( - 'admin' => array( - // password is "foo" - 'password' => '5FZ2Z8QIkA7UTZ4BYkoC+GsReLf569mSKDsfods6LYQ8t+a8EW9oaircfMpmaLbPBh4FOBiiFyLfuZmTSUwzZg==', - 'roles' => array('ROLE_ADMIN'), - ), - ) -); - - -$app->get('/', function () use ($userProvider) { - - - $providers = [new \BiiG\SecurityTest\CustomAuthenticationProvider()]; - $authenticationManager = new AuthenticationProviderManager($providers); - - // for some extra checks: is account enabled, locked, expired, etc. - $userChecker = new \Symfony\Component\Security\Core\User\UserChecker(); - - try { - $authenticatedToken = $authenticationManager - ->authenticate($unauthenticatedToken); - - -// for some extra checks: is account enabled, locked, expired, etc. - $userChecker = new UserChecker(); - -// an array of password encoders (see below) - $encoderFactory = new EncoderFactory([ - User::class => new MessageDigestPasswordEncoder('sha512', true, 5000), - ]); - - $provider = new DaoAuthenticationProvider( - $userProvider, - $userChecker, - 'secured_area', - $encoderFactory - ); - - $provider->authenticate($unauthenticatedToken); - - } catch (AuthenticationException $failed) { - // authentication failed - } - - - return '<h1>Hello world</h1>'; -}); - - -$app->run();