Disable fresh login check in auth engines that won't support it
This commit is contained in:
parent
524d77f527
commit
2214a2c7ad
5 changed files with 20 additions and 2 deletions
|
@ -187,6 +187,11 @@ class UserAuthentication(object):
|
||||||
""" Returns whether this auth system supports using encrypted credentials. """
|
""" Returns whether this auth system supports using encrypted credentials. """
|
||||||
return self.state.supports_encrypted_credentials
|
return self.state.supports_encrypted_credentials
|
||||||
|
|
||||||
|
@property
|
||||||
|
def supports_fresh_login(self):
|
||||||
|
""" Returns whether this auth system supports the fresh login check. """
|
||||||
|
return self.state.supports_fresh_login
|
||||||
|
|
||||||
def query_users(self, query, limit=20):
|
def query_users(self, query, limit=20):
|
||||||
""" Performs a lookup against the user system for the specified query. The returned tuple
|
""" Performs a lookup against the user system for the specified query. The returned tuple
|
||||||
will be of the form (results, federated_login_id, err_msg). If the method is unsupported,
|
will be of the form (results, federated_login_id, err_msg). If the method is unsupported,
|
||||||
|
|
|
@ -12,6 +12,10 @@ class AppTokenInternalAuth(object):
|
||||||
""" Forces all internal credential login to go through an app token, by disabling all other
|
""" Forces all internal credential login to go through an app token, by disabling all other
|
||||||
access.
|
access.
|
||||||
"""
|
"""
|
||||||
|
@property
|
||||||
|
def supports_fresh_login(self):
|
||||||
|
# Since there is no password.
|
||||||
|
return False
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def federated_service(self):
|
def federated_service(self):
|
||||||
|
|
|
@ -5,6 +5,10 @@ class DatabaseUsers(object):
|
||||||
def federated_service(self):
|
def federated_service(self):
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
@property
|
||||||
|
def supports_fresh_login(self):
|
||||||
|
return True
|
||||||
|
|
||||||
def ping(self):
|
def ping(self):
|
||||||
""" Always assumed to be working. If the DB is broken, other checks will handle it. """
|
""" Always assumed to be working. If the DB is broken, other checks will handle it. """
|
||||||
return (True, None)
|
return (True, None)
|
||||||
|
|
|
@ -24,6 +24,10 @@ class FederatedUsers(object):
|
||||||
def federated_service(self):
|
def federated_service(self):
|
||||||
return self._federated_service
|
return self._federated_service
|
||||||
|
|
||||||
|
@property
|
||||||
|
def supports_fresh_login(self):
|
||||||
|
return True
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def supports_encrypted_credentials(self):
|
def supports_encrypted_credentials(self):
|
||||||
return True
|
return True
|
||||||
|
|
|
@ -10,7 +10,7 @@ from flask_restful import Resource, abort, Api, reqparse
|
||||||
from flask_restful.utils.cors import crossdomain
|
from flask_restful.utils.cors import crossdomain
|
||||||
from jsonschema import validate, ValidationError
|
from jsonschema import validate, ValidationError
|
||||||
|
|
||||||
from app import app, metric_queue
|
from app import app, metric_queue, authentication
|
||||||
from auth.permissions import (ReadRepositoryPermission, ModifyRepositoryPermission,
|
from auth.permissions import (ReadRepositoryPermission, ModifyRepositoryPermission,
|
||||||
AdministerRepositoryPermission, UserReadPermission,
|
AdministerRepositoryPermission, UserReadPermission,
|
||||||
UserAdminPermission)
|
UserAdminPermission)
|
||||||
|
@ -300,7 +300,8 @@ def require_fresh_login(func):
|
||||||
last_login = session.get('login_time', datetime.datetime.min)
|
last_login = session.get('login_time', datetime.datetime.min)
|
||||||
valid_span = datetime.datetime.now() - datetime.timedelta(minutes=10)
|
valid_span = datetime.datetime.now() - datetime.timedelta(minutes=10)
|
||||||
|
|
||||||
if not user.password_hash or last_login >= valid_span:
|
if (not user.password_hash or last_login >= valid_span or
|
||||||
|
not authentication.supports_fresh_login):
|
||||||
return func(*args, **kwargs)
|
return func(*args, **kwargs)
|
||||||
|
|
||||||
raise FreshLoginRequired()
|
raise FreshLoginRequired()
|
||||||
|
|
Reference in a new issue