feat(security): Add PHP \Attribute for remaining security annotations - #37905
Conversation
There was a problem hiding this comment.
Psalm found more than 10 potential problems in the proposed changes. Check the Files changed tab for more details.
4f53919 to
a64daa3
Compare
a64daa3 to
203f182
Compare
Signed-off-by: Joas Schilling <coding@schilljs.com>
203f182 to
ecb8b55
Compare
|
Comment for #37039 on merge: |
vitormattos
left a comment
There was a problem hiding this comment.
Only suggestions, not blocking points.
| if ($this->reflector->hasAnnotation($annotationName)) { | ||
| return true; | ||
| } | ||
|
|
| @@ -114,23 +141,25 @@ public function beforeController($controller, $methodName) { | |||
| * @throws SecurityException | |||
| */ | |||
| public function afterController($controller, $methodName, Response $response) { | |||
There was a problem hiding this comment.
This will impact a lot of classes but would be good create a followup issue to do this fix return type and others from Middleware abstract class:
| public function afterController($controller, $methodName, Response $response) { | |
| public function afterController($controller, $methodName, Response $response): void { |
| * @param class-string<T> $attributeClass | ||
| * @return boolean | ||
| */ | ||
| protected function hasAnnotationOrAttribute(ReflectionMethod $reflectionMethod, string $annotationName, string $attributeClass): bool { |
There was a problem hiding this comment.
This method occur 3 times at this PR with the same signature.
Maybe will be good to move to parent class.
There was a problem hiding this comment.
This ia only temporary until we drop the annotations and its 2 if statements. I don't really feel like creating an abstract parent class for 4 operational lines
| * @return boolean | ||
| */ | ||
| protected function hasAnnotationOrAttribute(ReflectionMethod $reflectionMethod, string $annotationName, string $attributeClass): bool { | ||
| if ($this->reflector->hasAnnotation($annotationName)) { |
There was a problem hiding this comment.
At other implements of this method on this PR you used the follow code. Make any difference or only was about wrote more times the same method without doing a copy paste?
| if ($this->reflector->hasAnnotation($annotationName)) { | |
| if (!empty($reflectionMethod->getAttributes($attributeClass))) { |
There was a problem hiding this comment.
For AuthorizedAdminSetting we need the values, so i changed it there but then went for an independent approach, so that's why after that attempt some might diverge, but as mentioned above they are just 2 ifs so it doesn't really matter
Summary
Allowing the remaining annotations of the security middlewares as Attributes
TODO
Checklist