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

Allow to use custom authenticator by extending JWTAuthenticator #916

Merged
merged 1 commit into from
Sep 13, 2021

Conversation

fd6130
Copy link

@fd6130 fd6130 commented Sep 1, 2021

Fix #915

This PR will allow user to use their own custom authenticator that is extends from JWTAuthenticator.

Currently allow one authenticator per firewall only.

namespace App\Security;

use Lexik\Bundle\JWTAuthenticationBundle\Security\Authenticator\JWTAuthenticator;

class CustomAuthenticator extends JWTAuthenticator
{
    // Your own logic
}
# config/services.yaml
services:
    app.custom_authenticator:
        class: App\Security\CustomAuthenticator
        parent: lexik_jwt_authentication.security.jwt_authenticator
# config/packages/security.yaml
security:
    # ...
    firewalls:
        # ...
        api:
            pattern:   ^/api
            stateless: true
            jwt: 
                authenticator: app.custom_authenticator

@chalasr
Copy link
Collaborator

chalasr commented Sep 13, 2021

Thank you @fd6130.

@chalasr chalasr merged commit 591673a into lexik:2.x Sep 13, 2021
@fd6130 fd6130 deleted the custom_authenticator branch September 14, 2021 16:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Extending JWTTokenAuthenticator in symfony 5.3
2 participants