Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Auth: fixed session invalidation logic #449

Merged
merged 2 commits into from
Dec 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 2 additions & 6 deletions ayon_server/auth/session.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,13 +85,9 @@ async def check(cls, token: str, request: Request | None) -> SessionModel | None
# extend normal tokens validity, but not service tokens.
# they should be validated against db forcefully every 10 minutes or so

# Extend the session lifetime only if it's in its second half
# (save update requests).
# So it doesn't make sense to call the parameter last_used is it?
# Whatever. Fix later.

if not session.is_service:
if time.time() - session.created > ayonconfig.session_ttl / 2:
remaining_ttl = ayonconfig.session_ttl - (time.time() - session.last_used)
if remaining_ttl < ayonconfig.session_ttl - 120:
session.last_used = time.time()
await Redis.set(cls.ns, token, json_dumps(session.dict()))

Expand Down
2 changes: 1 addition & 1 deletion ayon_server/config/ayonconfig.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ class AyonConfig(BaseModel):
)

session_ttl: int = Field(
default=24 * 3600,
default=72 * 3600,
description="Session lifetime in seconds",
)

Expand Down