diff --git a/assets/ts_src/ajax_ui.ts b/assets/ts_src/ajax_ui.ts index 98da4eaf..af6661bb 100644 --- a/assets/ts_src/ajax_ui.ts +++ b/assets/ts_src/ajax_ui.ts @@ -363,6 +363,11 @@ class AjaxUI { return; } + //Ignore ajax errors with 200 code (like the ones during 2FA authentication) + if(request.status == 200) { + return; + } + console.error("Error getting the ajax data from server!"); console.log(event); console.log(request); diff --git a/config/packages/scheb_two_factor.yaml b/config/packages/scheb_two_factor.yaml index 6c692aaf..41feb3d2 100644 --- a/config/packages/scheb_two_factor.yaml +++ b/config/packages/scheb_two_factor.yaml @@ -11,6 +11,7 @@ scheb_two_factor: issuer: 'Part-DB' # 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 backup_codes: enabled: true # If the backup code feature should be enabled diff --git a/config/packages/security.yaml b/config/packages/security.yaml index 5fd51805..4fa6ccb1 100644 --- a/config/packages/security.yaml +++ b/config/packages/security.yaml @@ -18,6 +18,11 @@ security: anonymous: true user_checker: App\Security\UserChecker + two_factor: + auth_form_path: 2fa_login + check_path: 2fa_login_check + csrf_token_generator: security.csrf.token_manager + # activate different ways to authenticate #http_basic: true @@ -42,5 +47,7 @@ security: # Easy way to control access for large sections of your site # Note: Only the *first* access control that matches will be used access_control: - # - { path: ^/admin, roles: ROLE_ADMIN } - # - { path: ^/profile, roles: ROLE_USER } + # This makes the logout route available during two-factor authentication, allows the user to cancel + - { path: ^/logout, role: IS_AUTHENTICATED_ANONYMOUSLY } + # This ensures that the form can only be accessed when two-factor authentication is in progress + - { path: ^/2fa, role: IS_AUTHENTICATED_2FA_IN_PROGRESS } diff --git a/config/routes/scheb_two_factor.yaml b/config/routes/scheb_two_factor.yaml index b574a0c9..b4ef9116 100644 --- a/config/routes/scheb_two_factor.yaml +++ b/config/routes/scheb_two_factor.yaml @@ -1,7 +1,7 @@ 2fa_login: - path: /2fa + path: /{_locale}/2fa defaults: _controller: "scheb_two_factor.form_controller:form" 2fa_login_check: - path: /2fa_check + path: /{_locale}/2fa_check diff --git a/templates/security/2fa_form.html.twig b/templates/security/2fa_form.html.twig new file mode 100644 index 00000000..cfd1b587 --- /dev/null +++ b/templates/security/2fa_form.html.twig @@ -0,0 +1,61 @@ +{% extends "main_card.html.twig" %} + +{% block title %}{% trans %}tfa.check.title{% endtrans %}{% endblock %} + +{% block card_title %} {% trans %}tfa.check.title{% endtrans %}{% endblock %} + +{% block content %} + {% if authenticationError %} + + {% endif %} + + {{ parent() }} +{% endblock %} + +{% block card_content %} + + + {# Display current two-factor provider #} + +
+
+ +
+ + + {% trans %}tfa.check.code.help{% endtrans %} + +
+
+ {% if displayTrustedOption %} +
+
+
+ + +
+
+
+ {% endif %} + + + {% if isCsrfProtectionEnabled %} + + {% endif %} +
+
+ + {% trans %}user.logout{% endtrans %} +
+
+
+{% endblock %} \ No newline at end of file