-
|
Previously, I had a working setup with Weblate v5.9.2.2 using Django's remote user authentication. After updating to 5.10.4. Weblate started crashing upon page load with a stack trace pointing to a file in Weblate source code: The line in question is here. To me, this seems like a possible bug, since I am not a Python expert and even less so with Django, so I decided to start a discussion rather than opening a bug ticket right away. Do you think this is an issue with Weblate or my setup (see below)? I am using both a custom middleware configuration and a custom backend like so: AUTHENTICATION_BACKENDS = [
"kieku.auth.RemoteUserBackend",
"weblate.accounts.auth.WeblateUserBackend",
]
MIDDLEWARE += [
"django.contrib.auth.middleware.AuthenticationMiddleware",
"kieku.auth.RemoteUserMiddleware",
]The middleware specifies the name of the HTTP header containing the authenticated user's username as per Django's docs. That works fine with v5.10.4. In other words, dropping my custom backend from The custom backend inherits from from django.contrib.auth import get_user_model
from django.contrib.auth.backends import RemoteUserBackend as DjangoRemoteUserBackend
from django.contrib.auth.middleware import (
RemoteUserMiddleware as DjangoRemoteUserMiddleware,
)
UserModel = get_user_model()
class RemoteUserMiddleware(DjangoRemoteUserMiddleware):
"""
Make django.contrib.auth.backends.RemoteUserBackend read username from our custom header.
See https://docs.djangoproject.com/en/5.1/howto//auth-remote-user/ .
"""
header = "HTTP_X_USER"
class RemoteUserBackend(DjangoRemoteUserBackend):
def configure_user(self, request, user, **kwargs):
"""
After authentication, update the user's e-mail and full name fields with values from
Shibboleth headers.
"""
user = super().configure_user(request, user, **kwargs)
email = request.META.get("HTTP_X_EMAIL")
if email:
user.email = email
full_name = request.META.get("HTTP_X_FULLNAME")
if full_name:
user.full_name = full_name
user.save()
return userIf I replace the backend class with just class RemoteUserBackend(DjangoRemoteUserBackend):
passI still get the same error. This leads me to suspect that commit 202520b might be the culprit rather than my What do you think? Should I open a bug issue for this? If the problem is not with Weblate, I'd much appreciate any pointers as to what I'm messing up with the customization. Like I said, it worked before, leading me to believe it is correct, but my Django knowledge is very limited so I'm pretty stuck with debugging this at the moment. Thank you very much! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
|
Definitely a bug introduced in #13640, created #14434 to track this. |
Beta Was this translation helpful? Give feedback.
Definitely a bug introduced in #13640, created #14434 to track this.