Skip to content

[Security] Add statusCode and message arguments to #[IsGranted] #18103

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

Closed

Conversation

alexandre-daubois
Copy link
Member

Following #18101 (comment)

@WebMamba
Copy link
Contributor

Great thanks @alexandre-daubois! I was searching for it after looking at your last PR!

@MrYamous
Copy link
Contributor

I am also tempted to explicitly specify the default status code, and maybe document message argument (or I can do another PR for that) WDYT ?

@alexandre-daubois
Copy link
Member Author

Updated! What do you think?

@alexandre-daubois alexandre-daubois changed the title [Security] Add argument statusCode to #[IsGranted] [Security] Add statusCode and message arguments to #[IsGranted] Mar 20, 2023
security.rst Outdated

use Symfony\Component\Security\Http\Attribute\IsGranted;

#[IsGranted('ROLE_ADMIN', statusCode: 403)]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we can keep a custom statusCode here and specify in text above 403 is default value, seems confusing to me to explicitly define default value here

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're right, updated!

@OskarStark OskarStark changed the title [Security] Add statusCode and message arguments to #[IsGranted] [Security] Add statusCode and message arguments to #[IsGranted] Mar 21, 2023
security.rst Outdated
class AdminController extends AbstractController
{
// ...
}

The default code is 403.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
The default code is 403.

already mentioned in the sentence above. Afterwards good to merge 👍

@OskarStark
Copy link
Contributor

Thank you @alexandre-daubois.

@OskarStark OskarStark closed this Mar 21, 2023
@OskarStark OskarStark force-pushed the isgranted-status-code branch from 17ceb21 to 149d33b Compare March 21, 2023 08:15
OskarStark added a commit that referenced this pull request Mar 21, 2023
…#[IsGranted]` (alexandre-daubois)

This PR was squashed before being merged into the 6.2 branch.

Discussion
----------

[Security] Add `statusCode` and `message` arguments to `#[IsGranted]`

Following #18101 (comment)

Commits
-------

149d33b [Security] Add `statusCode` and `message` arguments to `#[IsGranted]`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants