Skip to main content

Pyramid Security Extension

Project description

A simple pyramid extension to provides contexts based authentication policy. To register authentication methods:

from pyramid.security import remember, forget


class Context(object):
    pass


class ContextAuthenticationPolicy:
    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)


def includeme(config):
    from pyramid_contextauth import get_authentication_policy
    policy = get_authentication_policy(config)
    policy.register_context(Context, ContextAuthenticationPolicy)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pyramid_contextauth-0.1.1.tar.gz (3.4 kB view details)

Uploaded Source

File details

Details for the file pyramid_contextauth-0.1.1.tar.gz.

File metadata

File hashes

Hashes for pyramid_contextauth-0.1.1.tar.gz
Algorithm Hash digest
SHA256 74fffb965105b0ffb329501f9d6a092b15389201eed60493c1c31ea3e26dcf6c
MD5 993e28e4c3ee004d768425cffc4be756
BLAKE2b-256 ebc8599f89c569aed61225f80bb712fb8393efe8bdb46ce024711713b1edd7e6

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page