This repository has been archived by the owner on Jul 30, 2024. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 511
Add Two Factor Authentication #842
Open
TillerBurr
wants to merge
33
commits into
pallets-eco:develop
Choose a base branch
from
TillerBurr:develop
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 25 commits
Commits
Show all changes
33 commits
Select commit
Hold shift + click to select a range
915b1b4
Security two factor authentication feature
galstat88 eb6e673
fix double import and unused import, revert get_user
TillerBurr 8befa63
Merge branch 'develop1' into develop
TillerBurr 794faea
syntax error
3eebb5f
fix missing setup.py install_requires
ab07db1
fix TestMail (remove __init_)
4e1b9cb
verify_and_update_password fix
cf617fd
formatting
0f23a50
more formatting
09e9c69
too many blank lines
9cfa47d
double imports in forms.py
6a932b0
formatting forms.py
9fa6005
signals line length
117a0e1
twofactor formatting
46c77af
utils formatting
0944672
update twilio client import
d1f854d
missing import
f8c00ec
blueprint line length (twofactor)
1d1578c
trailing whitespace...
47a5cd5
line too long/import/authors inadv. deleted
948d248
compat: release.py python3
TillerBurr a2c82c8
update install_requires in setup.py
d7d0cb4
bump flask_sqlalchemy
5076a3c
conftest.py allow nulls in sqlalchemy
176b8ca
Spelling, Update Functions and Tests Python 3.7 Support
TillerBurr a9feee7
Update docs/configuration.rst
TillerBurr 185fcbc
consistent two-factor
TillerBurr 148f866
.gitignore .venv/
TillerBurr 3b90197
fixes. passlib.totp, if not request.is_json
TillerBurr 0b0c366
translation stubs for new messages
TillerBurr 4a766a1
Make two-factor login more JSON friendly
TillerBurr 4f909eb
make pyqrcode and onetimepass optional, check imps
TillerBurr 7ef9003
fix function def and import
TillerBurr File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -47,3 +47,6 @@ Session.vim | |
|
||
# Pycharm files | ||
.idea/ | ||
|
||
# VScode | ||
.vscode/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -39,3 +39,6 @@ Tristan Escalada | |
Vadim Kotov | ||
Walt Askew | ||
John Paraskevopoulos | ||
Gal Stainfeld | ||
Ivan Piskunov | ||
Tyler Baur |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -69,6 +69,10 @@ Core | |
to ``MAIL_DEFAULT_SENDER`` if | ||
Flask-Mail is used otherwise | ||
``no-reply@localhost``. | ||
``SECURITY_TWO_FACTOR_RESCUE_MAIL`` Specifies the email address users send | ||
mail to when they can't complete the | ||
two factor authentication login. | ||
Defaults to ``no-reply@localhost``. | ||
``SECURITY_TOKEN_AUTHENTICATION_KEY`` Specifies the query string parameter to | ||
read when using token authentication. | ||
Defaults to ``auth_token``. | ||
|
@@ -151,31 +155,48 @@ Template Paths | |
|
||
.. tabularcolumns:: |p{6.5cm}|p{8.5cm}| | ||
|
||
======================================== ======================================= | ||
``SECURITY_FORGOT_PASSWORD_TEMPLATE`` Specifies the path to the template for | ||
the forgot password page. Defaults to | ||
``security/forgot_password.html``. | ||
``SECURITY_LOGIN_USER_TEMPLATE`` Specifies the path to the template for | ||
the user login page. Defaults to | ||
``security/login_user.html``. | ||
``SECURITY_REGISTER_USER_TEMPLATE`` Specifies the path to the template for | ||
the user registration page. Defaults to | ||
``security/register_user.html``. | ||
``SECURITY_RESET_PASSWORD_TEMPLATE`` Specifies the path to the template for | ||
the reset password page. Defaults to | ||
``security/reset_password.html``. | ||
``SECURITY_CHANGE_PASSWORD_TEMPLATE`` Specifies the path to the template for | ||
the change password page. Defaults to | ||
``security/change_password.html``. | ||
``SECURITY_SEND_CONFIRMATION_TEMPLATE`` Specifies the path to the template for | ||
the resend confirmation instructions | ||
page. Defaults to | ||
``security/send_confirmation.html``. | ||
``SECURITY_SEND_LOGIN_TEMPLATE`` Specifies the path to the template for | ||
the send login instructions page for | ||
passwordless logins. Defaults to | ||
``security/send_login.html``. | ||
======================================== ======================================= | ||
============================================== ======================================= | ||
``SECURITY_FORGOT_PASSWORD_TEMPLATE`` Specifies the path to the template for | ||
the forgot password page. Defaults to | ||
``security/forgot_password.html``. | ||
``SECURITY_LOGIN_USER_TEMPLATE`` Specifies the path to the template for | ||
the user login page. Defaults to | ||
``security/login_user.html``. | ||
``SECURITY_REGISTER_USER_TEMPLATE`` Specifies the path to the template for | ||
the user registration page. Defaults to | ||
``security/register_user.html``. | ||
``SECURITY_RESET_PASSWORD_TEMPLATE`` Specifies the path to the template for | ||
the reset password page. Defaults to | ||
``security/reset_password.html``. | ||
``SECURITY_CHANGE_PASSWORD_TEMPLATE`` Specifies the path to the template for | ||
the change password page. Defaults to | ||
``security/change_password.html``. | ||
``SECURITY_SEND_CONFIRMATION_TEMPLATE`` Specifies the path to the template for | ||
the resend confirmation instructions | ||
page. Defaults to | ||
``security/send_confirmation.html``. | ||
``SECURITY_SEND_LOGIN_TEMPLATE`` Specifies the path to the template for | ||
the send login instructions page for | ||
passwordless logins. Defaults to | ||
``security/send_login.html``. | ||
``SECURITY_TWO_FACTOR_VERIFY_CODE_TEMPLATE`` Specifies the path to the template for | ||
the verify code page for the two factor | ||
authentication process. Defaults to | ||
``security/two_factor_verify_code | ||
.html``. | ||
|
||
``SECURITY_TWO_FACTOR_CHOOSE_METHOD_TEMPLT`` Specifies the path to the template for | ||
TillerBurr marked this conversation as resolved.
Show resolved
Hide resolved
|
||
the choose method page for the two | ||
factor authentication process. Defaults | ||
to ``security/two_factor_choose_method | ||
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. There is a space too much which breaks the line. |
||
.html`` | ||
``SECURITY_TWO_FACTOR_CHANGE_METHOD_TEMPLATE`` Specifies the path to the template for | ||
the change method page for the two | ||
factor authentication process. Defaults | ||
to ``security/two_factor_change_method_ | ||
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. There is a space too much which breaks the line. 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. Thanks. I didn't change much on the docs, mostly just to make sure that the CI tests pass. I've made some changes to the codebase. |
||
password_confirmation.html``. | ||
|
||
============================================== ======================================= | ||
|
||
|
||
Feature Flags | ||
|
@@ -214,6 +235,15 @@ Feature Flags | |
change password endpoint. The URL for this endpoint is | ||
specified by the ``SECURITY_CHANGE_URL`` configuration | ||
option. Defaults to ``False``. | ||
``SECURITY_TWO_FACTOR`` Specifies if Flask-Security should enable the | ||
two factor login feature. If set to ``True``, in | ||
addition to their passwords, users will be required to | ||
enter a code that is sent to them. The added feature | ||
includes the ability to send it either via email, sms | ||
message, or Google Authenticator. Default time of | ||
validity is 30 seconds in Google Authenticator and up | ||
to 60 seconds if sent by mail or sms. | ||
Defaults to ``False``. | ||
========================= ====================================================== | ||
|
||
|
@@ -249,6 +279,12 @@ Email | |
``SECURITY_EMAIL_HTML`` Sends email as HTML using | ||
``*.html`` template. Defaults | ||
to ``True``. | ||
``SECURITY_EMAIL_SUBJECT_TWO_FACTOR`` Sets the subject for the two | ||
factor feature. Defaults to | ||
``Two Factor Login`` | ||
``SECURITY_EMAIL_SUBJECT_TWO_FACTOR_RESCUE`` Sets the subject for the two | ||
factor help function. Defaults | ||
to ``Two Factor Rescue`` | ||
================================================= ============================== | ||
|
||
Miscellaneous | ||
|
@@ -290,6 +326,28 @@ Miscellaneous | |
enabled. Always pluralized the | ||
time unit for this value. | ||
Defaults to ``1 days``. | ||
``SECURITY_TWO_FACTOR_GOOGLE_AUTH_VALIDITY`` Specifies the number of time | ||
windows user has before the token | ||
generated for him using google | ||
authenticator is valid. time | ||
windows specifies the amount of | ||
time, which is 30 seconds for each | ||
window. Default to 0, which is up | ||
to 30 seconds. | ||
``SECURITY_TWO_FACTOR_MAIL_VALIDITY`` Specifies the number of time | ||
windows user has before the token | ||
sent to him using mail is valid. | ||
time windows specifies the amount | ||
of time, which is 30 seconds for | ||
each window. Default to 1, which | ||
is up to 60 seconds. | ||
``SECURITY_TWO_FACTOR_SMS_VALIDITY`` Specifies the number of time | ||
windows user has before the token | ||
sent to him using sms is valid. | ||
time windows specifies the amount | ||
of time, which is 30 seconds for | ||
each window. Default to 5, which | ||
is up to 3 minutes. . | ||
``SECURITY_LOGIN_WITHOUT_CONFIRMATION`` Specifies if a user may login | ||
before confirming their email when | ||
the value of | ||
|
@@ -315,6 +373,24 @@ Miscellaneous | |
``SECURITY_DEFAULT_REMEMBER_ME`` Specifies the default "remember | ||
me" value used when logging in | ||
a user. Defaults to ``False``. | ||
``SECURITY_TWO_FACTOR_ENABLED_METHODS`` Specifies the default enabled | ||
methods for two factor | ||
authentication. defaults to | ||
``['mail', 'google_authenticator', | ||
'sms']`` which are the only | ||
supported method at the moment. | ||
``SECURITY_TWO_FACTOR_URI_SERVICE_NAME`` Specifies the name of the service | ||
or application that the user is | ||
authenticating to. Defaults to | ||
``service_name`` | ||
``SECURITY_TWO_FACTOR_SMS_SERVICE`` Specifies the name of the sms | ||
service provider. Defaults to | ||
``Dummy`` which does nothing. | ||
``SECURITY_TWO_FACTOR_SMS_SERVICE_CONFIG`` Specifies a dictionary of basic | ||
configurations needed for use of a | ||
sms service. Defaults to | ||
``{'ACCOUNT_ID': NONE, 'AUTH_TOKEN | ||
':NONE, 'PHONE_NUMBER': NONE}`` | ||
``SECURITY_DATETIME_FACTORY`` Specifies the default datetime | ||
factory. Defaults to | ||
``datetime.datetime.utcnow``. | ||
|
@@ -359,5 +435,12 @@ The default messages and error levels can be found in ``core.py``. | |
* ``SECURITY_MSG_PASSWORD_RESET_REQUEST`` | ||
* ``SECURITY_MSG_REFRESH`` | ||
* ``SECURITY_MSG_RETYPE_PASSWORD_MISMATCH`` | ||
* ``SECURITY_MSG_TWO_FACTOR_INVALID_TOKEN`` | ||
* ``SECURITY_MSG_TWO_FACTOR_LOGIN_SUCCESSFUL`` | ||
* ``SECURITY_MSG_TWO_FACTOR_CHANGE_METHOD_SUCCESSFUL`` | ||
* ``SECURITY_MSG_TWO_FACTOR_PASSWORD_CONFIRMATION_DONE`` | ||
* ``SECURITY_MSG_TWO_FACTOR_PASSWORD_CONFIRMATION_NEEDED`` | ||
* ``SECURITY_MSG_TWO_FACTOR_PERMISSION_DENIED`` | ||
* ``SECURITY_MSG_TWO_FACTOR_METHOD_NOT_AVAILABLE`` | ||
* ``SECURITY_MSG_UNAUTHORIZED`` | ||
* ``SECURITY_MSG_USER_DOES_NOT_EXIST`` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,6 +9,7 @@ Contents | |
quickstart | ||
models | ||
customizing | ||
two_factor_configurations | ||
api | ||
changelog | ||
authors |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
There is a space too much which breaks the line.