Skip to main content

A permission system modeled on the file permission system under Unix.

Project description

Cithun

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

特性

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

Example

from arclet.cithun import Permission
from arclet.cithun.builtins import System

system = System("data.json")

with system.transaction():
    AUTH_1 = system.create_role("ROLE_AUTH_1", "AUTH_1")
    AUTH_2 = system.create_role("ROLE_AUTH_2", "AUTH_2")
    AUTH_3 = system.create_role("ROLE_AUTH_3", "AUTH_3")
    AUTH_4 = system.create_role("ROLE_AUTH_4", "AUTH_4")
    AUTH_5 = system.create_role("ROLE_AUTH_5", "AUTH_5")
    system.inherit(AUTH_2, AUTH_1)
    system.inherit(AUTH_3, AUTH_2)
    system.inherit(AUTH_4, AUTH_3)
    system.inherit(AUTH_5, AUTH_4)
    alice = system.create_user("alice", "Alice")
    bob = system.create_user("bob", "Bob")
    carol = system.create_user("carol", "Carol")
    system.inherit(alice, AUTH_1)
    system.inherit(bob, AUTH_3)
    system.inherit(carol, AUTH_5)

    system.assign(AUTH_1, "app", Permission.AVAILABLE)
    system.assign(AUTH_3, "app", Permission.VISIT)
    system.assign(AUTH_5, "app.data", Permission.AVAILABLE | Permission.VISIT | Permission.MODIFY)

    system.assign(AUTH_4, "app.secret", Permission.AVAILABLE | Permission.VISIT)
    system.assign(alice, "app.data", Permission.MODIFY)
    system.assign(bob, "app.config", Permission.MODIFY)

    system.depend(alice, "app.data", AUTH_4, "app.secret", Permission.VISIT)
    system.depend(bob, "app.config", alice, "app.data",Permission.VISIT)

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

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

arclet_cithun-1.3.0-py3-none-any.whl (34.0 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: arclet_cithun-1.3.0.tar.gz
  • Upload date:
  • Size: 33.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: pdm/2.25.6 CPython/3.11.7 Windows/10

File hashes

Hashes for arclet_cithun-1.3.0.tar.gz
Algorithm Hash digest
SHA256 031685d47921b23cfbf688ad3cd9484c1fc82e831eb9e67b7622ad7cf291da61
MD5 5d1b356bd2598881dcd4da669bd62c7f
BLAKE2b-256 bd594463ca219a41fe73426b4b820c3df7d9438faed9a98a79d9a8d84b231b34

See more details on using hashes here.

File details

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

File metadata

  • Download URL: arclet_cithun-1.3.0-py3-none-any.whl
  • Upload date:
  • Size: 34.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: pdm/2.25.6 CPython/3.11.7 Windows/10

File hashes

Hashes for arclet_cithun-1.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 2d4df998708e87a8efa4deace8a6942ce25ee4c4736dee41231f86f140089b3f
MD5 36692b416bbe6afc2783ff8ed5e2e8ee
BLAKE2b-256 6a65fca61c82abfc99ce39a5dc326cc53600d195f8c9b391e63e6d9f91a573a4

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page