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

Uploaded Source

Built Distribution

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

Uploaded Python 3

File details

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

File metadata

  • Download URL: whocan-0.3.2.tar.gz
  • Upload date:
  • Size: 5.6 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.2.tar.gz
Algorithm Hash digest
SHA256 4cd681fe8e39e2966baab7c0a23525d4df20b9646ed9bb6941f7d630e145f696
MD5 ba8ea1ff6a3d37dfc0ceda609db0d18c
BLAKE2b-256 37d70129408690a57281676d3e5958d4a2923213031f7f8a19bfc9cc5186bb47

See more details on using hashes here.

File details

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

File metadata

  • Download URL: whocan-0.3.2-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.2-py3-none-any.whl
Algorithm Hash digest
SHA256 d9dc711db8f82992db9346d4335836453bf6276a08264b5eaea2a2d08153e411
MD5 0070484b526cd6e91a8ffbd89c9b30fb
BLAKE2b-256 f752c3dd802da402b5a489ce69a0b2ba3e4cf21dc449c1eb45df23eeefb972db

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