https://github.com/xefi/python-entitled
A Simple Python Library for Authorizations
https://github.com/xefi/python-entitled
authorization permissions python
Last synced: 2 months ago
JSON representation
A Simple Python Library for Authorizations
- Host: GitHub
- URL: https://github.com/xefi/python-entitled
- Owner: xefi
- Created: 2024-03-13T09:55:31.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2025-03-03T23:49:17.000Z (3 months ago)
- Last Synced: 2025-03-30T11:09:29.721Z (2 months ago)
- Topics: authorization, permissions, python
- Language: Python
- Homepage: https://python-entitled.xefi.com/
- Size: 125 KB
- Stars: 117
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README

[](https://github.com/psf/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](https://python-entitled.xefi.com/)
## A sneak peek...
```py
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 = roleclass Resource:
def __init__(self, id: int, user: User):
self.id: str = id
self.owner: User = usermy_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 policyuser1 = User(1, "user")
resource1 = Resource(1, user1)
if client.allows("edit", user1, resource1): # Using the client to make auth decisions
...
```
## Support usSince 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](https://www.xefi.com/solutions-software/), print and cloud needs.
[Want to work with us ?](https://carriere.xefi.fr/metiers-software)