可以使用Django的HTTP基本身份验证吗? [英] Can I use HTTP Basic Authentication with Django?

查看:285
本文介绍了可以使用Django的HTTP基本身份验证吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们有一个在Apache上运行的网站,其中有许多通过HTTP Basic身份验证保护的静态页面。



我已经写了一个新的部分网站与Django使用Django内置的用户管理支持。



我遇到的问题是用户必须通过HTTP基本身份验证登录一次,然后再次使用Django登录表单。对于用户来说,这两个都很笨拙,很混乱。



我想知道是否有人找到了一种方法来使Django使用HTTP Basic身份验证信息登录用户。 >

我不希望将密码传递给Django,而是如果一个用户 dave 已经被Apache认证,那么他们应该自动登录到Django作为 dave



(一个选项是使Apache和Django共享一个用户商店以确保常用的用户名和密码,但是这仍然会涉及到两个登录提示,这是我想避免的。)

解决方案

这已经添加到Django 1.3版本中。请参阅此处的更多当前文档:
http:// docs.djangoproject.com/en/dev/howto/auth-remote-user/


We have a website running on Apache, access to which has a number of static pages protected via HTTP Basic authentication.

I've written a new part of the site with Django using Django's built in support for user management.

The problem I have is that users have to log in once via the HTTP Basic authentication and then again using a Django login form. This both clumsy and very confusing for users.

I was wondering if anyone had found a way to make Django log a user in using the HTTP Basic authentication information.

I not expecting to pass a password to Django, but rather if a user dave has been authenticated by Apache then they should be automatically logged into Django as dave too.

(One option would be to make Apache and Django share a user store to ensure common usernames and passwords but this would still involve two login prompts which is what I'm trying to avoid.)

解决方案

This has been added to the Django 1.3 release. See more current documentation for this here: http://docs.djangoproject.com/en/dev/howto/auth-remote-user/

这篇关于可以使用Django的HTTP基本身份验证吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆