diff options
author | Frederick Muriuki Muriithi | 2024-07-19 09:35:51 -0500 |
---|---|---|
committer | Frederick Muriuki Muriithi | 2024-07-31 09:30:22 -0500 |
commit | 6510dd5175b84c9780dda2fe0d8869efaeb2404b (patch) | |
tree | 7f17e90fa9ff4bb9b4ad3a7146f0489119132b93 /gn_auth/session.py | |
parent | bb66f79d675ad046acdc4e6853416bf7e948d6dc (diff) | |
download | gn-auth-6510dd5175b84c9780dda2fe0d8869efaeb2404b.tar.gz |
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.
Diffstat (limited to 'gn_auth/session.py')
-rw-r--r-- | gn_auth/session.py | 4 |
1 files changed, 2 insertions, 2 deletions
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 |