New method skipAuthorizationActions - #341
Conversation
| "stan-baseline": "tools/phpstan --generate-baseline", | ||
| "stan-setup": "phive install", | ||
| "rector-setup": "cp composer.json composer.backup && composer require --dev rector/rector:\"~2.3.1\" && mv composer.backup composer.json", | ||
| "rector-setup": "cp composer.json composer.backup && composer require --dev rector/rector --with-dependencies && mv composer.backup composer.json", |
There was a problem hiding this comment.
That change was necessary for the cs-stan / Coding Standard & Static Analysis test to work and return its results.
I simply wanted to test what that test said; if necessary, I'll undo that commit.
There was a problem hiding this comment.
I guess we would need to get 3.x green again independently.
|
Also please check your solution on: Fatal on canResult() and authorize(). performCheck returns bool true, canResult() declares : ResultInterface: TypeError: AuthorizationComponent::canResult(): Return value must be of type |
|
It may not be the best code, but since it's a method that must return a different type depending on the calling method, it's the only solution I could think of. $skipAuthorization = $this->checkAction($action, 'skipAuthorization');
if ($skipAuthorization) {
$this->skipAuthorization();
return match ($method) {
'can' => true,
'canResult' => new Result(true),
};
} |
|
I believe the intention was to unify the verification and authorization methods for controller and model actions. This decision could lead to I wanted to write the following: $this->authorizeAction();
if ($this->getService($request)->authorizationChecked()) {
return true;
}But in PHPUnit, this resulted in infinite recursion: If we had two |
|
Isn't this PR effectively reimplementing what's already possible with RequestAuthorizationMiddleware? |
|
It follows the same logic as In a controller where many methods don't require authorization, such as the UsersController, which combines login and logout methods (and others like 2FA verification) with user management methods, it becomes very tedious to write |
Draft, mainly to have something concrete to discuss on #339.