Skip to main content

Permission system

Project description

Cithun

仿照 Linux 下的文件权限系统实现的权限管理系统。

WIP

特性

  • 通过类似 Linux 下的文件权限系统的方式管理权限
  • 支持用户组
  • 支持用户组继承
  • 可用上下文选择此时的权限

Example

from arclet.cithun import SyncMonitor, Node, NodeState, context, PermissionExecutor

monitor = SyncMonitor()

baz = Node("/foo/bar/baz").mkdir(parents=True)
qux = (baz / "qux").touch()

with context(scope="main"):
    admin = monitor.new_group('admin', 100)
    PermissionExecutor.root.set(admin, baz, NodeState("vma"))
    
    user = monitor.new_user('cithun')
    monitor.user_inherit(user, admin)
    
    assert PermissionExecutor.root.get(user, baz).most == NodeState("vma")
    assert not PermissionExecutor.root.get(user, qux).most.available
    
    PermissionExecutor.root.set(user, qux, NodeState(7))
    assert PermissionExecutor.root.get(user, qux).most.available

    PermissionExecutor.root.set(admin, baz, NodeState("v-a"))
    try:
        PermissionExecutor(user).set(user, qux, NodeState("vm-"))
    except PermissionError as e:
        print(e)  # Permission denied as /baz/ is not modifiable

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

arclet_cithun-0.1.1.tar.gz (14.7 kB view details)

Uploaded Source

Built Distribution

arclet_cithun-0.1.1-py3-none-any.whl (15.5 kB view details)

Uploaded Python 3

File details

Details for the file arclet_cithun-0.1.1.tar.gz.

File metadata

  • Download URL: arclet_cithun-0.1.1.tar.gz
  • Upload date:
  • Size: 14.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: pdm/2.18.0 CPython/3.9.13 Windows/10

File hashes

Hashes for arclet_cithun-0.1.1.tar.gz
Algorithm Hash digest
SHA256 32f34333a9769fa5a6685961e81d084e3135f2c5e0f331dbe7d78e3fd21c89c6
MD5 ed3e0d5aa6c567b9b14b34069a85cc9a
BLAKE2b-256 4d457e245c6c19335d9d3a4c8f130b552bbbceaf7a8e6ced15fdffd51fc8c0f9

See more details on using hashes here.

File details

Details for the file arclet_cithun-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: arclet_cithun-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 15.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: pdm/2.18.0 CPython/3.9.13 Windows/10

File hashes

Hashes for arclet_cithun-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 ef973ccce81bd17bbeb53e79ea8ac649f07789b8aa67b0cf91af77194c7621e1
MD5 d4f7193dc823746f93afb9c7aa96b58b
BLAKE2b-256 531041d037bd0549df1b503e392096abd031f42c51b06c62a6fa9616b637cbcc

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