Hi I try to figure out how to use django AUTHENTICATION_BACKENDS with django channels
I see it get KeyError (_auth_user_id) when parse the request, I wonder why it return anonymous user immediately and not query the AUTHENTICATION_BACKENDS *@database_sync_to_asyncdef get_user(scope): """Return the user model instance associated with the given scope.If no user is retrieved,return an instance of `AnonymousUser`."""if "session"not in scope: raise ValueError( "Cannot find session in scope. You should wrap your consumer in SessionMiddleware." )session = scope["session"]user = Nonetry:user_id = _get_user_session_key(session)backend_path = session[BACKEND_SESSION_KEY]except KeyError:#return anoymous here without go further query the user passelse : if backend_path in settings.AUTHENTICATION_BACKENDS: backend = load_backend(backend_path)user = backend.get_user(user_id)# Verify the sessionif hasattr(user, "get_session_auth_hash"): session_hash = session.get(HASH_SESSION_KEY)session_hash_verified = session_hash and constant_time_compare( session_hash, user.get_session_auth_hash())if not session_hash_verified: session.flush()user = Nonereturn user or AnonymousUser()* https://github.com/django/channels/blob/fca74cdf78761650842102b02ee27bad1634ea20/channels/auth.py#L38 -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/938afdb2-16f8-4e5b-a20e-1c4737af631fn%40googlegroups.com.