Skip to content

Commit

Permalink
root: deny unauthenticated websocket messages consumer
Browse files Browse the repository at this point in the history
Signed-off-by: Marc 'risson' Schmitt <[email protected]>
  • Loading branch information
rissson committed Feb 27, 2025
1 parent 42501f6 commit 7d40e00
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions authentik/root/messages/consumer.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
"""websocket Message consumer"""

from channels.exceptions import DenyConnection
from channels.generic.websocket import JsonWebsocketConsumer
from django.core.cache import cache

Expand All @@ -13,6 +14,8 @@ class MessageConsumer(JsonWebsocketConsumer):
session_key: str

def connect(self):
if not self.scope["user"].is_authenticated():
raise DenyConnection()

Check warning on line 18 in authentik/root/messages/consumer.py

View check run for this annotation

Codecov / codecov/patch

authentik/root/messages/consumer.py#L17-L18

Added lines #L17 - L18 were not covered by tests
self.accept()
self.session_key = self.scope["session"].session_key
if not self.session_key:
Expand Down

0 comments on commit 7d40e00

Please sign in to comment.