Pyramid安全扩展,用于注册基于多个上下文的身份验证策略。
项目描述
一个简单的Pyramid扩展,用于注册基于上下文的身份验证策略。注册的策略的Introspectables被添加到配置中,并将在debugtoolbar中显示其关联的上下文。
from pyramid.security import remember, forget
from pyramid.authentication import AuthTktAuthenticationPolicy
def includeme(config):
config.include('pyramid_contextauth')
config.register_authentication_policy(
AuthTktAuthenticationPolicy('secret'),
Context1,
)
config.register_authentication_policy(
ContextAuthenticationPolicy(),
(Context2, Context3),
)
class Context1(object):
pass
class Context2(object):
pass
class Context3(object):
pass
class ContextAuthenticationPolicy(object):
def authenticated_userid(self, request):
return unauthenticated_userid(request)
def unauthenticated_userid(self, request):
"A dummy example"
return request.POST.get('userid')
def effective_principals(self, request):
if self.unauthenticated_userid(request):
return ['User']
return []
def remember(self, request, prinicpal, **kw):
return remember(request, prinicpal, **kw)
def forget(self, request):
return forget(request)
变更日志
0.7
在每个资源线路上执行策略检查,并获取第一个获取的策略。
在travis配置的after_success中添加coverall。
移除pyramid版本约束。
0.6
移除装饰器authentication_policy:扩展不应内部实例化身份验证策略类。
0.5
将相同的上下文注册到多个策略中会引发配置错误。
当用另一个策略覆盖上下文时,注销旧策略。
更改register_authentication_policy和authentication_policy签名。
0.4
将注册的身份验证策略的Introspectables添加到配置中。
将register_context重命名为register_policy
0.3
由于ContextBasedAuthenticationPolicy.register_context现在需要配置实例作为第一个参数,因此破坏了向后兼容性。
添加配置指令config.register_authentication_policy,它接受一个上下文字符串列表。
使用注册表适配器而不是字典来注册策略。
在执行配置扫描时添加装饰器authentication_policy以注册策略。
0.2.1
调整需求文件和依赖关系。
0.2
通过添加需求文件更新依赖关系。
0.1.1
更改register_context接口,破坏了与0.0.3的兼容性
0.0.3
在includeme返回之前提交配置。
0.0.2
如果没有提供,则使用超级类CallbackAuthenticationPolicy的authenticated_userid和effective_principals。
0.0.1
初始版本
项目详情
pyramid_contextauth-0.7.3.tar.gz 的哈希值
| 算法 | 哈希摘要 | |
|---|---|---|
| SHA256 | 5bc136529a38c7cea48e55f0c93df44193865f1ad7c7ecac19827197aac54a73 |
|
| MD5 | 56f90e47d0de7800fac75d4de97fc861 |
|
| BLAKE2b-256 | acfb5dc1d3f9f70e75ffc2131dcc70730e6279fdc62fe7b0a0f05e5dac0aebf6 |