mirror of
https://code.eliotberriot.com/funkwhale/funkwhale.git
synced 2025-10-06 04:09:56 +02:00
Basic channels middleware for token auth
This commit is contained in:
parent
498aa1137b
commit
5c2ddc56c4
5 changed files with 138 additions and 0 deletions
11
api/funkwhale_api/common/consumers.py
Normal file
11
api/funkwhale_api/common/consumers.py
Normal file
|
@ -0,0 +1,11 @@
|
|||
from channels.generic.websocket import JsonWebsocketConsumer
|
||||
|
||||
|
||||
class JsonAuthConsumer(JsonWebsocketConsumer):
|
||||
def connect(self):
|
||||
try:
|
||||
assert self.scope['user'].pk is not None
|
||||
except (AssertionError, AttributeError, KeyError):
|
||||
return self.close()
|
||||
|
||||
return self.accept()
|
Loading…
Add table
Add a link
Reference in a new issue