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.3.5.tar.gz
(5.6 kB
view details)
Built Distribution
File details
Details for the file whocan-0.3.5.tar.gz
.
File metadata
- Download URL: whocan-0.3.5.tar.gz
- Upload date:
- Size: 5.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.1.13 CPython/3.10.0 Linux/5.15.0-71-generic
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4d15d39cc2c769710b18f338b6680604650ae1b61119a820cbef69df60eb6bf0 |
|
MD5 | 86f31f71880d860ac16269ff5a531313 |
|
BLAKE2b-256 | 4ce54404af7a7f2b9f6fa152c396b3102e58514cd84c60cdb8b08f64288a30b7 |
File details
Details for the file whocan-0.3.5-py3-none-any.whl
.
File metadata
- Download URL: whocan-0.3.5-py3-none-any.whl
- Upload date:
- Size: 6.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.1.13 CPython/3.10.0 Linux/5.15.0-71-generic
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | d0e678bf253a6902736e285ce4b7d3b2bfdb762e286d43c2938829c36e84947f |
|
MD5 | 850929ab46de4924e35d3a61ef3c2408 |
|
BLAKE2b-256 | 31eaeb2321800cfb95315681741f8fd5d1e105eac984effadc2c172ac0505eea |