-
-
Notifications
You must be signed in to change notification settings - Fork 424
MakeAuthenticator : update security.yaml #261
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
weaverryan
merged 5 commits into
symfony:master
from
nikophil:make-auth-update-security
Sep 11, 2018
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
2fb5b40
add authenticator in security.yaml the simplest way
nikophil c63a86a
Add authenticator : let the user chose which firewall to update
nikophil 2186549
Add entry point if one or more authenticators exist on chosen firewall
nikophil a983caa
fixes after PR
nikophil 3a26d98
add return type to InteractiveSecurityHelper::guessFirewallName
nikophil 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the Symfony MakerBundle 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\MakerBundle\Security; | ||
|
||
use Symfony\Bundle\MakerBundle\Exception\RuntimeCommandException; | ||
use Symfony\Component\Console\Style\SymfonyStyle; | ||
|
||
/** | ||
* @internal | ||
*/ | ||
final class InteractiveSecurityHelper | ||
{ | ||
public function guessFirewallName(SymfonyStyle $io, array $securityData): string | ||
{ | ||
$realFirewalls = array_filter( | ||
$securityData['security']['firewalls'] ?? [], | ||
function ($item) { | ||
return !isset($item['security']) || true === $item['security']; | ||
} | ||
); | ||
|
||
if (0 === \count($realFirewalls)) { | ||
return 'main'; | ||
} | ||
|
||
if (1 === \count($realFirewalls)) { | ||
return key($realFirewalls); | ||
} | ||
|
||
return $io->choice('Which firewall do you want to update ?', array_keys($realFirewalls), key($realFirewalls)); | ||
} | ||
|
||
public function guessEntryPoint(SymfonyStyle $io, array $securityData, string $authenticatorClass, string $firewallName) | ||
nikophil marked this conversation as resolved.
Show resolved
Hide resolved
|
||
{ | ||
if (!isset($securityData['security'])) { | ||
$securityData['security'] = []; | ||
} | ||
|
||
if (!isset($securityData['security']['firewalls'])) { | ||
$securityData['security']['firewalls'] = []; | ||
} | ||
|
||
$firewalls = $securityData['security']['firewalls']; | ||
if (!isset($firewalls[$firewallName])) { | ||
throw new RuntimeCommandException(sprintf('Firewall "%s" does not exist', $firewallName)); | ||
} | ||
|
||
if (!isset($firewalls[$firewallName]['guard']) | ||
|| !isset($firewalls[$firewallName]['guard']['authenticators']) | ||
|| !$firewalls[$firewallName]['guard']['authenticators'] | ||
|| isset($firewalls[$firewallName]['guard']['entry_point'])) { | ||
return null; | ||
} | ||
|
||
$authenticators = $firewalls[$firewallName]['guard']['authenticators']; | ||
$authenticators[] = $authenticatorClass; | ||
|
||
return $io->choice( | ||
'The entry point for your firewall is what should happen when an anonymous user tries to access | ||
a protected page. For example, a common "entry point" behavior is to redirect to the login page. | ||
The "entry point" behavior is controlled by the start() method on your authenticator. | ||
However, you will now have multiple authenticators. You need to choose which authenticator\'s | ||
start() method should be used as the entry point (the start() method on all other | ||
authenticators will be ignored, and can be blank.', | ||
$authenticators, | ||
current($authenticators) | ||
); | ||
} | ||
} |
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.