Skip to content

[Security] Remove special case for #[IsGranted()] subject #48102

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

Merged

Conversation

HypeMC
Copy link
Member

@HypeMC HypeMC commented Nov 3, 2022

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:

-#[IsGranted(attribute: 'SOME_ATTRIBUTE', subject: 'request')]
+#[IsGranted(attribute: 'SOME_ATTRIBUTE', subject: new Expression('request'))]
public function index()
{
}

use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpKernel\Event\ControllerArgumentsEvent;
use Symfony\Component\HttpKernel\Exception\HttpException;
use Symfony\Component\HttpKernel\HttpKernelInterface;
use Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface;
use Symfony\Component\Security\Core\Authorization\ExpressionLanguage;
Copy link
Member Author

@HypeMC HypeMC Nov 3, 2022

Choose a reason for hiding this comment

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

This is a mistake I made in my original PR #46978

@chalasr
Copy link
Member

chalasr commented Nov 4, 2022

Thank you @HypeMC.

@chalasr chalasr merged commit 4d4c411 into symfony:6.2 Nov 4, 2022
@HypeMC HypeMC deleted the make-request-always-available-to-isgranted-2 branch November 4, 2022 12:17
fabpot added a commit to symfony/symfony-docs that referenced this pull request Mar 24, 2023
… (HypeMC)

This PR was merged into the 6.2 branch.

Discussion
----------

[Security] Use expression for `#[IsGranted()]` subject

symfony/symfony#46978
symfony/symfony#48080
symfony/symfony#48102

Commits
-------

9d4045f [Security] Use expression for #[IsGranted()] subject
weaverryan pushed a commit to symfony/symfony-docs that referenced this pull request Mar 28, 2023
… (HypeMC)

This PR was merged into the 6.2 branch.

Discussion
----------

[Security] Use expression for `#[IsGranted()]` subject

symfony/symfony#46978
symfony/symfony#48080
symfony/symfony#48102

Commits
-------

9d4045f [Security] Use expression for #[IsGranted()] subject
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.

4 participants