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.7.tar.gz
(5.7 kB
view details)
Built Distribution
File details
Details for the file whocan-0.3.7.tar.gz
.
File metadata
- Download URL: whocan-0.3.7.tar.gz
- Upload date:
- Size: 5.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.6.1 CPython/3.10.12 Linux/6.2.0-34-generic
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0e3c0a9a9e4c3869f045a83064460bdae9b0fb3207b45172137436d6d933e99e |
|
MD5 | 23b98eedd237f51370b75d968f60a8d9 |
|
BLAKE2b-256 | 85f3a66a95480af8af528e4662cb9793377c3a742dcd64cf949e519bcfee76d1 |
File details
Details for the file whocan-0.3.7-py3-none-any.whl
.
File metadata
- Download URL: whocan-0.3.7-py3-none-any.whl
- Upload date:
- Size: 7.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.6.1 CPython/3.10.12 Linux/6.2.0-34-generic
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6efe934f586de591ae0fa2585bb261cb2f31f938babc9e4d443ce7a657e9daf4 |
|
MD5 | 39fc7e0d29e2a6870645d73f68a11de1 |
|
BLAKE2b-256 | 7645b6f36017fb7748ce24a22cecca1b21286796de1b867c44e2c758bf056e28 |