-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[Security] AuthenticatorManager to make "authenticators" first-class security #33558
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
fabpot
merged 30 commits into
symfony:master
from
wouterj:security/deprecate-providers-listeners
Apr 21, 2020
Merged
Changes from 1 commit
Commits
Show all changes
30 commits
Select commit
Hold shift + click to select a range
c321f4d
Created GuardAuthenticationManager to make Guard first-class Security
wouterj a6890db
Created HttpBasicAuthenticator and some Guard traits
wouterj 9b7fddd
Integrated GuardAuthenticationManager in the SecurityBundle
wouterj a172bac
Added FormLogin and Anonymous authenticators
wouterj 526f756
Added GuardManagerListener
wouterj 5013258
Add provider key in PreAuthenticationGuardToken
wouterj 5efa892
Create a new core AuthenticatorInterface
wouterj fa4b3ec
Implemented password migration for the new authenticators
wouterj 4c06236
Fixes after testing in Demo application
wouterj 873b949
Mark new core authenticators as experimental
wouterj b923e4c
Enabled remember me for the GuardManagerListener
wouterj b14a5e8
Moved new authenticator to the HTTP namespace
wouterj 999ec27
Refactor to an event based authentication approach
wouterj 7859977
Removed all mentions of 'guard' in the new system
wouterj 1c810d5
Added support for lazy firewalls
wouterj ddf430f
Added remember me functionality
wouterj 09bed16
Only load old manager if new system is disabled
wouterj 44cc76f
Use one AuthenticatorManager per firewall
wouterj bf1a452
Merge AuthenticatorManager and AuthenticatorHandler
wouterj 60d396f
Added automatically CSRF protected authenticators
wouterj 59f49b2
Rename AuthenticatingListener
wouterj 6b9d78d
Added tests
wouterj ba3754a
Differentiate between interactive and non-interactive authenticators
wouterj f5e11e5
Reverted changes to the Guard component
wouterj 95edc80
Added pre-authenticated authenticators (X.509 & REMOTE_USER)
wouterj 7ef6a7a
Use the firewall event dispatcher
wouterj 0fe5083
Added JSON login authenticator
wouterj 9ea32c4
Also use authentication failure/success handlers in FormLoginAuthenti…
wouterj 50224aa
Introduce Passport & Badges to extend authenticators
wouterj b1e040f
Rename providerKey to firewallName for more consistent naming
wouterj File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Use one AuthenticatorManager per firewall
- Loading branch information
commit 44cc76fec2c0c98336a8cdd015719f8dad912545
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
48 changes: 48 additions & 0 deletions
48
src/Symfony/Bundle/SecurityBundle/Security/FirewallAwareAuthenticatorManager.php
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the Symfony package. | ||
* | ||
* (c) Fabien Potencier <fabien@symfony.com> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace Symfony\Bundle\SecurityBundle\Security; | ||
|
||
use Symfony\Component\DependencyInjection\ServiceLocator; | ||
use Symfony\Component\HttpFoundation\RequestStack; | ||
use Symfony\Component\Security\Core\Authentication\AuthenticationManagerInterface; | ||
use Symfony\Component\Security\Core\Authentication\Token\TokenInterface; | ||
use Symfony\Component\Security\Core\Exception\LogicException; | ||
|
||
/** | ||
* A decorator that delegates all method calls to the authenticator | ||
* manager of the current firewall. | ||
* | ||
* @author Wouter de Jong <wouter@wouterj.nl> | ||
*/ | ||
class FirewallAwareAuthenticatorManager implements AuthenticationManagerInterface | ||
{ | ||
private $firewallMap; | ||
private $authenticatorManagers; | ||
private $requestStack; | ||
|
||
public function __construct(FirewallMap $firewallMap, ServiceLocator $authenticatorManagers, RequestStack $requestStack) | ||
{ | ||
$this->firewallMap = $firewallMap; | ||
$this->authenticatorManagers = $authenticatorManagers; | ||
$this->requestStack = $requestStack; | ||
} | ||
|
||
public function authenticate(TokenInterface $token) | ||
{ | ||
$firewallConfig = $this->firewallMap->getFirewallConfig($this->requestStack->getMasterRequest()); | ||
if (null === $firewallConfig) { | ||
throw new LogicException('Cannot call authenticate on this request, as it is not behind a firewall.'); | ||
} | ||
|
||
return $this->authenticatorManagers->get($firewallConfig->getName())->authenticate($token); | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.