From 6510dd5175b84c9780dda2fe0d8869efaeb2404b Mon Sep 17 00:00:00 2001 From: Frederick Muriuki Muriithi Date: Fri, 19 Jul 2024 09:35:51 -0500 Subject: Enable external configuration of session expiry period Enable passing in the number of minutes that a session can be valid for. This enables the length of time that the session can last to be configurable rather than hard-coded. --- gn_auth/session.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'gn_auth/session.py') diff --git a/gn_auth/session.py b/gn_auth/session.py index 7226ac5..39f6959 100644 --- a/gn_auth/session.py +++ b/gn_auth/session.py @@ -47,11 +47,11 @@ def session_expired() -> bool: return now >= session[__SESSION_KEY__]["expires"] return True -def update_expiry() -> bool: +def update_expiry(minutes: int = 10) -> bool: """Update the session expiry and return a boolean indicating success.""" if not session_expired(): now = datetime.now(tz=timezone.utc) - session[__SESSION_KEY__]["expires"] = now + timedelta(minutes=10) + session[__SESSION_KEY__]["expires"] = now + timedelta(minutes=minutes) return True return False -- cgit v1.2.3