Skip to content
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

[security] Provide authentification token when using an user checker #50650

Open
fabienlem opened this issue Jun 13, 2023 · 5 comments
Open

[security] Provide authentification token when using an user checker #50650

fabienlem opened this issue Jun 13, 2023 · 5 comments

Comments

@fabienlem
Copy link

fabienlem commented Jun 13, 2023

Description

Hi there,

When using a custom user checker, ie:

security:
    firewalls:
        api:
            user_checker: 'App\Security\UserChecker'

I would like to be able to get the authentication token. My use case is as follows: I want to make checks less stringent when an impersonation is in progress.

Injecting the Security service does not provide a solution.

use Symfony\Bundle\SecurityBundle\Security;

    public function checkPostAuth(UserInterface $user): void
    {
        $this->security->getToken(); // null
    }

I saw that in Symfony\Component\Security\Http\EventListener\UserCheckerListener the token could be provided as second parameter to the checkPostAuth method. So it could be posible to achieve some things like knowing if an impersonation is in progress.

What do you think about this proposal?

Kind regards,

Fabien

Example

No response

@mdeboer
Copy link
Contributor

mdeboer commented Jun 18, 2023

I very much like this idea. Found it odd why it isn't provided in postAuth really.

@dmiedev
Copy link

dmiedev commented Jul 1, 2023

So there is not a single way how to obtain the token?

@dmiedev
Copy link

dmiedev commented Jul 1, 2023

Welp, this is troublesome :/
One could probably use $this->requestStack->getCurrentRequest()->headers->get('authorization') as a temporary (and somewhat ugly) workaround

@carsonbot
Copy link

Thank you for this suggestion.
There has not been a lot of activity here for a while. Would you still like to see this feature?

@dmiedev
Copy link

dmiedev commented Jan 2, 2024

Yes

@carsonbot carsonbot removed the Stalled label Jan 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants