Skip to content

Instantly share code, notes, and snippets.

View manupatel007's full-sized avatar
🎯
Focusing

Vishwas Patel manupatel007

🎯
Focusing
  • Jaipur
View GitHub Profile
@manupatel007
manupatel007 / channelmiddleware.py
Last active August 31, 2021 16:14
Simple middleware to secure django channels 3.0 using Token authentication by simplejwt.
from rest_framework_simplejwt.tokens import UntypedToken
from django.conf import settings
from jwt import decode as jwt_decode
from urllib.parse import parse_qs
from django.contrib.auth.models import User
from channels.db import database_sync_to_async
@database_sync_to_async
def get_user(user_id):