Library for defining and determining access.
Project description
Whocan
Library for defining and determining access.
Usage
YAML usage
statements:
- effect: allow
actions:
- workspace:Create*
- workspace:Delete*
- workspace:Get*
- workspace:List*
- workspace:Update*
resources:
- workspace:individual-${username}
import pathlib
import whocan
policy = whocan.Policy.load(pathlib.Path('path-to-file.yaml'))
policy.is_allowed(
resource='workspaces:individual-my-username',
action='workspace:DeletePage',
arguments={'username': 'my-username'},
)
# True
policy.is_allowed(
resource='workspaces:individual-a-different-user',
action='workspace:DeletePage',
arguments={'username': 'my-username'},
)
# False
Pure python usage
import whocan
statement = whocan.Statement(
resources=['workspaces:individual-${username}'],
actions=[
'workspace:Create*',
'workspace:Delete*',
'workspace:Get*',
'workspace:List*',
'workspace:Update*',
],
effect='allow',
)
policy = whocan.Policy(statements=[statement])
policy.is_allowed(
resource='workspaces:individual-my-username',
action='workspace:DeletePage',
arguments={'username': 'my-username'},
)
# True
policy.is_allowed(
resource='workspaces:individual-a-different-user',
action='workspace:DeletePage',
arguments={'username': 'my-username'},
)
# False
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
whocan-0.2.1.tar.gz
(4.5 kB
view details)
Built Distribution
File details
Details for the file whocan-0.2.1.tar.gz
.
File metadata
- Download URL: whocan-0.2.1.tar.gz
- Upload date:
- Size: 4.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.1.13 CPython/3.9.8 Linux/5.15.0-41-generic
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 85663b1f29718de4235f5884a11ecd6ab4f188883fdce63d76d5b379f5a73bd8 |
|
MD5 | fefc4f8d4db08d4e5273ddb76baed7bd |
|
BLAKE2b-256 | 482fc8ad1d045f1c644f650f4d7a673543e9391c00c9e41680a738044dc9c659 |
File details
Details for the file whocan-0.2.1-py3-none-any.whl
.
File metadata
- Download URL: whocan-0.2.1-py3-none-any.whl
- Upload date:
- Size: 5.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.1.13 CPython/3.9.8 Linux/5.15.0-41-generic
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | b0adaf544bc13275c12f3b6ef8a78cd346e7472cde6cedf7f15fbabb2d6cdd6a |
|
MD5 | ffa6708d2640219b33601450abd1a2cf |
|
BLAKE2b-256 | 62aac6d57b9692db3cdffaf69d14e1f30a3c1f17610a82a5d4bb2e1e38ec54cd |