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

Uploaded Source

Built Distribution

whocan-0.4.0-py3-none-any.whl (7.1 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: whocan-0.4.0.tar.gz
  • Upload date:
  • Size: 5.8 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

Hashes for whocan-0.4.0.tar.gz
Algorithm Hash digest
SHA256 e814a53fcdb123739c1713d047960222ac8bde69269c84fa4b8847eb68e99ba3
MD5 3a8ce529fc5964eeaa39966010dcef86
BLAKE2b-256 9b7b5bb5fb026a3221d71bbd14547bbe591b77fecc7352ecaae30dba0ec07129

See more details on using hashes here.

File details

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

File metadata

  • Download URL: whocan-0.4.0-py3-none-any.whl
  • Upload date:
  • Size: 7.1 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

Hashes for whocan-0.4.0-py3-none-any.whl
Algorithm Hash digest
SHA256 5e2a9bc90942766a3cb9a27410fe7974f240a57375bfc847c31c648f58714bc6
MD5 3dfe91cf922983e5ae6574590a025d5b
BLAKE2b-256 5f435d6490fb690f544a7863024b22f9aabbec3944e816dba6c7795e8914bb0d

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