scheb / 2fa

Two-factor authentication for Symfony applications 🔐
MIT License
504 stars 75 forks source link

After login it is not redirecting me to the 2fa route #221

Closed venkateshlb closed 7 months ago

venkateshlb commented 8 months ago

Bundle version: 5.x Symfony version: 5.4 PHP version: 8.1

I already have a user login form with the auth process. I have set up the package as per the documentation but after login, it is not redirecting me to the 2fa route.

I am using scheb 2fa. I already have a user login form with the auth process. I have setup the package as per the documentation but after login, it is not redirecting me to the 2fa route.

security:
    enable_authenticator_manager: true

    password_hashers:
        legacy:
            algorithm: sha256
            encode_as_base64: false
            iterations: 1

        UserBundle\Entity\User:
            # the new hasher, along with its options
            algorithm: bcrypt
            migrate_from:
                - bcrypt # uses the "bcrypt" hasher with the default options
                - legacy # uses the "legacy" hasher configured above

        Symfony\Component\Security\Core\User\PasswordAuthenticatedUserInterface:
                algorithm: 'auto'
                cost:      15

    providers:
        db_provider:
            entity:
                class: UserBundle:User
                property: email

        api_provider:
            entity:
                class: UserBundle:User
                property: privateToken

        in_memory:
            memory: ~

    firewalls:
        dev:
            pattern: ^/(_(profiler|wdt)|css|images|js)/
            security: false
        api:
            pattern: ^/api/
            stateless: true
            custom_authenticator: user.apikey_authenticator
            provider: api_provider
            entry_point: UserBundle\Security\AuthenticationEntryPoint
        main:
            lazy: true
            pattern: ^/
            http_basic: ~
            provider: db_provider
            # user_checker: UserBundle\Security\UserChecker
            entry_point: form_login
            form_login:
                check_path: /login_check
                login_path: /login
                username_parameter: _email
                enable_csrf: true
            logout:
                path: /logout
                target: /login
            two-factor:
                auth_form_path: 2fa_login
                check_path: 2fa_login_check

    role_hierarchy:
        ROLE_SUPER_ADMIN: ROLE_USER

    access_control:
        - { path: ^/org/[^/], roles: PUBLIC_ACCESS }
        - { path: ^/cookie/[^/], roles: PUBLIC_ACCESS }
        - { path: ^/session/[^/], roles: PUBLIC_ACCESS }
        - { path: ^/2fa, role: PUBLIC_ACCESS }
        - { path: ^/user/[^/]+/register/[^/], roles: PUBLIC_ACCESS }
        - { path: ^/user/[^/]+/reset-password/[^/], roles: PUBLIC_ACCESS }
        - { path: ^/keep-alive, roles: PUBLIC_ACCESS }
        - { path: ^/login, roles: PUBLIC_ACCESS }
        - { path: ^/user, roles: ROLE_USER }
scheb commented 8 months ago

Follow the troubleshooting guide: https://symfony.com/bundles/SchebTwoFactorBundle/6.x/troubleshooting.html#two-factor-authentication-form-is-not-shown-after-login

And please update your software. Bundle version 5 is already end-of-life.

stale[bot] commented 7 months ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.