将shibboleth身份验证与rit项目集成
django-shibauth-rit的Python项目详细描述
一、二、二、二、二、三、三、三、三、三、三、四、四、四、四、四、六、六、六、六、六、六、六、六、六、六、六、六、六、六、六、六、六、六、六、六、六、六、六、六、六、六、六、六、六、六、六、六、六、六、六、六、六、六、六、六、六、六、六、六、六、六、六、六、六、六、六、六图片::https://badge.fury.io/py/django shibauth rit.svg
:目标:https://badge.fury.io/py/django shibauth rit
…图片:https://travis-ci.org/audiolion/django-shibauth-rit.svg?branch=master
:目标:https://travis ci.org/audiolion/django shibauth rit
…图片::https://codecov.io/gh/audiolion/django shib auth rit/branch/master/graph/badge.svg
:目标:https://codecov.io/gh/audiolion/django shibauth rit
rit::
pip安装django shibauth rit
将其添加到"已安装的应用程序"中:
……代码块::python
已安装的应用程序=(
…
‘Shibauth-rit’,
…
)
添加身份验证后端:
…代码块::python
authentication_backends=[
'shibauth_rit.backends.shibauthritbackend',
…
]
代码块::python
…
)
添加django shib auth rit的url模式:
…代码块::python
…
url(r'^',include('shibauth_rit.url s'),
…
]
代码块::python
login_url='https://<;您的站点根目录>;/shibboleth.sso/login'
将shibboleth的返回属性映射到您的用户模型:
……代码块::python
shibauth_attribute_map={
'uid':(true,'username'),
'mail':(false,'email'),
}
shibboleth在成功验证后返回许多属性。根据rit的
文档,当前返回的属性是:
…代码块::
uid-用户的rit用户名
given name-用户的给定(名字)名称
sn-用户的姓氏(姓氏/姓氏)
mail-用户的电子邮件地址(注意可以为空)
ritedumemberofid-帐户所属的组(例如:叉车操作员、自动售货机管理员、历史记录员等)
riteduffiliation-显示与RIT关系的多值属性(例如:学生、员工、学生工人、调整人员、退休人员等)
请与ITS服务台联系以请求其他属性。
映射属性时,使用`(boolean,'usermodelfield')`的元组,其中'boolean'表示该字段是否为'required'。这应该符合您的
用户模型的要求。如果您的用户型号如下:
…代码块::python
类用户(abstractbaseuser,permissionsmixin):
用户名字段='email'
电子邮件字段='email'
email=models.email field('email address'),unique=true,blank=true,null=true)
user name=models.charfield(('username'),unique=true,required=true,max_length=50)
name=models.charfield(('name of user'),blank=true,max_length=100)
username是必需属性,应为"uid":(true,'username')`但是电子邮件不是
必需的,应该是'mail':(false,'email')`。
可以通过子类化"shibauthritbackend"并重写"handle\u parse\u exception()"方法来完成此操作。见[石的子类BauthritBackend])。
。htaccess安装程序
----
此包要求您的站点托管在RIT的服务器上。.htaccess应该如下所示。代码块::apache
确保打开https。对于shibboleth auth
rewritecond${https}off
rewriterule(.*)https://%{http{host}[r,l]
两个选项是必需的,延迟加载,在这两个选项中,用户无需进行身份验证即可访问您的站点
<;如果"%{https}='on'">;
sslRequiressl
authType shibboleth
需要shibboleth
shibrequestSetting Requiression false
shibredirecttossl 443
<;
如果"%{https}=‘on’">;
sslRequiresSL
authType shibboleth
shibrequiresession on
需要有效用户
;请参见https://www.rit.edu/webdev/authenticating-and-authorizing-rit-users了解其他需要选项
<;/if>;
这会在apache web服务器上设置一些内容,因此当人们转到https://<;your site root>;/shibboleth.s so/login时,它会启动重定向到rit的shibboleth登录。不要在那里放置url路径,尽管我认为apache总是在它到达您的代码之前获取它,最好不要弄乱它。
}}`在您的模板中,用于将用户路由到登录或注销页面。这些都是为了方便而提供的,不是必需的。若要激活,请将以下内容添加到您的设置中:
…代码块::python
templates=[
{
…
"选项":{
"上下文处理器":[
…
"shibauth rit.context处理器.登录链接",
"shibauth-rit.context-processors.logout-u-link"、
…
]、
}、
…
、
]
代码块::bash
$python runtests.py
代码块::bash
source<;yourvirtualenv>;bin/activate
(myenv)$pip install tox
(myenv)$tox
credits
----
呈现此包时使用的工具:
*cookiecutter
*`cookiecutter djangopack`
。_ Cookiecutter:https://github.com/audreyr/Cookiecutter
。_` Cookiecutter DjangoPackage`:https://github.com/pydanny/Cookiecutter DjangoPackage
----
<0.1.0(2017-02-15)
++++++++++++++
:目标:https://badge.fury.io/py/django shibauth rit
…图片:https://travis-ci.org/audiolion/django-shibauth-rit.svg?branch=master
:目标:https://travis ci.org/audiolion/django shibauth rit
…图片::https://codecov.io/gh/audiolion/django shib auth rit/branch/master/graph/badge.svg
:目标:https://codecov.io/gh/audiolion/django shibauth rit
rit::
pip安装django shibauth rit
将其添加到"已安装的应用程序"中:
……代码块::python
已安装的应用程序=(
…
‘Shibauth-rit’,
…
)
添加身份验证后端:
…代码块::python
authentication_backends=[
'shibauth_rit.backends.shibauthritbackend',
…
]
代码块::python
…
)
添加django shib auth rit的url模式:
…代码块::python
url(r'^',include('shibauth_rit.url s'),
…
]
代码块::python
login_url='https://<;您的站点根目录>;/shibboleth.sso/login'
将shibboleth的返回属性映射到您的用户模型:
……代码块::python
shibauth_attribute_map={
'uid':(true,'username'),
'mail':(false,'email'),
}
shibboleth在成功验证后返回许多属性。根据rit的
文档,当前返回的属性是:
…代码块::
uid-用户的rit用户名
given name-用户的给定(名字)名称
sn-用户的姓氏(姓氏/姓氏)
mail-用户的电子邮件地址(注意可以为空)
ritedumemberofid-帐户所属的组(例如:叉车操作员、自动售货机管理员、历史记录员等)
riteduffiliation-显示与RIT关系的多值属性(例如:学生、员工、学生工人、调整人员、退休人员等)
请与ITS服务台联系以请求其他属性。
映射属性时,使用`(boolean,'usermodelfield')`的元组,其中'boolean'表示该字段是否为'required'。这应该符合您的
用户模型的要求。如果您的用户型号如下:
…代码块::python
类用户(abstractbaseuser,permissionsmixin):
用户名字段='email'
电子邮件字段='email'
email=models.email field('email address'),unique=true,blank=true,null=true)
user name=models.charfield(('username'),unique=true,required=true,max_length=50)
name=models.charfield(('name of user'),blank=true,max_length=100)
username是必需属性,应为"uid":(true,'username')`但是电子邮件不是
必需的,应该是'mail':(false,'email')`。
可以通过子类化"shibauthritbackend"并重写"handle\u parse\u exception()"方法来完成此操作。见[石的子类BauthritBackend])。
。htaccess安装程序
----
此包要求您的站点托管在RIT的服务器上。.htaccess应该如下所示。代码块::apache
确保打开https。对于shibboleth auth
rewritecond${https}off
rewriterule(.*)https://%{http{host}[r,l]
两个选项是必需的,延迟加载,在这两个选项中,用户无需进行身份验证即可访问您的站点
<;如果"%{https}='on'">;
sslRequiressl
authType shibboleth
需要shibboleth
shibrequestSetting Requiression false
shibredirecttossl 443
<;
如果"%{https}=‘on’">;
sslRequiresSL
authType shibboleth
shibrequiresession on
需要有效用户
;请参见https://www.rit.edu/webdev/authenticating-and-authorizing-rit-users了解其他需要选项
<;/if>;
这会在apache web服务器上设置一些内容,因此当人们转到https://<;your site root>;/shibboleth.s so/login时,它会启动重定向到rit的shibboleth登录。不要在那里放置url路径,尽管我认为apache总是在它到达您的代码之前获取它,最好不要弄乱它。
}}`在您的模板中,用于将用户路由到登录或注销页面。这些都是为了方便而提供的,不是必需的。若要激活,请将以下内容添加到您的设置中:
…代码块::python
templates=[
{
…
"选项":{
"上下文处理器":[
…
"shibauth rit.context处理器.登录链接",
"shibauth-rit.context-processors.logout-u-link"、
…
]、
}、
…
、
]
代码块::bash
$python runtests.py
代码块::bash
source<;yourvirtualenv>;bin/activate
(myenv)$pip install tox
(myenv)$tox
credits
----
呈现此包时使用的工具:
*cookiecutter
*`cookiecutter djangopack`
。_ Cookiecutter:https://github.com/audreyr/Cookiecutter
。_` Cookiecutter DjangoPackage`:https://github.com/pydanny/Cookiecutter DjangoPackage
----
<0.1.0(2017-02-15)
++++++++++++++