8000 [Security] Initialize SwitchUserEvent::targetUser on attemptExitUser by rvanlaak · Pull Request #14931 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

[Security] Initialize SwitchUserEvent::targetUser on attemptExitUser #14931

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
wants to merge 1 commit into from

Conversation

rvanlaak
Copy link
Contributor

The SwitchUserEvent is triggered in case an account is switched. This works okay while switching to the user, but on exit the SwitchUserEvent is triggered again with the original User. That User was not initialized by the provider yet.

Q A
Bug fix? yes
New feature? no
BC breaks? no
Deprecations? no
Tests pass? yes
Fixed tickets
License MIT
Doc PR

@@ -162,7 +162,8 @@ private function attemptExitUser(Request $request)
}

if (null !== $this->dispatcher) {
$switchEvent = new SwitchUserEvent($request, $original->getUser());
$user = $this->provider->loadUserByUsername($original->getUser()->getUserName());
Copy link
Member

Choose a reason for hiding this comment

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

you should use the refreshUser method of the user provider instead.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

FIXED and rebased

The `SwitchUserEvent` is triggered in case an account is switched. This works okay while switching to the user, but on exit the `SwitchUserEvent` is triggered again with the original User. That User was not initialized by the provider yet.

load user by UserInterface instead of username
@rvanlaak
Copy link
Contributor Author

ping @stof do you think this can be merged to 2.3 and up?

@fabpot
Copy link
Member
fabpot commented Jun 16, 2015

Looks like a bug fix, so 2.3.

@xabbuh
Copy link
Member
xabbuh commented Jun 26, 2015

@rvanlaak Looks good, but can you add a test to avoid future regressions?

@rvanlaak
Copy link
Contributor Author

Yes I agree, but how can we see or the User is initialized? The UserInterface variables are actually already there.

@xabbuh
Copy link
Member
xabbuh commented Jun 28, 2015

You could check which user instance is passed to refreshUser() and which one is passed to the SwitchUserEvent.

@rvanlaak
Copy link
Contributor Author

But they are both an instance of UserInterface right? Can't test the userland implementation, so what exactly could I be able to check on?

@xabbuh
Copy link
Member
xabbuh commented Jun 28, 2015

@rvanlaak I opened a new PR request based on the 2.3 branch and added a test for your change (I kept your commit so you will still get the credits). Sorry that I failed to explain how I imagined to test the changes.

@xabbuh
Copy link
Member
xabbuh commented Jun 28, 2015

closing in favor of #15137

@xabbuh xabbuh closed this Jun 28, 2015
@rvanlaak
Copy link
Contributor Author

👍 @xabbuh

fabpot added a commit that referenced this pull request Jun 30, 2015
…ptExitUser (Rvanlaak, xabbuh)

This PR was merged into the 2.3 branch.

Discussion
----------

[Security] Initialize SwitchUserEvent::targetUser on attemptExitUser

| Q             | A
| ------------- | ---
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | #14931
| License       | MIT
| Doc PR        |

Commits
-------

f999217 trigger event with right user (add test)
01ee3f6 [Security] Initialize SwitchUserEvent::targetUser on attemptExitUser
@rvanlaak rvanlaak deleted the patch-3 branch March 23, 2016 19:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants
0