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.4.1.tar.gz
(5.9 kB
view hashes)
Built Distribution
whocan-0.4.1-py3-none-any.whl
(7.3 kB
view hashes)