-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[Workflow] Override guard listener class #29751
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,13 +24,13 @@ | |
*/ | ||
class GuardListener | ||
{ | ||
private $configuration; | ||
private $expressionLanguage; | ||
private $tokenStorage; | ||
private $authorizationChecker; | ||
private $trustResolver; | ||
private $roleHierarchy; | ||
private $validator; | ||
protected $configuration; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That's a no-go: we strongly favor private properties because it helps maintenance a lot. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks for the feedback. So as I understand it, it is preferable to create my own new class completely override the listener.guard services declaration. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yes - you can decorate the core listener if it serves your purpose, but only via composition, ie using its public API. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Since there is a no-go on changing the GuardListener properties visibility and there is other ways to serve my purpose, it seems this pull request can be closed |
||
protected $expressionLanguage; | ||
protected $tokenStorage; | ||
protected $authorizationChecker; | ||
protected $trustResolver; | ||
protected $roleHierarchy; | ||
protected $validator; | ||
|
||
public function __construct(array $configuration, ExpressionLanguage $expressionLanguage, TokenStorageInterface $tokenStorage, AuthorizationCheckerInterface $authorizationChecker, AuthenticationTrustResolverInterface $trustResolver, RoleHierarchyInterface $roleHierarchy = null, ValidatorInterface $validator = null) | ||
{ | ||
|
@@ -62,15 +62,15 @@ public function onTransition(GuardEvent $event, $eventName) | |
} | ||
} | ||
|
||
private function validateGuardExpression(GuardEvent $event, $expression) | ||
protected function validateGuardExpression(GuardEvent $event, $expression) | ||
{ | ||
if (!$this->expressionLanguage->evaluate($expression, $this->getVariables($event))) { | ||
$event->setBlocked(true); | ||
} | ||
} | ||
|
||
// code should be sync with Symfony\Component\Security\Core\Authorization\Voter\ExpressionVoter | ||
private function getVariables(GuardEvent $event) | ||
protected function getVariables(GuardEvent $event) | ||
{ | ||
$token = $this->tokenStorage->getToken(); | ||
|
||
|
Uh oh!
There was an error while loading. Please reload this page.