Quantcast
Channel: Active questions tagged symfony4 - Stack Overflow
Viewing all articles
Browse latest Browse all 3925

Validating username password with LexikJWTAuthenticationBundle before authentication

$
0
0

I want to perform traditional validation of username( character count and valid email) and password (character count) before authentication is performed.

The users are in database and I don't want to hit the database before this validation gives a go.

I have LexikJWTAuthenticationBundle set up with Symfony 4.1 and it is working. There is no controller as the authentication is completely being handled by the bundle.

I am not sure how can I perform above mentioned validation. Please help.

Find below my security config to get some idea what I already have set up.

security:    role_hierarchy:        ROLE_ADMIN:       ROLE_USER        ROLE_SUPER_ADMIN: [ ROLE_USER, ROLE_ADMIN, ROLE_ALLOWED_TO_SWITCH ]    encoders:        App\Entity\User:            id: app.bcrypt_plus_encoder    providers:        db_user_provider:            entity:                class: App\Entity\User                # the property to query by - e.g. username, email, etc                property: email                # if you're using multiple entity managers                # manager_name: customer    firewalls:        guest:            pattern: ^/api/guest            stateless: true            anonymous: true        login:            pattern:  ^/api/login            user_checker: App\Security\UserChecker            stateless: true            anonymous: true            provider: db_user_provider            json_login:                check_path: /api/login_check                success_handler: lexik_jwt_authentication.handler.authentication_success                failure_handler: App\Security\Http\Authentication\AuthenticationFailureHandler                require_previous_session: false                username_path: email                password_path: passw        api:            pattern:   ^/api            stateless: true            guard:                provider: db_user_provider                authenticators:                    - lexik_jwt_authentication.jwt_token_authenticator    access_control:        - { path: ^/api/guest, roles: IS_AUTHENTICATED_ANONYMOUSLY }        - { path: ^/api/login, roles: IS_AUTHENTICATED_ANONYMOUSLY }        - { path: ^/api,       roles: IS_AUTHENTICATED_FULLY }

Viewing all articles
Browse latest Browse all 3925

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>