-
Notifications
You must be signed in to change notification settings - Fork 60
feat: Initial 2FA implementation with Scheb\TwoFactorBundle #365
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
base: develop
Are you sure you want to change the base?
Changes from 1 commit
2bf5bdd
243cc61
a3c402c
b459ac9
c23cb93
d4e2d28
677bb25
f7d9b85
a7a9389
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| # config/packages/scheb_2fa.yaml | ||
| scheb_two_factor: | ||
| backup_codes: | ||
| enabled: true | ||
| totp: | ||
| enabled: true # If TOTP authentication should be enabled, default false | ||
| server_name: bewelcome.com # Server name used in QR code | ||
| issuer: BeWelcome # Issuer name used in QR code | ||
| leeway: 60 # Acceptable time drift in seconds, must be less or equal than the TOTP period | ||
| parameters: # Additional parameters added in the QR code | ||
| # image: 'https://my-service/img/logo.png' | ||
| image: 'https://miro.medium.com/v2/resize:fill:128:128/1*65AfOY_oNSTe2G1bFMwQ4A.jpeg' | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This should be served through our own server. Could this be done relative to the base url?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. just to know which file. I got this one while doing image search for a small logo |
||
| template: security/2fa_form.html.twig | ||
| google: | ||
jj2bw marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| enabled: true | ||
| server_name: bewelcome.com # Server name used in QR code | ||
| issuer: BeWelcome # Issuer name used in QR code | ||
| leeway: 60 # Acceptable time drift in seconds, must be less or equal than the TOTP period | ||
| template: security/2fa_form.html.twig | ||
| security_tokens: | ||
| # - Symfony\Component\Security\Core\Authentication\Token\UsernamePasswordToken | ||
| # Symfony 7.2 default enable_authenticator_manager, per profiler _security_skipped_authenticators | ||
| - Symfony\Component\Security\Http\Authenticator\Token\PostAuthenticationToken | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| # config/routes/scheb_2fa.yaml | ||
| 2fa_login: | ||
| path: /2fa | ||
| # "scheb_two_factor.form_controller" references the controller service provided by the bundle. | ||
| # You don't HAVE to use it, but - except you have very special requirements - it is recommended. | ||
| controller: "scheb_two_factor.form_controller::form" | ||
|
|
||
| 2fa_login_check: | ||
| path: /2fa_check |
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This introduced new columns for the member entity but there is no migration. Additionally the two factor auth should be optional which means that there needs to be a preference to enable it and the columns should be in a table of their own (we already have way too many columns on member).
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. imho, that should come after validating things are functional. more database optimisation. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,39 @@ | ||
| {% extends "base.html.twig" %} | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is lacking translations.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. similary, after validating things are functional (and not breaking anything) as this initial work and there will certainly be polishing later. But no point to polish something not working. |
||
|
|
||
| {% block body %} | ||
| <h1>Two-Factor Authentication</h1> | ||
|
|
||
| {% if authenticationError %} | ||
| <p class="error">{{ authenticationError|trans(authenticationErrorData, 'SchebTwoFactorBundle') }}</p> | ||
| {% endif %} | ||
|
|
||
| <form class="form" action="{{ checkPathUrl ? checkPathUrl: path(checkPathRoute) }}" method="post"> | ||
| <p class="widget"> | ||
| <label for="_auth_code">Enter authentication code for provider <code>{{ twoFactorProvider }}</code>:</label> | ||
| <input id="_auth_code" type="text" name="{{ authCodeParameterName }}" autocomplete="one-time-code" autofocus /> | ||
| <button type="submit" name="submit-button">Send Code</button> or <a href="{{ logoutPath }}">Cancel 2FA</a> | ||
| </p> | ||
|
|
||
| {% if twoFactorProvider == "email" %} | ||
| <p>Hint: The current authentication code is: <code>{{ app.user.emailAuthCode }}</code></p> | ||
| {% endif %} | ||
|
|
||
| {% if displayTrustedOption %} | ||
| <p><label for="_trusted"><input id="_trusted" type="checkbox" name="{{ trustedParameterName }}" /> {{ "trusted"|trans({}, 'SchebTwoFactorBundle') }}</label></p> | ||
| {% endif %} | ||
|
|
||
| {% if availableTwoFactorProviders|length > 1 %} | ||
| <hr/> | ||
| <p>Choose authentication method: | ||
| {% for provider in availableTwoFactorProviders %} | ||
| <a href="{{ path("2fa_login", {"preferProvider": provider}) }}">{{ provider }}</a> | ||
| {% if not loop.last %}, {% endif %} | ||
| {% endfor %} | ||
| </p> | ||
| {% endif %} | ||
|
|
||
| {% if isCsrfProtectionEnabled %} | ||
| <input type="hidden" name="{{ csrfParameterName }}" value="{{ csrf_token(csrfTokenId) }}"> | ||
| {% endif %} | ||
| </form> | ||
| {% endblock %} | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nope. The server would be bewelcome.org. But I suppose it is better to use a parameter here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
for now switched to .org
not sure where variable should be defined.