跳转到主要内容

Pyramid安全扩展,用于注册基于多个上下文的身份验证策略。

项目描述

https://travis-ci.org/hadrien/pyramid_contextauth.png https://coveralls.io/repos/hadrien/pyramid_contextauth/badge.png https://pypip.in/d/pyramid_contextauth/badge.png

一个简单的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

  • 如果没有提供,则使用超级类CallbackAuthenticationPolicyauthenticated_userideffective_principals

0.0.1

  • 初始版本

项目详情


下载文件

下载适用于您平台的文件。如果您不确定选择哪个,请了解更多关于安装包的信息。

源分布

pyramid_contextauth-0.7.3.tar.gz (4.6 kB 查看哈希值)

上传时间

由以下支持