Skip to content

Instantly share code, notes, and snippets.

View goatwu1993's full-sized avatar

Chao Yang Wu goatwu1993

View GitHub Profile
@goatwu1993
goatwu1993 / middlewares.py
Created January 5, 2021 09:21
Django_Channels3_SimpleJWT_Auth_Middleware.py
"""General web socket middlewares
"""
from channels.auth import AuthMiddlewareStack
from channels.db import database_sync_to_async
from channels.middleware import BaseMiddleware
from django.contrib.auth.models import AnonymousUser
from rest_framework_simplejwt.authentication import JWTTokenUserAuthentication
from rest_framework_simplejwt.state import User