Skip to content
This repository has been archived by the owner on Feb 22, 2024. It is now read-only.

Commit

Permalink
Merge pull request #322 from waltaskew/develop
Browse files Browse the repository at this point in the history
Add configuration for token expiration
  • Loading branch information
Matt Wright committed May 2, 2015
2 parents f2a5e4b + 897b2fc commit e4d9d3a
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 1 deletion.
1 change: 1 addition & 0 deletions AUTHORS
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,4 @@ Rotem Yaari
Srijan Choudhary
Tristan Escalada
Vadim Kotov
Walt Askew
4 changes: 4 additions & 0 deletions docs/configuration.rst
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@ Core
``SECURITY_TOKEN_AUTHENTICATION_HEADER`` Specifies the HTTP header to read when
using token authentication. Defaults to
``Authentication-Token``.
``SECURITY_TOKEN_MAX_AGE`` Specifies the number of seconds before
an authentication token expires.
Defaults to None, meaning the token
never expires.
``SECURITY_DEFAULT_HTTP_AUTH_REALM`` Specifies the default authentication
realm when using basic HTTP auth.
Defaults to ``Login Required``
Expand Down
3 changes: 2 additions & 1 deletion flask_security/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@
'EMAIL_SENDER': 'no-reply@localhost',
'TOKEN_AUTHENTICATION_KEY': 'auth_token',
'TOKEN_AUTHENTICATION_HEADER': 'Authentication-Token',
'TOKEN_MAX_AGE': None,
'CONFIRM_SALT': 'confirm-salt',
'RESET_SALT': 'reset-salt',
'LOGIN_SALT': 'login-salt',
Expand Down Expand Up @@ -192,7 +193,7 @@ def _user_loader(user_id):

def _token_loader(token):
try:
data = _security.remember_token_serializer.loads(token)
data = _security.remember_token_serializer.loads(token, max_age=_security.token_max_age)
user = _security.datastore.find_user(id=data[0])
if user and safe_str_cmp(md5(user.password), data[1]):
return user
Expand Down

0 comments on commit e4d9d3a

Please sign in to comment.