CARVIEW |
Select Language
HTTP/2 200
date: Sun, 12 Oct 2025 22:18:06 GMT
content-type: text/html; charset=utf-8
vary: X-PJAX, X-PJAX-Container, Turbo-Visit, Turbo-Frame, X-Requested-With,Accept-Encoding, Accept, X-Requested-With
x-repository-download: git clone https://github.com/symfony/symfony.git
etag: W/"4221e6ced80824aefa9b324cd959e3a4"
cache-control: max-age=0, private, must-revalidate
strict-transport-security: max-age=31536000; includeSubdomains; preload
x-frame-options: deny
x-content-type-options: nosniff
x-xss-protection: 0
referrer-policy: no-referrer-when-downgrade
content-security-policy: default-src 'none'; base-uri 'self'; child-src github.githubassets.com github.com/assets-cdn/worker/ github.com/assets/ gist.github.com/assets-cdn/worker/; connect-src 'self' uploads.github.com www.githubstatus.com collector.github.com raw.githubusercontent.com api.github.com github-cloud.s3.amazonaws.com github-production-repository-file-5c1aeb.s3.amazonaws.com github-production-upload-manifest-file-7fdce7.s3.amazonaws.com github-production-user-asset-6210df.s3.amazonaws.com *.rel.tunnels.api.visualstudio.com wss://*.rel.tunnels.api.visualstudio.com github.githubassets.com objects-origin.githubusercontent.com copilot-proxy.githubusercontent.com proxy.individual.githubcopilot.com proxy.business.githubcopilot.com proxy.enterprise.githubcopilot.com *.actions.githubusercontent.com wss://*.actions.githubusercontent.com productionresultssa0.blob.core.windows.net/ productionresultssa1.blob.core.windows.net/ productionresultssa2.blob.core.windows.net/ productionresultssa3.blob.core.windows.net/ productionresultssa4.blob.core.windows.net/ productionresultssa5.blob.core.windows.net/ productionresultssa6.blob.core.windows.net/ productionresultssa7.blob.core.windows.net/ productionresultssa8.blob.core.windows.net/ productionresultssa9.blob.core.windows.net/ productionresultssa10.blob.core.windows.net/ productionresultssa11.blob.core.windows.net/ productionresultssa12.blob.core.windows.net/ productionresultssa13.blob.core.windows.net/ productionresultssa14.blob.core.windows.net/ productionresultssa15.blob.core.windows.net/ productionresultssa16.blob.core.windows.net/ productionresultssa17.blob.core.windows.net/ productionresultssa18.blob.core.windows.net/ productionresultssa19.blob.core.windows.net/ github-production-repository-image-32fea6.s3.amazonaws.com github-production-release-asset-2e65be.s3.amazonaws.com insights.github.com wss://alive.github.com wss://alive-staging.github.com api.githubcopilot.com api.individual.githubcopilot.com api.business.githubcopilot.com api.enterprise.githubcopilot.com; font-src github.githubassets.com; form-action 'self' github.com gist.github.com copilot-workspace.githubnext.com objects-origin.githubusercontent.com; frame-ancestors 'none'; frame-src viewscreen.githubusercontent.com notebooks.githubusercontent.com; img-src 'self' data: blob: github.githubassets.com media.githubusercontent.com camo.githubusercontent.com identicons.github.com avatars.githubusercontent.com private-avatars.githubusercontent.com github-cloud.s3.amazonaws.com objects.githubusercontent.com release-assets.githubusercontent.com secured-user-images.githubusercontent.com/ user-images.githubusercontent.com/ private-user-images.githubusercontent.com opengraph.githubassets.com marketplace-screenshots.githubusercontent.com/ copilotprodattachments.blob.core.windows.net/github-production-copilot-attachments/ github-production-user-asset-6210df.s3.amazonaws.com customer-stories-feed.github.com spotlights-feed.github.com objects-origin.githubusercontent.com *.githubusercontent.com; manifest-src 'self'; media-src github.com user-images.githubusercontent.com/ secured-user-images.githubusercontent.com/ private-user-images.githubusercontent.com github-production-user-asset-6210df.s3.amazonaws.com gist.github.com; script-src github.githubassets.com; style-src 'unsafe-inline' github.githubassets.com; upgrade-insecure-requests; worker-src github.githubassets.com github.com/assets-cdn/worker/ github.com/assets/ gist.github.com/assets-cdn/worker/
server: github.com
content-encoding: gzip
accept-ranges: bytes
set-cookie: _gh_sess=mQSesdKco7fWbqOwPOkoRNJ47N5ezAECjLkpq6DE1MR3KVXsfQcX9CNWvG1Od6%2FKbEYfnIc4nxa%2ByGAFvVSOnXyIJkZsIGS3c95ptgSKF45iEJgk%2FhKyTMyeKnpnR3raR0trN9kjgcuywKbELxm82UtxTwP9XlH4w6ZAsBy%2Fk%2BG1ENHbuVSGArfWy%2B0SWanjdrJmcybc6Cse5wXd7JIyLG1qnxtvH2qoESIKZshi1sbZ6JYTv1%2B53f5bm88FPRaG7zEDTFwFR2gqsN1CriPeFA%3D%3D--RUvkV704N5PXb6Rb--PErbRQdISBei5ivXcnAU1A%3D%3D; Path=/; HttpOnly; Secure; SameSite=Lax
set-cookie: _octo=GH1.1.881814426.1760307485; Path=/; Domain=github.com; Expires=Mon, 12 Oct 2026 22:18:05 GMT; Secure; SameSite=Lax
set-cookie: logged_in=no; Path=/; Domain=github.com; Expires=Mon, 12 Oct 2026 22:18:05 GMT; HttpOnly; Secure; SameSite=Lax
x-github-request-id: DA38:1D4E10:131ABF1:195CC0A:68EC291D
feature #61359 [Security] Add `$methods` support to `#[IsGranted]` to… · symfony/symfony@0d47620 · GitHub
Copy file name to clipboardExpand all lines: src/Symfony/Component/Security/Http/Attribute/IsGranted.php
Copy file name to clipboardExpand all lines: src/Symfony/Component/Security/Http/CHANGELOG.md
Copy file name to clipboardExpand all lines: src/Symfony/Component/Security/Http/EventListener/IsGrantedAttributeListener.php
Copy file name to clipboardExpand all lines: src/Symfony/Component/Security/Http/Tests/EventListener/IsGrantedAttributeListenerTest.php
Copy file name to clipboardExpand all lines: src/Symfony/Component/Security/Http/Tests/Fixtures/IsGrantedAttributeMethodsController.php
Skip to content
Navigation Menu
{{ message }}
-
-
Notifications
You must be signed in to change notification settings - Fork 9.7k
Commit 0d47620
committed
feature #61359 [Security] Add
This PR was merged into the 7.4 branch.
Discussion
----------
[Security] Add `$methods` support to `#[IsGranted]` to restrict access by HTTP method
| Q | A
| ------------- | ---
| Branch? | 7.4
| Bug fix? | no
| New feature? | yes
| Deprecations? | no
| Issues | no
| License | MIT
### Description
This PR adds support for restricting `#[IsGranted]` validation to specific HTTP methods via a new `$methods` argument.
### What's New
You can now define access control per HTTP method directly in the `#[IsGranted]` attribute. This allows greater flexibility when securing controller actions that handle multiple HTTP verbs.
```php
#[IsGranted('ROLE_ADMIN', methods: ['GET', 'POST'])]
public function someAction() {}
#[IsGranted('ROLE_ADMIN', methods: 'POST')]
public function otherAction() {}
```
* If the current request method does not match, the attribute is ignored.
* If the method matches, the usual access check logic runs as expected.
This change aligns `#[IsGranted]` more closely with other HTTP-aware attributes like:
* `#[IsCsrfTokenValid]`
* `#[IsSignatureValid]` (currently under review)
Commits
-------
68f0fca [Security] Add `$methods` support to `#[IsGranted]` to restrict access by HTTP method$methods
support to #[IsGranted]
to restrict access by HTTP method (santysisi)File tree
Expand file treeCollapse file tree
5 files changed
+96
-5
lines changedFilter options
- src/Symfony/Component/Security/Http
- Attribute
- EventListener
- Tests
- EventListener
- Fixtures
Expand file treeCollapse file tree
5 files changed
+96
-5
lines changedCollapse file: src/Symfony/Component/Security/Http/Attribute/IsGranted.php
src/Symfony/Component/Security/Http/Attribute/IsGranted.php
Copy file name to clipboardExpand all lines: src/Symfony/Component/Security/Http/Attribute/IsGranted.php+11-5Lines changed: 11 additions & 5 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
24 | 24 |
| |
25 | 25 |
| |
26 | 26 |
| |
| 27 | + | |
| 28 | + | |
| 29 | + | |
27 | 30 |
| |
28 |
| - | |
29 |
| - | |
30 |
| - | |
31 |
| - | |
32 |
| - | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
33 | 37 |
| |
34 | 38 |
| |
35 | 39 |
| |
36 | 40 |
| |
37 | 41 |
| |
38 | 42 |
| |
39 | 43 |
| |
| 44 | + | |
40 | 45 |
| |
| 46 | + | |
41 | 47 |
| |
42 | 48 |
|
Collapse file: src/Symfony/Component/Security/Http/CHANGELOG.md
src/Symfony/Component/Security/Http/CHANGELOG.md
Copy file name to clipboardExpand all lines: src/Symfony/Component/Security/Http/CHANGELOG.md+1Lines changed: 1 addition & 0 deletions
- Display the source diff
- Display the rich diff
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
7 | 7 |
| |
8 | 8 |
| |
9 | 9 |
| |
| 10 | + | |
10 | 11 |
| |
11 | 12 |
| |
12 | 13 |
| |
|
Collapse file: src/Symfony/Component/Security/Http/EventListener/IsGrantedAttributeListener.php
src/Symfony/Component/Security/Http/EventListener/IsGrantedAttributeListener.php
Copy file name to clipboardExpand all lines: src/Symfony/Component/Security/Http/EventListener/IsGrantedAttributeListener.php+4Lines changed: 4 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
47 | 47 |
| |
48 | 48 |
| |
49 | 49 |
| |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
50 | 54 |
| |
51 | 55 |
| |
52 | 56 |
| |
|
Collapse file: src/Symfony/Component/Security/Http/Tests/EventListener/IsGrantedAttributeListenerTest.php
src/Symfony/Component/Security/Http/Tests/EventListener/IsGrantedAttributeListenerTest.php
Copy file name to clipboardExpand all lines: src/Symfony/Component/Security/Http/Tests/EventListener/IsGrantedAttributeListenerTest.php+70Lines changed: 70 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
454 | 454 |
| |
455 | 455 |
| |
456 | 456 |
| |
| 457 | + | |
| 458 | + | |
| 459 | + | |
| 460 | + | |
| 461 | + | |
| 462 | + | |
| 463 | + | |
| 464 | + | |
| 465 | + | |
| 466 | + | |
| 467 | + | |
| 468 | + | |
| 469 | + | |
| 470 | + | |
| 471 | + | |
| 472 | + | |
| 473 | + | |
| 474 | + | |
| 475 | + | |
| 476 | + | |
| 477 | + | |
| 478 | + | |
| 479 | + | |
| 480 | + | |
| 481 | + | |
| 482 | + | |
| 483 | + | |
| 484 | + | |
| 485 | + | |
| 486 | + | |
| 487 | + | |
| 488 | + | |
| 489 | + | |
| 490 | + | |
| 491 | + | |
| 492 | + | |
| 493 | + | |
| 494 | + | |
| 495 | + | |
| 496 | + | |
| 497 | + | |
| 498 | + | |
| 499 | + | |
| 500 | + | |
| 501 | + | |
| 502 | + | |
| 503 | + | |
| 504 | + | |
| 505 | + | |
| 506 | + | |
| 507 | + | |
| 508 | + | |
| 509 | + | |
| 510 | + | |
| 511 | + | |
| 512 | + | |
| 513 | + | |
| 514 | + | |
| 515 | + | |
| 516 | + | |
| 517 | + | |
| 518 | + | |
| 519 | + | |
| 520 | + | |
| 521 | + | |
| 522 | + | |
| 523 | + | |
| 524 | + | |
| 525 | + | |
| 526 | + | |
457 | 527 |
|
Collapse file: src/Symfony/Component/Security/Http/Tests/Fixtures/IsGrantedAttributeMethodsController.php
src/Symfony/Component/Security/Http/Tests/Fixtures/IsGrantedAttributeMethodsController.php
Copy file name to clipboardExpand all lines: src/Symfony/Component/Security/Http/Tests/Fixtures/IsGrantedAttributeMethodsController.php+10Lines changed: 10 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
77 | 77 |
| |
78 | 78 |
| |
79 | 79 |
| |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
80 | 90 |
|
You can’t perform that action at this time.
0 commit comments