Define The Structure

Acl

To start using miracle, instantiate the Acl object:

fromaclimportAclacl=Acl()

The Acl object keeps track of your resources and permissions
defined on them, handles grants over roles and provides utilities to
manage them. When configured, you can check the access against the
defined state.

Create

Methods from this section allow you to build the structure: list of
roles, resources and permissions.

It’s not required that you have the structure defined before you start
granting the access: the grant() method implicitly creates all
resources and permissions that were not previously defined.

Start with defining the resources and permissions on them, then you
can grant a role with the access to some permissions on a resource.

For roles, resources & permissions, any hashable objects will do.

add_role(role)

Define a role.

role: the role to define.

The role will have no permissions granted, but will appear in
get_roles().

acl.add_role('admin')acl.get_roles()# -> {'admin'}

add_resource(resource)

Define a resource.

resources: the resource to define.

The resource will have no permissions defined but will appear in
get_resources().

acl.add_resource('blog')acl.get_resources()# -> {'blog'}

add_permission(resource, permission)

Define a permission on a resource.

resource: the resource to define the permission on. Is created if
was not previously defined.

permission: the permission to define.

The defined permission is not granted to anyone, but will appear in
get_permissions(resource).