Skip to main content

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


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)

Uploaded Source

Built Distribution

whocan-0.3.5-py3-none-any.whl (6.5 kB view details)

Uploaded Python 3

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

Hashes for whocan-0.3.5.tar.gz
Algorithm Hash digest
SHA256 4d15d39cc2c769710b18f338b6680604650ae1b61119a820cbef69df60eb6bf0
MD5 86f31f71880d860ac16269ff5a531313
BLAKE2b-256 4ce54404af7a7f2b9f6fa152c396b3102e58514cd84c60cdb8b08f64288a30b7

See more details on using hashes here.

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

Hashes for whocan-0.3.5-py3-none-any.whl
Algorithm Hash digest
SHA256 d0e678bf253a6902736e285ce4b7d3b2bfdb762e286d43c2938829c36e84947f
MD5 850929ab46de4924e35d3a61ef3c2408
BLAKE2b-256 31eaeb2321800cfb95315681741f8fd5d1e105eac984effadc2c172ac0505eea

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page