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

Uploaded Source

Built Distribution

whocan-0.2.1-py3-none-any.whl (5.3 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for whocan-0.2.1.tar.gz
Algorithm Hash digest
SHA256 85663b1f29718de4235f5884a11ecd6ab4f188883fdce63d76d5b379f5a73bd8
MD5 fefc4f8d4db08d4e5273ddb76baed7bd
BLAKE2b-256 482fc8ad1d045f1c644f650f4d7a673543e9391c00c9e41680a738044dc9c659

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for whocan-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 b0adaf544bc13275c12f3b6ef8a78cd346e7472cde6cedf7f15fbabb2d6cdd6a
MD5 ffa6708d2640219b33601450abd1a2cf
BLAKE2b-256 62aac6d57b9692db3cdffaf69d14e1f30a3c1f17610a82a5d4bb2e1e38ec54cd

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