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.4.1.tar.gz (5.9 kB view details)

Uploaded Source

Built Distribution

whocan-0.4.1-py3-none-any.whl (7.3 kB view details)

Uploaded Python 3

File details

Details for the file whocan-0.4.1.tar.gz.

File metadata

  • Download URL: whocan-0.4.1.tar.gz
  • Upload date:
  • Size: 5.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.6.1 CPython/3.10.12 Linux/6.2.0-35-generic

File hashes

Hashes for whocan-0.4.1.tar.gz
Algorithm Hash digest
SHA256 031c84467a695f3532500bf0697beced1c8cb73cfd31abe1028f07c8374f2778
MD5 4561fc07e77dd5af7da4e372da4a20ac
BLAKE2b-256 6f31bcf06053744f905ea7d23266114fc1422ce890e9a671734f16858694f7b7

See more details on using hashes here.

File details

Details for the file whocan-0.4.1-py3-none-any.whl.

File metadata

  • Download URL: whocan-0.4.1-py3-none-any.whl
  • Upload date:
  • Size: 7.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.6.1 CPython/3.10.12 Linux/6.2.0-35-generic

File hashes

Hashes for whocan-0.4.1-py3-none-any.whl
Algorithm Hash digest
SHA256 8a4cc3d574f18345348f62c83384ec72077055a077aac5a9feb9878ff09fcbf0
MD5 670d867c6bc51549199150b867a3972f
BLAKE2b-256 0bd6dbeb0cf9cda7d8fdfa6eb8677c6dc667cea3b760e8f1720ae0309dcdb165

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