Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feature #19398 [DX][SecurityBundle] Introduce a FirewallConfig class …
…accessible from FirewallContext (chalasr) This PR was merged into the 3.2-dev branch. Discussion ---------- [DX][SecurityBundle] Introduce a FirewallConfig class accessible from FirewallContext | Q | A | | --- | --- | | Branch? | master | | Bug fix? | no | | New feature? | yes | | BC breaks? | no | | Deprecations? | yes but it should not have any impact in userland | | Tests pass? | yes | | Fixed tickets | #15294 | | License | MIT | | Doc PR | todo | With this, the `FirewallContext` class now has a `getConfig()` method returning a `FirewallConfig` object representing the firewall configuration. Also this adds a `getContext()` method to the `FirewallMap` class of the `SecurityBundle`, to be able to retrieve the current context. In a next time, this could be useful to display some firewall related informations to the Profiler, as pointed out in #15294. Also, it can be useful to be able to access the current firewall configuration from an AuthenticationListener, especially for third party bundles (I can develop on demand). Commits ------- 52d25ed Introduce a FirewallConfig class
- Loading branch information
Showing
8 changed files
with
394 additions
and
8 deletions.
There are no files selected for viewing
This file contains 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 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 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 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 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.