Basic channels middleware for token auth

This commit is contained in:
Eliot Berriot 2018-02-25 13:05:29 +01:00
parent 498aa1137b
commit 5c2ddc56c4
No known key found for this signature in database
GPG key ID: DD6965E2476E5C27
5 changed files with 138 additions and 0 deletions

17
api/config/routing.py Normal file
View file

@ -0,0 +1,17 @@
from django.conf.urls import url
from channels.auth import AuthMiddlewareStack
from channels.routing import ProtocolTypeRouter, URLRouter
from funkwhale_api.common.auth import TokenAuthMiddleware
from funkwhale_api.music import consumers
application = ProtocolTypeRouter({
# Empty for now (http->django views is added by default)
"websocket": TokenAuthMiddleware(
URLRouter([
url("^api/v1/test/$", consumers.MyConsumer),
])
),
})