Monday, September 5, 2022

More documentation needed - Channels with multiple authentication backends

Greetings,

I've started using channels in an existing application (because IDOM requires it), which has two authentication backends (one local, one LDAP):

AUTHENTICATION_BACKENDS = [
    "django_auth_ldap.backend.LDAPBackend",
    "django.contrib.auth.backends.ModelBackend",
]

This results in the following warnings:

IDOM websocket authentication has failed!
Traceback (most recent call last):
  File "/home/ldt/Projects/fedjango/.venv/lib/python3.9/site-packages/channels/auth.py", line 95, in login
    backend = backend or user.backend
[...]
AttributeError: 'User' object has no attribute 'backend'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
[...]
  File "/home/ldt/Projects/fedjango/.venv/lib/python3.9/site-packages/channels/auth.py", line 101, in login
    raise ValueError(
ValueError: You have multiple authentication backends configured and therefore must provide the `backend` argument or set the `backend` attribute on the user.

Unfortunately, the channels documentation has little to no information on how to best solve this. Where should I provide this backend? Which constructor or function takes this as argument? And what should I provide exactly? The backend object, or just the string?


Thanks in advance for any help you can provide,

Laurent De Buyst

--
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+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/0ecf64a8-4c91-45f4-ba8a-79583bb0321fn%40googlegroups.com.

No comments:

Post a Comment