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

[Security] Allow disabling redirect on logout#46320

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

Open
jvasseur wants to merge1 commit intosymfony:7.4
base:7.4
Choose a base branch
Loading
fromjvasseur:allow-disabling-logout-redirect

Conversation

jvasseur
Copy link
Contributor

@jvasseurjvasseur commentedMay 11, 2022
edited by OskarStark
Loading

QA
Branch?7.3
Bug fix?no
New featureyes
Deprecationsno
LicenseMIT
Doc PR

When using JSON authentication, customizing the success response can be done easily in the corresponding controller, but customizing the logout success is more tiresome and requires to create a listener for it (while still requiring to create a route for it to work).

This PR propose to add the possibility to disable the redirect on successful logout and let the request fallback to the defined route in this case.

This allow customizing both login and logout response in the same place like this:

security:firewalls:main:json_login:check_path:auth_loginlogout:path:auth_logouttarget:~
class AuthControllerextends AbstractController{    #[Route("/login", name:"auth_login")]publicfunctionlogin():Response    {return$this->json($this->getUser());    }    #[Route("/logout", name:"auth_logout")]publicfunctionlogout():Response    {return$this->json(null);    }}

It means I had to remove the Exception in case no logout listener set a response but I don't think it should be considered a BC break since it's an error case that is removed and the corresponding exception was just the baseRuntimeException and thus wasn't specifically catchable.

The only downside is that other logout listeners can't modify the response anymore because it doesn't exists in the event but since this is an opt-in feature I don't think it's a problem.

@carsonbotcarsonbot added this to the6.1 milestoneMay 11, 2022
@jvasseurjvasseurforce-pushed theallow-disabling-logout-redirect branch from1bbe1d9 to799d8aeCompareMay 11, 2022 12:22
@jvasseurjvasseur changed the title[Security] Allow disabling redirect on login[Security] Allow disabling redirect on logoutMay 11, 2022
@jvasseurjvasseurforce-pushed theallow-disabling-logout-redirect branch from799d8ae to9a52fd4CompareMay 11, 2022 12:23
@carsonbot
Copy link

Hey!

I think@scheb has recently worked with this code. Maybe they can help review this?

Cheers!

Carsonbot

@wouterjwouterj modified the milestones:6.1,6.2May 12, 2022
@jvasseurjvasseurforce-pushed theallow-disabling-logout-redirect branch from9a52fd4 to4077513CompareJuly 6, 2022 10:35
@nicolas-grekasnicolas-grekas modified the milestones:6.2,6.3Nov 5, 2022
@nicolas-grekasnicolas-grekas modified the milestones:6.3,6.4May 23, 2023
@nicolas-grekasnicolas-grekas modified the milestones:6.4,7.1Nov 15, 2023
@xabbuhxabbuh modified the milestones:7.1,7.2May 15, 2024
@fabpotfabpot modified the milestones:7.2,7.3Nov 20, 2024
Copy link
Contributor

@SpomkySpomky left a comment

Choose a reason for hiding this comment

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

Hi@jvasseur,

Thank you for the proposed changes. This looks good to me.
Just a few changes rebase and we are good to go.

@@ -8,6 +8,7 @@ CHANGELOG
* Deprecate the `Symfony\Component\Security\Core\Security` service alias, use `Symfony\Bundle\SecurityBundle\Security\Security` instead
* Add `Security::getFirewallConfig()` to help to get the firewall configuration associated to the Request
* Add `Security::login()` to login programmatically
* Allow disabling the redirection on successful logout by passing `null` to the `target` option
Copy link
Contributor

Choose a reason for hiding this comment

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

Should move to 7.3

@chalasr
Copy link
Member

👍 from me also, once rebased and retargeted.

@fabpotfabpot modified the milestones:7.3,7.4May 26, 2025
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@SpomkySpomkySpomky requested changes

@wouterjwouterjAwaiting requested review from wouterj

@chalasrchalasrAwaiting requested review from chalasrchalasr is a code owner

Assignees
No one assigned
Projects
None yet
Milestone
7.4
Development

Successfully merging this pull request may close these issues.

8 participants
@jvasseur@carsonbot@chalasr@Spomky@fabpot@nicolas-grekas@wouterj@xabbuh

[8]ページ先頭

©2009-2025 Movatter.jp