>>> import simpleacl
>>> acl = simpleacl.Acl()
>>> acl.add_role('admin')
>>> acl.add_role('member')
>>> acl.add_role('guest')
>>> acl.add_privilege('view_page')
>>> acl.add_privilege('edit_page')
>>> acl.add_privilege('delete_page')
>>> acl.allow('admin', 'all')
>>> acl.allow('member', ['view_page', 'edit_page'])
>>> acl.allow('guest', 'view_page')
>>> # set who the active role based on what the user is.
>>> acl.active_role_is('member')
>>> # check if the user is allowed to the privilege
>>> acl.is_allowed('edit_page')
True
>>> acl.is_allowed('delete_page')
False
-
Notifications
You must be signed in to change notification settings - Fork 2
Simple ACL library for Python with middleware
License
kyleterry/simpleacl-py
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
About
Simple ACL library for Python with middleware
Resources
License
Stars
Watchers
Forks
Packages 0
No packages published