Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
symfony-secu-test
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Container Registry
Model registry
Analyze
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Maxime Veber
symfony-secu-test
Commits
5a79b5c7
Commit
5a79b5c7
authored
7 years ago
by
Maxime Veber
Browse files
Options
Downloads
Patches
Plain Diff
Remove useless code
parent
4d28696e
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
foo.php
+7
-29
7 additions, 29 deletions
foo.php
index.php
+0
-71
0 additions, 71 deletions
index.php
with
7 additions
and
100 deletions
foo.php
+
7
−
29
View file @
5a79b5c7
...
...
@@ -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
/*
...
...
This diff is collapsed.
Click to expand it.
index.php
deleted
100644 → 0
+
0
−
71
View file @
4d28696e
<?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
();
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment