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

Uploaded Source

Built Distribution

whocan-0.2.3-py3-none-any.whl (5.4 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for whocan-0.2.3.tar.gz
Algorithm Hash digest
SHA256 53728ff791b147f29cbdb487b3e7ebd6eeed421e9e8883928ab599ffc8c092db
MD5 f2f5b585f7f97a6d5e604c3836db0099
BLAKE2b-256 0379351f679a2e4e2c594e4b4701f574188d73ed78ba53cea597626d8abde347

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for whocan-0.2.3-py3-none-any.whl
Algorithm Hash digest
SHA256 410ffa4b2d49227372a1650ce5ffb0414f8ba485bfb2e859f8b51adf317f9700
MD5 c312418732685bf64b69476139bbb994
BLAKE2b-256 798036c4c23a2ee13ac29302310fa8b7fd5160c85f69fe9a2534f2e148f03f17

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