-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[DX][SecurityBundle] Introduce a FirewallConfig class accessible from FirewallContext #19398
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
Merged
Changes from all commits
Commits
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
126 changes: 126 additions & 0 deletions
126
src/Symfony/Bundle/SecurityBundle/Security/FirewallConfig.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,126 @@ | ||
<?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; | ||
|
||
/** | ||
* @author Robin Chalas <robin.chalas@gmail.com> | ||
*/ | ||
class FirewallConfig | ||
{ | ||
private $name; | ||
private $requestMatcher; | ||
private $securityEnabled; | ||
private $stateless; | ||
private $provider; | ||
private $context; | ||
private $entryPoint; | ||
private $accessDeniedHandler; | ||
private $accessDeniedUrl; | ||
private $userChecker; | ||
private $listeners; | ||
|
||
public function __construct($name, $requestMatcher, $securityEnabled = true, $stateless = false, $provider = null, $context = null, $entryPoint = null, $accessDeniedHandler = null, $accessDeniedUrl = null, $userChecker = null, $listeners = array()) | ||
{ | ||
$this->name = $name; | ||
$this->requestMatcher = $requestMatcher; | ||
$this->securityEnabled = $securityEnabled; | ||
$this->stateless = $stateless; | ||
$this->provider = $provider; | ||
$this->context = $context; | ||
$this->entryPoint = $entryPoint; | ||
$this->accessDeniedHandler = $accessDeniedHandler; | ||
$this->accessDeniedUrl = $accessDeniedUrl; | ||
$this->userChecker = $userChecker; | ||
$this->listeners = $listeners; | ||
} | ||
|
||
public function getName() | ||
{ | ||
return $this->name; | ||
} | ||
|
||
/** | ||
* @return string The request matcher service id | ||
*/ | ||
public function getRequestMatcher() | ||
{ | ||
return $this->requestMatcher; | ||
} | ||
|
||
public function isSecurityEnabled() | ||
{ | ||
return $this->securityEnabled; | ||
} | ||
|
||
public function allowsAnonymous() | ||
{ | ||
return in_array('anonymous', $this->listeners, true); | ||
} | ||
|
||
public function isStateless() | ||
{ | ||
return $this->stateless; | ||
} | ||
|
||
/** | ||
* @return string The provider service id | ||
*/ | ||
public function getProvider() | ||
{ | ||
return $this->provider; | ||
} | ||
|
||
/** | ||
* @return string The context key | ||
*/ | ||
public function getContext() | ||
{ | ||
return $this->context; | ||
} | ||
|
||
/** | ||
* @return string The entry_point service id | ||
*/ | ||
public function getEntryPoint() | ||
{ | ||
return $this->entryPoint; | ||
} | ||
|
||
/** | ||
* @return string The user_checker service id | ||
*/ | ||
public function getUserChecker() | ||
{ | ||
return $this->userChecker; | ||
} | ||
|
||
/** | ||
* @return string The access_denied_handler service id | ||
*/ | ||
public function getAccessDeniedHandler() | ||
{ | ||
return $this->accessDeniedHandler; | ||
} | ||
|
||
public function getAccessDeniedUrl() | ||
{ | ||
return $this->accessDeniedUrl; | ||
} | ||
|
||
/** | ||
* @return array An array of listener keys | ||
*/ | ||
public function getListeners() | ||
{ | ||
return $this->listeners; | ||
} | ||
} |
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
missing
for the
anonymous
listener registered increateAuthenticationListeners()
?Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added. Thanks
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe
anonymous
could be a boolean parameter of the config to be exposed in the collector.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good idea.
Could you give me your opinion about the
FirewallConfig::$listenerConfigs
property?I'm not sure it is useful, values cannot be the final ones so it is pretty much a dump of what is written in yaml. Plus, I really don't see how I should display them into the profiler.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As it is a native listener, I'll be in favor of adding a
has/authorizes/acceptsAnonymous
method indeed.IMHO, as we've discussed about, as this is almost the raw configuration for listeners, we should probably not expose it but instead simply list enabled listeners for the given firewall. Thus you can simply show in the profiler the list of enabled listeners.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
allowsAnonymous
considering https://github.com/symfony/symfony/pull/19490/files/acd4ceac12c252adf7e8399f08d23ad6d1f46fee#r72892574There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you're right. Some sensible data such as passphrase, secret (i.e. anonymous), ... should probably not be displayed in the profiler (#19490).
Would you totally avoid storing the configuration of each registered listener and only store their names instead? Or keep it as is and just list
array_keys($listenerConfigs)
in #19490?Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would totally avoid storing this config. Having the listeners config like this is not reliable. It'll only be if each listener were forced to register their own processed config themself in a
FirewallListenerConfig
instance. And use-cases are probably too marginal.So, keeping the list of registered listeners name should be enough to me.