Skip to main content

Pyramid Security Extension

Project description

A simple pyramid extension to provides contexts based authentication policy.

Usage:

from pyramid.security import remember, forget
from pyramid.authentication import AuthTktAuthenticationPolicy,

from pyramid_contextauth import authentication_policy


def includeme(config):
    config.include('pyramid_contextauth')
    config.register_authentication_policy(
        AuthTktAuthenticationPolicy('secret'),
        Context1,
    )


class Context1(object):
    pass


class Context2(object):
    pass


class Context3(object):
    pass


@authentication_policy(contexts=(Context2, Context3))
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)

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.5.tar.gz (4.3 kB view details)

Uploaded Source

File details

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

File metadata

File hashes

Hashes for pyramid_contextauth-0.5.tar.gz
Algorithm Hash digest
SHA256 be7770c00b554e22ac944e3b35133f8b22bd9a6e506a75870be71ac594145cdd
MD5 7e25f28a3add3d4fe956546ee677f312
BLAKE2b-256 f8105262e3e469a7f561e782f0716c920b791c38bbee6ce9c9cb53b2e59ef1a3

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