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

Uploaded Source

Built Distribution

whocan-0.3.4-py3-none-any.whl (6.6 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: whocan-0.3.4.tar.gz
  • Upload date:
  • Size: 5.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.13 CPython/3.9.8 Linux/5.15.0-48-generic

File hashes

Hashes for whocan-0.3.4.tar.gz
Algorithm Hash digest
SHA256 eb72e33aab87f0e0f375db86264cb907c8d2eb878f6d23d5d5a7446b580bd5bc
MD5 f09bb74a86d4d82f6c8ddbca664a8708
BLAKE2b-256 46980913dced7f666bc9342313e4792d5a5337c12d6e411a5cecabc2d361ed29

See more details on using hashes here.

File details

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

File metadata

  • Download URL: whocan-0.3.4-py3-none-any.whl
  • Upload date:
  • Size: 6.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.13 CPython/3.9.8 Linux/5.15.0-48-generic

File hashes

Hashes for whocan-0.3.4-py3-none-any.whl
Algorithm Hash digest
SHA256 fb8a121543c3481c1e9b94834d694adfd9c1035f9ba2c6b6ec22774d8bb21498
MD5 2a7ea53019d7019e5f46b2163b962a84
BLAKE2b-256 375c50e0131b6dde54296c5aacbe04710393669bcec31de3b1d3968666dbd99b

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