我想使用 django.contrib.auth.middleware.RemoteUserMiddleware 进行身份验证,如下所述:
https://docs.djangoproject.com/en/dev/howto/auth-remote-user/
问题是,如何在没有 Apache 的开发环境中进行测试?即我可以在本地设置中以某种方式设置 REMOTE_USER 吗?
编辑(添加设置)
AUTHENTICATION_BACKENDS = (
'django.contrib.auth.backends.RemoteUserBackend',
)
MIDDLEWARE_CLASSES = (
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.auth.middleware.RemoteUserMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
)
INSTALLED_APPS = (
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
...
)
然后我在我的 local_Settings 中有这个:
os.environ['REMOTE_USER'] = "mmatyas"
我还尝试了“HTTP_REMOTE_USER”变体。谢谢!