Main Types¶
- class flaskext.principal.Permission(*needs)¶
Represents needs, any of which must be present to access a resource
Parameters: - needs – The needs for this permission
- issubset(other)¶
Whether this permission needs are a subset of another
Parameters: - other – The other permission
- needs¶
A set of needs, any of which must be present in an identity to have access.
- require()¶
Create a principal for this permission.
The principal may be used as a context manager, or a decroator.
- union(other)¶
Create a new permission with the requirements of the union of this and other.
Parameters: - other – The other permission
- class flaskext.principal.Identity(name, auth_type='')¶
Represent the user’s identity.
Parameters: - name – The username
- auth_type – The authentication type used to confirm the user’s identity.
The identity is used to represent the user’s identity in the system. This object is created on login, or on the start of the request as loaded from the user’s session.
Once loaded it is sent using the identity-loaded signal, and should be populated with additional required information.
Needs that are provided by this identity should be added to the provides set after loading.
- can(permission)¶
Whether the identity has access to the permission.
Parameters: - permission – The permission to test provision for.
- provides¶
A set of needs provided by this user
Provisions can be added using the add method, for example:
identity = Identity('ali') identity.provides.add(('role', 'admin'))
- class flaskext.principal.AnonymousIdentity¶
An anonymous identity
Attr name: “anon”
- class flaskext.principal.Principal(permission)¶
The context of an identity for a permission.
Note
The principal is usually created by the flaskext.Permission.require method call for normal use-cases.
The principal behaves as either a context manager or a decorator. The permission is checked for provision in the identity, and if available the flow is continued (context manager) or the function is executed (decorator).
- can()¶
Whether the identity has access to the permission
- identity¶
The identity of this principal
- permission¶
The permission of this principal
- flaskext.principal.set_identity(identity)¶
Set the identity in the session
