Skip to main content

A library to make writing, enforcing and auditing your authorization policies a breeze

Project description

versions Code style: black

An authorization library for Python.

Aims to provide the tools to organize, enforce and audit your authorization layer as easily as possible, letting you focus on the essential part: the actual rules.

Documentation

For the full documentation, go here

A sneak peek...

from entitled import Policy, Client

# Some actors and resources of your application...
class User:
    def __init__(self, id: int, role: str):
        self.id: str = id
        self.role: str = role

class Resource:
    def __init__(self, id: int, user: User):
        self.id: str = id
        self.owner: User = user

my_policy = Policy[Resource]("resource") # Defining a policy for your resource

@my_policy.rule("edit")# Declaring a rule on the resource
def can_edit(
    actor: User, resource: Resource, context = None
        ) -> bool:
    return actor == resource.owner or actor.role == "admin"

client = Client()
client.register(my_policy) # Registering a policy

user1 = User(1, "user")
resource1 = Resource(1, user1)
if client.allows("edit", user1, resource1): # Using the client to make auth decisions
    ...

Support us

Since 1997, XEFI is a leader in IT performance support for small and medium-sized businesses through its nearly 200 local agencies based in France, Belgium, Switzerland and Spain. A one-stop shop for IT, office automation, software, digitalization, print and cloud needs. Want to work with us ?

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

entitled-0.4.2.tar.gz (5.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

entitled-0.4.2-py3-none-any.whl (5.4 kB view details)

Uploaded Python 3

File details

Details for the file entitled-0.4.2.tar.gz.

File metadata

  • Download URL: entitled-0.4.2.tar.gz
  • Upload date:
  • Size: 5.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.0.1 CPython/3.12.8

File hashes

Hashes for entitled-0.4.2.tar.gz
Algorithm Hash digest
SHA256 6736b49563c7e59528717c9eb3c70c8c4d0fc1487b724af9821785ad1458989e
MD5 f7ba4f3717cb1d6775c909f64eca4203
BLAKE2b-256 bb11751bc0811f36f9b606d94140a2fd2772ec43de274cbb77d78c97149f7480

See more details on using hashes here.

Provenance

The following attestation bundles were made for entitled-0.4.2.tar.gz:

Publisher: publish-to-pypi.yml on xefi/python-entitled

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file entitled-0.4.2-py3-none-any.whl.

File metadata

  • Download URL: entitled-0.4.2-py3-none-any.whl
  • Upload date:
  • Size: 5.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.0.1 CPython/3.12.8

File hashes

Hashes for entitled-0.4.2-py3-none-any.whl
Algorithm Hash digest
SHA256 bfb17340a0fd9cf0419e0fe7db857e0a4bc6cd52e48fc638c77bf46f10c7b2c5
MD5 140b946d98d5c61b1a6686ab6fd57701
BLAKE2b-256 0c26cc574852f47c2a0735bf4d9c2c280c376b2e22db3d849707b42a610985f2

See more details on using hashes here.

Provenance

The following attestation bundles were made for entitled-0.4.2-py3-none-any.whl:

Publisher: publish-to-pypi.yml on xefi/python-entitled

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

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