Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[FrameworkBundle] Fix denyAccessUnlessGranted for mixed attributes#49493

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
nicolas-grekas merged 1 commit intosymfony:5.4fromdelbertooo:fix-deny-access
Feb 23, 2023
Merged

[FrameworkBundle] Fix denyAccessUnlessGranted for mixed attributes#49493

nicolas-grekas merged 1 commit intosymfony:5.4fromdelbertooo:fix-deny-access
Feb 23, 2023

Conversation

@delbertooo
Copy link
Contributor

@delbertooodelbertooo commentedFeb 22, 2023
edited by nicolas-grekas
Loading

QA
Branch?5.4
Bug fix?yes
New feature?no
Deprecations?no
Tickets-
LicenseMIT
Doc PR-

Checking authorization against anything that isn'tarray|string will cause PHP errors now. The methodAbstractController::denyAccessUnlessGranted() sets the givensingle attribute into the exception in case of denied access. TheAuthorizationCheckerInterface defines that the attribute can be anything, even objects. The parameter type hintarray|string ofAccessDeniedException::setAttributes() want's an array of attributes (or a string for convenience).

Example

useSymfony\Bundle\FrameworkBundle\Controller\AbstractController;class MyCustomAttribute{}class ProfileControllerextends AbstractController{publicfunctionindex():Response    {$this->denyAccessUnlessGranted(newMyCustomAttribute());// 💥 ERROR: Symfony\Component\Security\Core\Exception\AccessDeniedException::setAttributes(): Argument #1 ($attributes) must be of type array|string, [...]$user =$this->getUser();returnnewResponse('Well hi there'.$user->getFirstName());    }}

The fix

As the given attribute is asingle attribute: always wrap it into an array when creating the exception, because the exception expects an array of attributes.

@carsonbot
Copy link

Hey!

I see that this is your first PR. That is great! Welcome!

Symfony has acontribution guide which I suggest you to read.

In short:

  • Always add tests
  • Keep backward compatibility (seehttps://symfony.com/bc).
  • Bug fixes must be submitted against the lowest maintained branch where they apply (seehttps://symfony.com/releases)
  • Features and deprecations must be submitted against the 6.3 branch.

Review the GitHub status checks of your pull request and try to solve the reported issues. If some tests are failing, try to see if they are failing because of this change.

When two Symfony core team members approve this change, it will be merged and you will become an official Symfony contributor!
If this PR is merged in a lower version branch, it will be merged up to all maintained branches within a few days.

I am going to sit back now and wait for the reviews.

Cheers!

Carsonbot

@delbertooo
Copy link
ContributorAuthor

Can someone re-run the checks or something? I don't think this issue is caused by my code:

There was 1 failure:1) Symfony\Component\Clock\Tests\MonotonicClockTest::testSleepFailed asserting that 1677065608.00641 is equal to 1677065608.0064101 or is greater than 1677065608.0064101.

@nicolas-grekasnicolas-grekas modified the milestones:6.2,5.4Feb 23, 2023
Fix AbstractController::denyAccessUnlessGranted() for attributes that aren't string or array. Always wrap the given single attribute into an array to not break the parameter type of AccessDeniedException#setAttributes() (which supports strings only for convenience).
Copy link
Member

@nicolas-grekasnicolas-grekas left a comment

Choose a reason for hiding this comment

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

(I fixed my review comments)

@nicolas-grekas
Copy link
Member

Thank you@delbertooo.

@nicolas-grekasnicolas-grekas merged commit111af45 intosymfony:5.4Feb 23, 2023
This was referencedFeb 28, 2023
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@nicolas-grekasnicolas-grekasnicolas-grekas approved these changes

@lyrixxlyrixxAwaiting requested review from lyrixx

@ycerutoycerutoAwaiting requested review from yceruto

@wouterjwouterjAwaiting requested review from wouterj

@chalasrchalasrAwaiting requested review from chalasr

@dunglasdunglasAwaiting requested review from dunglas

@OskarStarkOskarStarkAwaiting requested review from OskarStark

@xabbuhxabbuhAwaiting requested review from xabbuh

Assignees

No one assigned

Projects

None yet

Milestone

5.4

Development

Successfully merging this pull request may close these issues.

3 participants

@delbertooo@carsonbot@nicolas-grekas

[8]ページ先頭

©2009-2025 Movatter.jp