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] Fixed SwitchUserListener when exiting an impersonation with AnonymousToken#18425

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
fabpot merged 1 commit intosymfony:2.3fromlyrixx:patch-1
Apr 5, 2016

Conversation

@lyrixx
Copy link
Member

QA
Branch?2.3
Bug fix?yes
New feature?no
BC breaks?no
Deprecations?no
Tests pass?yes
Fixed tickets-
LicenseMIT
Doc PR-

If you configure a firewall with switch user withrole: IS_AUTHENTICATED_ANONYMOUSLY it's impossible to exit the
impersonation because the next line$this->provider->refreshUser($original->getUser()) will fail. It fails becauseRefreshUser
expects an instance ofUserInterface and here it's a string.

Therefore, it does not make sense to refresh an Anonymous Token, right ?

stloyd reacted with thumbs up emoji
}

if (null !==$this->dispatcher) {
if (null !==$this->dispatcher && !$originalinstanceof AnonymousToken) {
Copy link
Member

Choose a reason for hiding this comment

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

I think it would be better to check if$original->getUser is an instance of theUserInterface to also support custom tokens that might return something else.

Copy link
MemberAuthor

Choose a reason for hiding this comment

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

you are right. I updated the code and added some tests.

@nicolas-grekas
Copy link
Member

👍

$listener->handle($this->event);
}

publicfunctiontestExitUserDontDispatchesEventWithStringUser()
Copy link
Member

Choose a reason for hiding this comment

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

testExitUserDoesNotDispatchEventWithStringUser

Copy link
MemberAuthor

Choose a reason for hiding this comment

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

@xabbuh thanks & fixed.

@javiereguiluzjaviereguiluz changed the title[Security] Fixed SwitchUserListener when exiting an impersonication with AnonymousToken[Security] Fixed SwitchUserListener when exiting an impersonation with AnonymousTokenApr 4, 2016
@stof
Copy link
Member

stof commentedApr 4, 2016

@lyrixx are you really allowing anonymous users to impersonate users ? This looks weird.

But the fix is indeed valid

@lyrixx
Copy link
MemberAuthor

@stof Yes I do that. It's an awesome idea for demo app (you may see it on thursday).
With very few line of code, you can add simple login / logout feature for some hardcoded users.

security:    role_hierarchy:        ROLE_ADMIN: [ROLE_WRITTER, ROLE_SPELLCHECKER, ROLE_JOURNALIST]    encoders:        Symfony\Component\Security\Core\User\User: plaintext    providers:        in_memory:            memory:                users:                    alice: { password: password, roles: ROLE_WRITTER }                    spellchecker: { password: password , roles: ROLE_SPELLCHECKER }                    journalist: { password: password , roles: ROLE_JOURNALIST }                    admin: { password: password , roles: ROLE_ADMIN }    firewalls:        dev:            pattern: ^/(_(profiler|wdt)|css|images|js)/            security: false        main:            pattern: ^/            anonymous: true            logout: true            switch_user:                role: IS_AUTHENTICATED_ANONYMOUSLY

…ith AnonymousTokenIf you configure a firewall with switch user with `role: IS_AUTHENTICATED_ANONYMOUSLY` it's impossible to exit theimpersonation because the next line `$this->provider->refreshUser($original->getUser())` will fail. It fails because `RefreshUser`expects an instance of `UserInterface` and here it's a string.Therefore, it does not make sense to refresh an Anonymous Token, right ?
@fabpot
Copy link
Member

Thank you@lyrixx.

@fabpotfabpot merged commit59fea72 intosymfony:2.3Apr 5, 2016
fabpot added a commit that referenced this pull requestApr 5, 2016
…onation with AnonymousToken (lyrixx)This PR was merged into the 2.3 branch.Discussion----------[Security] Fixed SwitchUserListener when exiting an impersonation with AnonymousToken| Q             | A| ------------- | ---| Branch?       | 2.3| Bug fix?      | yes| New feature?  | no| BC breaks?    | no| Deprecations? | no| Tests pass?   | yes| Fixed tickets | -| License       | MIT| Doc PR        | -If you configure a firewall with switch user with `role: IS_AUTHENTICATED_ANONYMOUSLY` it's impossible to exit theimpersonation because the next line `$this->provider->refreshUser($original->getUser())` will fail. It fails because `RefreshUser`expects an instance of `UserInterface` and here it's a string.Therefore, it does not make sense to refresh an Anonymous Token, right ?Commits-------59fea72 [Security] Fixed SwitchUserListener when exiting an impersonication with AnonymousToken
@lyrixxlyrixx deleted the patch-1 branchApril 5, 2016 18:54
This was referencedApr 29, 2016
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

No reviews

Assignees

No one assigned

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

7 participants

@lyrixx@nicolas-grekas@stof@fabpot@xabbuh@javiereguiluz@carsonbot

[8]ページ先頭

©2009-2025 Movatter.jp