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

Cant get the 2fa to work #32

Closed
christianostrem opened this issue Nov 8, 2020 · 5 comments
Closed

Cant get the 2fa to work #32

christianostrem opened this issue Nov 8, 2020 · 5 comments

Comments

@christianostrem
Copy link

Bundle version: 5.1
Symfony version: 5.1

Description

Hi, I cant get the 2fa to work.
It dosent trigger at all.

I have a login form on my /login page
That postes to /login and the guard will handle the rest and redirect to admin section.
I am not sure on how is it suppose to work either.

Is it suppose to take over when i poste my credentials to the login page?
Do i need to create a new login form and post it to another page?

I am kinda blank here so any help would be great.

Security.yaml

security:
    providers:
        security:
            id: App\Service\UserProviderService
    encoders:
        App\Security\User: plaintext
    firewalls:
        dev:
            pattern: ^/(_(profiler|wdt)|css|images|js)/
            security: false
        main:
            anonymous: ~
            remember_me:
                secret:   '%kernel.secret%'
                lifetime: 604800 # 1 week in seconds
                path:     /
            logout:
                path: /logout
                success_handler: App\Handler\LogoutSuccessHandler
            two_factor:
                auth_form_path: /2fa_login    # The route name you have used in the routes.yaml
                check_path: /2fa_login_check  # The route name you have used in the routes.yaml
            guard:
                authenticators:
                    - App\Service\AuthenticationService
                entry_point: App\Service\AuthenticationService
    access_control:
        - { path: ^/logout, role: IS_AUTHENTICATED_ANONYMOUSLY }
        - { path: ^/2fa_login, role: IS_AUTHENTICATED_ANONYMOUSLY } 
        - { path: ^/admin, roles: [ROLE_ADMINISTRATOR] }

scheb_two_factor.yaml

scheb_two_factor:
    backup_codes:
        enabled: false                 # If the backup code feature should be enabled
    google:
        enabled: true                  # If Google Authenticator should be enabled, default false
        server_name: pagedomain.com       # Server name used in QR code
        issuer: pagedomain            # Issuer name used in QR code
        digits: 6                      # Number of digits in authentication code
        window: 1                      # How many codes before/after the current one would be accepted as valid
        template: "security/2fa_form.html.twig"   # Template used to render the authentication form
    security_tokens:
        - Symfony\Component\Security\Guard\Token\PostAuthenticationGuardToken
        - Symfony\Component\Security\Core\Authentication\Token\UsernamePasswordToken

Routing

2fa_login:
    path: /2fa_login
    defaults:
        _controller: "scheb_two_factor.form_controller:form"
2fa_login_check:
    path: /2fa_login_check
controllers:
    resource: '../src/Controller/'
    type:     annotation
    prefix:   /
dynamic_route:
    path: /{url}
    controller: App\Controller\DynamicRouteController::indexAction
    requirements:
        url: ".+"
login:
    path: /login
    controller: App\Controller\DynamicRouteController::indexAction

Additional Context

@scheb
Copy link
Owner

scheb commented Nov 8, 2020

After login, 2fa should redirect you to the 2fa authentication form, asking for the 2fa code.

Please follow the toubleshooting guide, "Two-factor authentication form is not shown after login" is your case.

@christianostrem
Copy link
Author

Thanx, I will check the troubleshooting guide. A bit easier now when I know whats going to happen next.

@stale
Copy link

stale bot commented Nov 30, 2020

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.

@stale stale bot added the Stale label Nov 30, 2020
@christianostrem
Copy link
Author

christianostrem commented Nov 30, 2020 via email

@stale stale bot removed the Stale label Nov 30, 2020
@stale
Copy link

stale bot commented Dec 21, 2020

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.

@stale stale bot added the Stale label Dec 21, 2020
@stale stale bot closed this as completed Dec 28, 2020
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

2 participants