You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
minor #48102 [Security] Remove special case for #[IsGranted()] subject (HypeMC)
This PR was merged into the 6.2 branch.
Discussion
----------
[Security] Remove special case for `#[IsGranted()]` subject
| Q | A
| ------------- | ---
| Branch? | 6.2
| Bug fix? | no
| New feature? | no
| Deprecations? | no
| Tickets | Fix#48080 (comment)
| License | MIT
| Doc PR | -
Addresses a comment by `@stof`
Instead of having `request` as a special case, an expression can be used instead:
```diff
-#[IsGranted(attribute: 'SOME_ATTRIBUTE', subject: 'request')]
+#[IsGranted(attribute: 'SOME_ATTRIBUTE', subject: new Expression('request'))]
public function index()
{
}
```
Commits
-------
3e0ac4f [Security] Remove special case for #[IsGranted()] subject
Copy file name to clipboardExpand all lines: src/Symfony/Component/Security/Http/EventListener/IsGrantedAttributeListener.php
-3Lines changed: 0 additions & 3 deletions
Original file line number
Diff line number
Diff line change
@@ -92,9 +92,6 @@ private function getIsGrantedSubject(string|Expression $subjectRef, Request $req
92
92
}
93
93
94
94
if (!\array_key_exists($subjectRef, $arguments)) {
95
-
if ('request' === $subjectRef) {
96
-
return$request;
97
-
}
98
95
thrownewRuntimeException(sprintf('Could not find the subject "%s" for the #[IsGranted] attribute. Try adding a "$%s" argument to your controller method.', $subjectRef, $subjectRef));
0 commit comments