在django内部使用shibboleth用户
django-shibboleth-remoteuser-kennydude的Python项目详细描述
django shibboleth remoteuser
==
这是一个用于保持事物最新的fork
用于将shibboleth与django一起使用的中间件。RemoteAuthMiddleware需要Django 1.3或更高版本。
[![构建状态](https://secure.travis-ci.org/brown-university-library/django-shibboleth-remoteuser.png?branch=master)(http://travis ci.org/brown university library/django shibboleth remoteuser)
git+https://github.com/brown university library/django shibboleth remoteuser.git
```
*在设置中。py:
*启用远程用户后端。
``python
身份验证后端+=(
'shibboleth.backends.shibboleth remoteuserbackend',
)
```
*添加django shibboleth中间件。
必须将django.contrib.auth.middleware.shibbolethremoteusermiddleware添加到django.contrib.auth.middleware.authenticationmiddleware之后的中间件类设置中。
例如:
``python
middleware类=(
…
“django.contrib.auth.middleware.authenticationmiddleware”,
“shibboleth.middleware.shibbolethremoteusermiddleware”,
…
)“将shibboleth属性映射到django用户模型。属性必须以其在http头中的格式声明。
使用此选项从shibboleth属性填充django用户对象。
如果属性是必需的,则元组的第一个元素状态为。如果在分析的
shibboleth头中找不到所需的元素,则会引发异常。
(true,“必需的”属性“)
(false,“可选的”属性)。
``python
shibboleth属性“映射={
“shib用户”:(true,“用户名”),
“shib给定名称”:(true,“名字”),
“shib-sn”:(true,“last-name”),
“shib-mail”:(false,“email”),
}
````
*登录url-将其设置为shibboleth安装的登录处理程序。在大多数情况下,这将类似于:
`` python
login_url='https://your_domain.edu/shibboleth.sso/login'
````
*apache配置-确保应用程序可以使用shibboleth属性。应用程序url不需要shibboleth。
```
<;location/app>;
authtype shibboleth
require shibboleth
<;/location>;
````
--
如果要验证所有配置是否正确,请执行以下两步。它将在您的应用程序/yourapp/shib/中创建一个路径,该路径将回送从shibboleth获得的属性。如果在屏幕上看到上面映射的属性,则一切正常。
*将shibboleth添加到已安装的应用程序中。
`` python
已安装的应用程序+=(
'shibboleth',
)
````
*将下面的内容添加到url.py以启用包含的示例视图。这个视图只是回显解析后的用户属性,这对测试很有帮助。
`` python
url patterns+=模式('',
url(r'^shib/',include('shibboleth.url',namespace='shibboleth'),
)
````
Django Shibboleth远程用户中间件应该是完整的。
这些都是为了方便而不是必需的。若要激活,请将以下内容添加到settings.py.
``python
template_context_processors+=(
'shibboleth.context_处理器。登录链接,
“shibboleth.context\u处理器。注销链接”
)
```
==
这是一个用于保持事物最新的fork
用于将shibboleth与django一起使用的中间件。RemoteAuthMiddleware需要Django 1.3或更高版本。
[![构建状态](https://secure.travis-ci.org/brown-university-library/django-shibboleth-remoteuser.png?branch=master)(http://travis ci.org/brown university library/django shibboleth remoteuser)
git+https://github.com/brown university library/django shibboleth remoteuser.git
```
*在设置中。py:
*启用远程用户后端。
``python
身份验证后端+=(
'shibboleth.backends.shibboleth remoteuserbackend',
)
```
*添加django shibboleth中间件。
必须将django.contrib.auth.middleware.shibbolethremoteusermiddleware添加到django.contrib.auth.middleware.authenticationmiddleware之后的中间件类设置中。
例如:
``python
middleware类=(
…
“django.contrib.auth.middleware.authenticationmiddleware”,
“shibboleth.middleware.shibbolethremoteusermiddleware”,
…
)“将shibboleth属性映射到django用户模型。属性必须以其在http头中的格式声明。
使用此选项从shibboleth属性填充django用户对象。
如果属性是必需的,则元组的第一个元素状态为。如果在分析的
shibboleth头中找不到所需的元素,则会引发异常。
(true,“必需的”属性“)
(false,“可选的”属性)。
``python
shibboleth属性“映射={
“shib用户”:(true,“用户名”),
“shib给定名称”:(true,“名字”),
“shib-sn”:(true,“last-name”),
“shib-mail”:(false,“email”),
}
````
*登录url-将其设置为shibboleth安装的登录处理程序。在大多数情况下,这将类似于:
`` python
login_url='https://your_domain.edu/shibboleth.sso/login'
````
*apache配置-确保应用程序可以使用shibboleth属性。应用程序url不需要shibboleth。
```
<;location/app>;
authtype shibboleth
require shibboleth
<;/location>;
````
如果要验证所有配置是否正确,请执行以下两步。它将在您的应用程序/yourapp/shib/中创建一个路径,该路径将回送从shibboleth获得的属性。如果在屏幕上看到上面映射的属性,则一切正常。
*将shibboleth添加到已安装的应用程序中。
`` python
已安装的应用程序+=(
'shibboleth',
)
````
*将下面的内容添加到url.py以启用包含的示例视图。这个视图只是回显解析后的用户属性,这对测试很有帮助。
`` python
url patterns+=模式('',
url(r'^shib/',include('shibboleth.url',namespace='shibboleth'),
)
````
Django Shibboleth远程用户中间件应该是完整的。
这些都是为了方便而不是必需的。若要激活,请将以下内容添加到settings.py.
``python
template_context_processors+=(
'shibboleth.context_处理器。登录链接,
“shibboleth.context\u处理器。注销链接”
)
```