我试图WWW-Authenticate
在 Django 中使用简单的 HTTP 身份验证REMOTE_USER
。这是通过RemoteUserMiddleware完成的。
不幸的是,像这样更改我的配置文件后:
MIDDLEWARE_CLASSES = (
'django.middleware.common.CommonMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.auth.middleware.RemoteUserMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
)
AUTHENTICATION_BACKENDS = (
'django.contrib.auth.backends.RemoteUserBackend',
)
并将@login_required
装饰器添加到我的视图中,它不起作用。当我查看该页面时,它会将我定向到accounts/login/?next=/page/I/tried/to/access
,它不存在并引发 404 错误。
为什么不直接发送WWW-Authenticate
?如果这不是正确的方法,我该怎么办?