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

How to whitelist routes during 2FA? #185

Closed
yard-mschwartz opened this issue Apr 5, 2023 · 2 comments
Closed

How to whitelist routes during 2FA? #185

yard-mschwartz opened this issue Apr 5, 2023 · 2 comments
Labels

Comments

@yard-mschwartz
Copy link

Bundle version: 5.13
Symfony version: 5.4.7
PHP version: 7.4 and 8.1
Using authenticators (enable_authenticator_manager: true): YES

Description

The README says you can whitelist routes that need to be accessible during the 2FA process. I wasn't able to find how this is being done. There doesn't seem to be documentation for this feature.

Additional Context

// security.yaml
security:
    enable_authenticator_manager: true

    ...

    firewalls:
        ...
        main:
            ...
            two_factor:
                auth_form_path: /2fa
                check_path: /2fa_check
                post_only: true
                provider: app_user_provider
                prepare_on_login: true
                prepare_on_access_denied: true
                authentication_required_handler: [...]\TwoFactorAuthenticationRequiredHandler
                success_handler: [...]\TwoFactorAuthenticationSuccessHandler
                failure_handler: [...]\TwoFactorAuthenticationFailureHandler
@yard-mschwartz
Copy link
Author

Oh wow, immediately stumbled on the answer by trial and error after posting the ticket.

Just adding a new line in routes/scheb_2fa.yaml does the trick:

2fa_login:
    path: /2fa
    defaults:
        _controller: "scheb_two_factor.form_controller:form"

2fa_login_check:
    path: /2fa_check

// added these
2fa_reset:
    path: /2fa_reset

@scheb
Copy link
Owner

scheb commented Apr 5, 2023

You can whitelist path patterns in the firewall access_control settings.

Use IS_AUTHENTICATED_2FA_IN_PROGRESS if you want that make that path only accessible within the intermediate 2fa state. Use PUBLIC_ACCESS if you want to have the path accessible all the time.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants