Skip to content

Navigation Menu

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

Appearance settings

SwitchUserToken incompatible with always_authenticate_before_granting #32756

Copy link
Copy link
Closed
@dsentker

Description

@dsentker
Issue body actions

Symfony version(s) affected: 4.3

Description
If a user is impersonating another user, the Symfony\Component\Security\Core\Authentication\Token\SwitchUserToken is created. But then, a Authentication Provider cannot be found for this token if the always_authenticate_before_granting configuration option is set to true. This is causing a redirect loop as printed in the logfile:

security.INFO: An AuthenticationException was thrown; redirecting to authentication entry point. [...] ProviderNotFoundException: No Authentication Provider found for token of class SwitchUserToken at [...]AuthenticationProviderManager.php:107)"

This exception is not thrown if always_authenticate_before_granting is removed from the security.yaml file.

How to reproduce

  1. Set always_authenticate_before_granting to true
  2. Impersonate a user
  3. Visit a URL that is behind a firewall

Possible Solution
I have no idea how to fix this. This issue #8974 is very similar to this one, but this is six years old.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.