Skip to main content
https://secure.travis-ci.org/yourlabs/django-rules-light.png?branch=master

This is a simple alternative to django-rules. The core difference is that it uses as registry that can be modified on runtime, instead of database models.

One of the goal is to enable developpers of external apps to make rules, depend on it, while allowing a project to override rules.

Example your_app/rules_light_registry.py:

# Everybody can read a blog post (for now!):
rules_light.registry['blog.post.read'] = True

# Require authentication to create a blog post, using a shortcut:
rules_light.registry['blog.post.create'] = rules_light.is_authenticated

def is_staff_or_mine(user, rule, obj):
    return user.is_staff or obj.author == user

# But others shouldn't mess with my posts !
rules_light.registry['blog.post.update'] = is_staff_or_mine
rules_light.registry['blog.post.delete'] = is_staff_or_mine

Example your_app/views.py:

@rules_light.class_decorator
class PostDetailView(generic.DetailView):
    model = Post

@rules_light.class_decorator
class PostCreateView(generic.CreateView):
    model = Post

@rules_light.class_decorator
class PostUpdateView(generic.UpdateView):
    model = Post

@rules_light.class_decorator
class PostDeleteView(generic.DeleteView):
    model = Post

You might want to read the tutorial for more.

What’s the catch ?

The catch is that this approach does not offer any feature to get secure querysets.

This means that the developper has to:

  • think about security when making querysets,

  • override eventual external app ListViews,

Requirements

  • Maintained against Python 2.7

  • and Django 1.4+

Quick Install

  • Install module: pip install django-rules-light,

  • Add to settings.INSTALLED_APPS: rules_light,

  • Add in settings.MIDDLEWARE_CLASSES: rules_light.middleware.Middleware,

  • Add in urls.py: rules_light.autodiscover(),

You might want to read the tutorial.

There is also a lot of documentation, from the core to the tools, including pointers to debug, log and test your security.

Resources

You could subscribe to the mailing list ask questions or just be informed of package updates.

Metadata

Release files for django-rules-light 0.0.8

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for django-rules-light 0.0.8
File Size Uploaded Provenance Actions
django-rules-light-0.0.8.tar.gz 15.9 kB Without provenance Details for django-rules-light-0.0.8.tar.gz

Release files / django-rules-light-0.0.8.tar.gz

Download URL django-rules-light-0.0.8.tar.gz
Size 15.9 kB
Tags Source
SHA-256 checksum
How to use checksums
9cff7d79391ce7b7509a0e09f1ebb85563e3b00ff065dc7c88e94f76c46f18cc
BLAKE2b-256 checksum
How to use checksums
fe8f1e247f02c8d94b4ba8dc48853cc6d7b1fdb1370dbc61fe5a1750003bb39b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Security for django-rules-light 0.0.8

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page