@@ -1612,7 +1612,7 @@ logger = logging.getLogger(__name__)
16121612
16131613def generate_csrf(secret_key = None , token_key = None ):
16141614
1615- secret_key = _get_config(
1615+ ~~ secret_key = _get_config(
16161616~~ secret_key, ' WTF_CSRF_SECRET_KEY' , current_app.secret_key,
16171617 message = ' A secret key is required to use CSRF.'
16181618 )
@@ -1640,7 +1640,7 @@ def generate_csrf(secret_key=None, token_key=None):
16401640
16411641def validate_csrf(data, secret_key = None , time_limit = None , token_key = None ):
16421642
1643- secret_key = _get_config(
1643+ ~~ secret_key = _get_config(
16441644~~ secret_key, ' WTF_CSRF_SECRET_KEY' , current_app.secret_key,
16451645 message = ' A secret key is required to use CSRF.'
16461646 )
@@ -1887,6 +1887,7 @@ from .forms import (
18871887# # ... source file abbreviated to get to current_app examples ...
18881888
18891889
1890+ UnifiedSigninSetupForm,
18901891 UnifiedSigninSetupValidateForm,
18911892 UnifiedVerifyForm,
18921893 us_send_security_token,
@@ -1899,7 +1900,6 @@ from .utils import (
18991900 FsPermNeed,
19001901 csrf_cookie_handler,
19011902 default_want_json,
1902- default_password_validator,
19031903 get_config,
19041904 get_identity_attribute,
19051905 get_identity_attributes,
@@ -1927,6 +1927,7 @@ _default_config = {
19271927 " FLASH_MESSAGES" : True ,
19281928 " I18N_DOMAIN" : " flask_security" ,
19291929 " I18N_DIRNAME" : pkg_resources.resource_filename(" flask_security" , " translations" ),
1930+ " EMAIL_VALIDATOR_ARGS" : None ,
19301931 " PASSWORD_HASH" : " bcrypt" ,
19311932 " PASSWORD_SALT" : None ,
19321933 " PASSWORD_SINGLE_HASH" : {
@@ -1936,20 +1937,11 @@ _default_config = {
19361937 " django_pbkdf2_sha1" ,
19371938 " django_bcrypt" ,
19381939 " django_salted_md5" ,
1939- " django_salted_sha1" ,
19401940
19411941
19421942# # ... source file abbreviated to get to current_app examples ...
19431943
19441944
1945- " SEND_CONFIRMATION_TEMPLATE" : " security/send_confirmation.html" ,
1946- " SEND_LOGIN_TEMPLATE" : " security/send_login.html" ,
1947- " VERIFY_TEMPLATE" : " security/verify.html" ,
1948- " TWO_FACTOR_VERIFY_CODE_TEMPLATE" : " security/two_factor_verify_code.html" ,
1949- " TWO_FACTOR_SETUP_TEMPLATE" : " security/two_factor_setup.html" ,
1950- " CONFIRMABLE" : False ,
1951- " REGISTERABLE" : False ,
1952- " RECOVERABLE" : False ,
19531945 " TRACKABLE" : False ,
19541946 " PASSWORDLESS" : False ,
19551947 " CHANGEABLE" : False ,
@@ -1962,6 +1954,14 @@ _default_config = {
19621954 " TWO_FACTOR_AUTHENTICATOR_VALIDITY" : 120 ,
19631955 " TWO_FACTOR_MAIL_VALIDITY" : 300 ,
19641956 " TWO_FACTOR_SMS_VALIDITY" : 120 ,
1957+ " TWO_FACTOR_ALWAYS_VALIDATE" : True ,
1958+ " TWO_FACTOR_LOGIN_VALIDITY" : " 30 days" ,
1959+ " TWO_FACTOR_VALIDITY_SALT" : " tf-validity-salt" ,
1960+ " TWO_FACTOR_VALIDITY_COOKIE" : {
1961+ " httponly" : True ,
1962+ " secure" : False ,
1963+ " samesite" : None ,
1964+ },
19651965 " CONFIRM_EMAIL_WITHIN" : " 5 days" ,
19661966 " RESET_PASSWORD_WITHIN" : " 5 days" ,
19671967 " LOGIN_WITHOUT_CONFIRMATION" : False ,
@@ -2073,6 +2073,7 @@ _default_config = {
20732073
20742074 state._phone_util = state.phone_util_cls(app)
20752075 state._mail_util = state.mail_util_cls(app)
2076+ state._password_util = state.password_util_cls(app)
20762077
20772078 app.extensions[" security" ] = state
20782079
@@ -2086,7 +2087,6 @@ _default_config = {
20862087
20872088 for newc, oldc in [
20882089 (" SECURITY_SMS_SERVICE" , " SECURITY_TWO_FACTOR_SMS_SERVICE" ),
2089- (" SECURITY_SMS_SERVICE_CONFIG" , " SECURITY_TWO_FACTOR_SMS_SERVICE_CONFIG" ),
20902090
20912091
20922092# # ... source file continues with no further current_app examples...
@@ -2144,6 +2144,7 @@ class UserManager(UserManager__Settings, UserManager__Utils, UserManager__Views)
21442144# # ... source file abbreviated to get to current_app examples ...
21452145
21462146
2147+ @ app.before_request
21472148 def advance_session_timeout():
21482149 session.permanent = True # Timeout after app.permanent_session_lifetime period
21492150 session.modified = True # Advance session timeout each time a user visits a page
@@ -2168,7 +2169,7 @@ class UserManager(UserManager__Settings, UserManager__Utils, UserManager__Views)
21682169 def call_or_get(function_or_property):
21692170 return function_or_property() if callable (function_or_property) else function_or_property
21702171
2171- return dict (
2172+ ~~ return dict (
21722173~~ user_manager = current_app.user_manager,
21732174 call_or_get = call_or_get,
21742175 )
0 commit comments