Skip to main content
Help us improve PyPI by participating in user testing. All experience levels needed!

Basic user model, authenticator and authorizer for lribeiro.cherrypy.authorizer and mongoengine

Project description

Basic user model, authenticator and authorizer for lribeiro.cherrypy.authorizer and mongoengine

Usage:

import cherrypy

from lribeiro.cherrypy.authorizer import authorize
from lribeiro.cherrypy.authorizer.authentication import AuthControllerDefaultDispatcher

from lribeiro.cherrypy.authorizer.mongoengine.auth import authenticator, authorizer


class Root:
    @cherrypy.expose
    def index(self):
        return 'index'

    @cherrypy.expose
    @authorize
    def auth_required(self):
        return 'auth required'

    @cherrypy.expose
    @authorize({'read': 'page', 'write': 'log'})
    def authorized(self):
        return 'authorized'

    @cherrypy.expose
    @authorize({'edit': ['page', 'site']})
    def unauthorized(self):
        return 'unauthorized'

config = {
    '/': {
        'tools.sessions.on': True,
        'tools.authorizer.on': True,
        'auth.authenticator': authenticator,
        'auth.authorizer': authorizer,
        'auth.login_page': '/login'
    }
}

if __name__ == '__main__':
    root = Root()
    root.auth = AuthControllerDefaultDispatcher()

    cherrypy.quickstart(root, '/', config)

Project details


Release history Release notifications

This version
History Node

1.0.1

History Node

1.0

Download files

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

Filename, size & hash SHA256 hash help File type Python version Upload date
lribeiro.cherrypy.authorizer.mongoengine-1.0.1-py3-none-any.whl (6.2 kB) Copy SHA256 hash SHA256 Wheel py3 Sep 8, 2014
lribeiro.cherrypy.authorizer.mongoengine-1.0.1.tar.gz (3.3 kB) Copy SHA256 hash SHA256 Source None Sep 8, 2014

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging CloudAMQP CloudAMQP RabbitMQ AWS AWS Cloud computing Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page