ADD setting for token expire hours
@@ -6,6 +6,7 @@ from flask import has_request_context, request
from anubis.config import config
from anubis.models import User
+from anubis.utils.config import get_config_int
def get_token() -> Union[str, None]:
@@ -40,8 +41,12 @@ def create_token(netid: str, exp_kwargs=None, **extras) -> Union[str, None]:
# Get user
user: User = User.query.filter_by(netid=netid).first()
+ # Get setting for number of hours that tokens should last.
+ token_exp_hours = get_config_int('AUTH_TOKEN_EXP_HOURS', default=6)
+
+ # Set the expire kwargs
if exp_kwargs is None:
- exp_kwargs = {"hours": 6}
+ exp_kwargs = {"hours": token_exp_hours}
# Verify user exists
if user is None:
