Authentication and Authorisation auth
Global authentication/authorisation service, accessible through current.auth.
from gluon import current
auth = current.auth
User Status and Roles
- auth.s3_logged_in()
Check whether the user is logged in; attempts a HTTP Basic Auth login if not.
- Returns bool
whether the user is logged in or not
- auth.s3_has_role(role, for_pe=None, include_admin=True)
Check whether the user has a certain role.
- Parameters
role (str|int) – the UID/ID of the role
for_pe (int) – the pe_id of a realm entity
include_admin (bool) – return True for ADMIN even if role is not explicitly assigned
- Returns bool
whether the user has the role (for the realm)
Access Permissions
Access methods:
Method Name |
Meaning |
---|---|
create |
create new records |
read |
read records |
update |
update existing records |
delete |
delete records |
review |
review unapproved records |
approve |
approve records |
- auth.s3_has_permission(method, table, record_id=None, c=None, f=None):
Check whether the current user has permission to perform an action in the given context.
- Parameters
method (str) – the access method
table (str|Table) – the table
record_id (int) – the record ID
c (str) – the controller name (if not specified, current.request.controller will be used)
f (str) – the function name (if not specified, current.request.function will be used)
- Returns bool
whether the intended action is permitted