-
-
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 all commits
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
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
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
29 changes: 29 additions & 0 deletions
29
...dle/SecurityBundle/DependencyInjection/Security/Factory/AuthenticatorFactoryInterface.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,29 @@ | ||
<?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\DependencyInjection\Security\Factory; | ||
|
||
use Symfony\Component\DependencyInjection\ContainerBuilder; | ||
|
||
/** | ||
* @author Wouter de Jong <wouter@wouterj.nl> | ||
* | ||
* @experimental in 5.1 | ||
*/ | ||
interface AuthenticatorFactoryInterface | ||
{ | ||
/** | ||
* Creates the authenticator service(s) for the provided configuration. | ||
* | ||
* @return string|string[] The authenticator service ID(s) to be used by the firewall | ||
*/ | ||
public function createAuthenticator(ContainerBuilder $container, string $firewallName, array $config, string $userProviderId); | ||
} |
56 changes: 56 additions & 0 deletions
56
...Bundle/SecurityBundle/DependencyInjection/Security/Factory/CustomAuthenticatorFactory.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,56 @@ | ||
<?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\DependencyInjection\Security\Factory; | ||
|
||
use Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition; | ||
use Symfony\Component\Config\Definition\Builder\NodeDefinition; | ||
use Symfony\Component\DependencyInjection\ContainerBuilder; | ||
|
||
class CustomAuthenticatorFactory implements AuthenticatorFactoryInterface, SecurityFactoryInterface | ||
{ | ||
public function create(ContainerBuilder $container, string $id, array $config, string $userProvider, ?string $defaultEntryPoint) | ||
{ | ||
throw new \LogicException('Custom authenticators are not supported when "security.enable_authenticator_manager" is not set to true.'); | ||
} | ||
|
||
public function getPosition(): string | ||
{ | ||
return 'pre_auth'; | ||
} | ||
|
||
public function getKey(): string | ||
{ | ||
return 'custom_authenticator'; | ||
} | ||
|
||
/** | ||
* @param ArrayNodeDefinition $builder | ||
*/ | ||
public function addConfiguration(NodeDefinition $builder) | ||
{ | ||
$builder | ||
->fixXmlConfig('service') | ||
wouterj marked this conversation as resolved.
Show resolved
Hide resolved
|
||
->children() | ||
->arrayNode('services') | ||
->info('An array of service ids for all of your "authenticators"') | ||
->requiresAtLeastOneElement() | ||
->prototype('scalar')->end() | ||
->end() | ||
->end() | ||
; | ||
} | ||
|
||
public function createAuthenticator(ContainerBuilder $container, string $firewallName, array $config, string $userProviderId): array | ||
{ | ||
return $config['services']; | ||
} | ||
} |
27 changes: 27 additions & 0 deletions
27
...Bundle/SecurityBundle/DependencyInjection/Security/Factory/EntryPointFactoryInterface.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,27 @@ | ||
<?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\DependencyInjection\Security\Factory; | ||
|
||
use Symfony\Component\DependencyInjection\ContainerBuilder; | ||
|
||
/** | ||
* @author Wouter de Jong <wouter@wouterj.nl> | ||
* | ||
* @experimental in 5.1 | ||
*/ | ||
interface EntryPointFactoryInterface | ||
{ | ||
/** | ||
* Creates the entry point and returns the service ID. | ||
*/ | ||
public function createEntryPoint(ContainerBuilder $container, string $id, array $config, ?string $defaultEntryPointId): string; | ||
} |
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
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
Oops, something went wrong.
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.