-
-
Notifications
You must be signed in to change notification settings - Fork 9.7k
[Security] Be able to know the reasons of the denied access #35592
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 1 commit
26a8381
868b9ff
edfc392
ec41df2
842e59e
7339108
8ef8d19
c8a360c
c4cfb5f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -26,7 +26,7 @@ interface AccessDecisionManagerInterface | |
* @param array $attributes An array of attributes associated with the method being invoked | ||
* @param object $object The object to secure | ||
* | ||
* @return bool|AccessDecision true if the access is granted, false otherwise | ||
* @return bool|AccessDecision Returning a boolean is deprecated since Symfony 5.1. Return an AccessDecision object instead. | ||
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. This interface is not internal, so we should also be BC with the usage of the method AFAIK. I don't think we currently preserve backwards compatibility in e.g. this example: if (!$accessDecisionManager->decide(...)) {
throw new AccessDeniedException();
} If an |
||
*/ | ||
public function decide(TokenInterface $token, array $attributes, $object = null); | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,9 +11,12 @@ | |
|
||
namespace Symfony\Component\Security\Core\Authorization\Voter; | ||
|
||
/** | ||
* @author Dany Maillard <danymaillard93b@gmail.com> | ||
*/ | ||
trait AccessTrait | ||
{ | ||
/** @var int */ | ||
/** @var int One of the VoterInterface::ACCESS_* constants */ | ||
protected $access; | ||
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. Should be private. 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. Already discussed here #35592 (comment). Ok for you ? 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. Not sure to understand the rationale there. |
||
|
||
public function getAccess(): int | ||
|
Original file line number | Diff line number | Diff line change | ||||||
---|---|---|---|---|---|---|---|---|
|
@@ -11,13 +11,22 @@ | |||||||
|
||||||||
namespace Symfony\Component\Security\Core\Authorization\Voter; | ||||||||
|
||||||||
/** | ||||||||
* A Vote is returned by a Voter and contains the access (granted, abstain or denied). It can also contains a reason | ||||||||
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.
Suggested change
|
||||||||
* explaining the why of the access which has been decided. | ||||||||
* | ||||||||
* @author Dany Maillard <danymaillard93b@gmail.com> | ||||||||
*/ | ||||||||
final class Vote | ||||||||
{ | ||||||||
use AccessTrait; | ||||||||
|
||||||||
private $reason; | ||||||||
private $parameters; | ||||||||
maidmaid marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||
|
||||||||
/** | ||||||||
* @param int $access One of the VoterInterface::ACCESS_* constants | ||||||||
*/ | ||||||||
private function __construct(int $access, string $reason = '', array $parameters = []) | ||||||||
{ | ||||||||
$this->access = $access; | ||||||||
|
Uh oh!
There was an error while loading. Please reload this page.