Skip to main content

Django middleware for enabling anonymous permissions

Project description

Overview

freeperms provides a simple and generic way to expose an application’s permissions to anonymous users. Take a wiki app or an issue tracker for example. In one deployment it might be appropriate to require a user login to edit pages or submit tickets for bugs, but in another deployment you might want to allow anonymous editing.

Applications that take advantage of the django.contrib.auth permissions framework (outside of django.contrib.admin) can be used with freeperms so that they don’t directly need to handle delegating features to anonymous users.

Usage

Add the middleware to your settings, at the end:

MIDDLEWARE_CLASSES = (
    'freeperms.middleware.AnonymousPermissionsMiddleware'
)

Then expose the permissions you want to grant to anonymous users:

ANONYMOUS_PERMISSIONS = (
    'wiki.add_page',
    'wiki.change_page',
    'wiki.delete_page',
    'tickets.add_ticket',
    'tickets.change_ticket',
)

You can also register or unregister permissions from anywhere in your Python code:

>>> import freeperms
>>> freeperms.register('wiki.add_page')
>>> freeperms.unregister('wiki.add_page')

Settings

ANONYMOUS_USERNAME

The username to use for anonymous users.

ANONYMOUS_PERMISSIONS

A sequence of permissions in the form ‘app_label.code_name’.

Changelog

0.1

  • Initial release.

Project details


Release history Release notifications | RSS feed

This version

0.1

Download files

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

Source Distribution

django-freeperms-0.1.tar.gz (3.5 kB view hashes)

Uploaded Source

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