Django CAS SSO客户端(从Django CAS继承)
hypers-cas的Python项目详细描述
#cas
[![代码运行状况](https://landscape.io/github/unistra/django-cas/master/landscape.svg?style=flat)(https://landscape.io/github/unistra/django cas/master)
django的cas客户端。这是k-state&;39;s fork of the original,它位于
https://bitbucket.org/cpcc/django-cas/overview。这个叉子是主动维护的,而且
>包括几个新功能。
>当前版本:0.8.5
>https://github.com/kstatome/django-cas
<请参阅bitbbucket上的文档:bitbbucket
>https://bitbbucket.org/cpcc/django-cas/overview
<<<
<<
>将以下内容添加到中间件如果要使用cas::
中间件类=(
'cas.middleware.casmiddleware',
管理应用程序,你应该使用'CasrAdMiNuthAuth'参数::“CasyAdmin,Auth= false [Br/]>BR/>< BR/> > 'CasyAdmin前缀''是从1.1.4版本中删除的,将在1.1.5版本中删除。
BR/> BR/>附加特征
BR/>此叉包含未在原始中发现的附加特征:
*代理主机BR/> *CAS响应回调
*CAS网关< BR/> *代理票(来自埃德蒙CREWE)
> BR/>代理主机BR/> BR/>您需要设置中间件来处理代理的使用。
> BR/>添加要使用客户端的域的“PROXYORE域”。然后添加
中间件类=(
'cas.middleware.proxy middleware',
)
此中间件需要在django“common”中间件之前添加。
创建一个回调函数,接受
proxyvalidate响应中的elementtree对象。可以有多个回调,它们可以生活在任何地方。在“settings.py”中定义
callback:
cas_response_callback s=(
'path.to.module.callbackfunction',
'anotherpath.to.module.callbackfunction2',
)并在“path/to/module.py`:
def callbackfunction(tree):
username=tree[0][0].text
user,user嫒created=user.objects.get嫒or嫒create(username=username)
profile,created=user.get嫒profile()
profile.email=tree[0][1].text
profile.position=tree[0][2].text
profile.save()
首先在设置中启用它。尝试在未显式启用此设置的情况下使用它将引发配置错误:
>然后,将“gateway”装饰器添加到一个视图:
来自cas.decorators import gateway
@gateway()
def foo(请求):
stuff
return render(请求,'foo/bar.html')
否则,将返回一个通用的“httpresponseforbidden”。
[![代码运行状况](https://landscape.io/github/unistra/django-cas/master/landscape.svg?style=flat)(https://landscape.io/github/unistra/django cas/master)
django的cas客户端。这是k-state&;39;s fork of the original,它位于
https://bitbucket.org/cpcc/django-cas/overview。这个叉子是主动维护的,而且
>包括几个新功能。
>当前版本:0.8.5
>https://github.com/kstatome/django-cas
<请参阅bitbbucket上的文档:bitbbucket
>https://bitbbucket.org/cpcc/django-cas/overview
<<<
<<
>将以下内容添加到中间件如果要使用cas::
中间件类=(
'cas.middleware.casmiddleware',
管理应用程序,你应该使用'CasrAdMiNuthAuth'参数::“CasyAdmin,Auth= false [Br/]>BR/>< BR/> > 'CasyAdmin前缀''是从1.1.4版本中删除的,将在1.1.5版本中删除。
BR/> BR/>附加特征
BR/>此叉包含未在原始中发现的附加特征:
*代理主机BR/> *CAS响应回调
*CAS网关< BR/> *代理票(来自埃德蒙CREWE)
> BR/>代理主机BR/> BR/>您需要设置中间件来处理代理的使用。
> BR/>添加要使用客户端的域的“PROXYORE域”。然后添加
中间件类=(
'cas.middleware.proxy middleware',
)
此中间件需要在django“common”中间件之前添加。
创建一个回调函数,接受
proxyvalidate响应中的elementtree对象。可以有多个回调,它们可以生活在任何地方。在“settings.py”中定义
callback:
cas_response_callback s=(
'path.to.module.callbackfunction',
'anotherpath.to.module.callbackfunction2',
)并在“path/to/module.py`:
def callbackfunction(tree):
username=tree[0][0].text
user,user嫒created=user.objects.get嫒or嫒create(username=username)
profile,created=user.get嫒profile()
profile.email=tree[0][1].text
profile.position=tree[0][2].text
profile.save()
首先在设置中启用它。尝试在未显式启用此设置的情况下使用它将引发配置错误:
>然后,将“gateway”装饰器添加到一个视图:
来自cas.decorators import gateway
@gateway()
def foo(请求):
stuff
return render(请求,'foo/bar.html')
否则,将返回一个通用的“httpresponseforbidden”。