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

providers/proxy: avoid erroring on logout with session_id is None #9119

Merged
merged 2 commits into from
Aug 7, 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
2 changes: 2 additions & 0 deletions authentik/core/signals.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@
@receiver(user_logged_out)
def user_logged_out_session(sender, request: HttpRequest, user: User, **_):
"""Delete AuthenticatedSession if it exists"""
if not request.session or not request.session.session_key:
return

Check warning on line 56 in authentik/core/signals.py

View check run for this annotation

Codecov / codecov/patch

authentik/core/signals.py#L56

Added line #L56 was not covered by tests
AuthenticatedSession.objects.filter(session_key=request.session.session_key).delete()


Expand Down
2 changes: 2 additions & 0 deletions authentik/enterprise/providers/rac/signals.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
@receiver(user_logged_out)
def user_logged_out_session(sender, request: HttpRequest, user: User, **_):
"""Disconnect any open RAC connections"""
if not request.session or not request.session.session_key:
return

Check warning on line 25 in authentik/enterprise/providers/rac/signals.py

View check run for this annotation

Codecov / codecov/patch

authentik/enterprise/providers/rac/signals.py#L25

Added line #L25 was not covered by tests
layer = get_channel_layer()
async_to_sync(layer.group_send)(
RAC_CLIENT_GROUP_SESSION
Expand Down
2 changes: 2 additions & 0 deletions authentik/providers/oauth2/signals.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,7 @@
@receiver(user_logged_out)
def user_logged_out_oauth_access_token(sender, request: HttpRequest, user: User, **_):
"""Revoke access tokens upon user logout"""
if not request.session or not request.session.session_key:
return
hashed_session_key = sha256(request.session.session_key.encode("ascii")).hexdigest()

Check warning on line 16 in authentik/providers/oauth2/signals.py

View check run for this annotation

Codecov / codecov/patch

authentik/providers/oauth2/signals.py#L15-L16

Added lines #L15 - L16 were not covered by tests
AccessToken.objects.filter(user=user, session_id=hashed_session_key).delete()
2 changes: 2 additions & 0 deletions authentik/providers/proxy/signals.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
@receiver(user_logged_out)
def logout_proxy_revoke_direct(sender: type[User], request: HttpRequest, **_):
"""Catch logout by direct logout and forward to proxy providers"""
if not request.session or not request.session.session_key:
return
proxy_on_logout.delay(request.session.session_key)


Expand Down
Loading