General-purpose decorators for use with Horizon.
Marks a view as requiring the "admin" role for access.
Performs user authentication check.
Similar to Django’s login_required decorator, except that this throws NotAuthenticated exception if the user is not signed-in.
Enforces role-based access controls.
Parameters: | required (list) – A tuple of role names, all of which the request user must possess in order access the decorated view. |
---|
Example usage:
from horizon.decorators import require_roles
@require_roles(['admin', 'member'])
def my_view(request):
...
Raises a NotAuthorized exception if the requirements are not met.
Enforces service-based access controls.
Parameters: | required (list) – A tuple of service type names, all of which the must be present in the service catalog in order access the decorated view. |
---|
Example usage:
from horizon.decorators import require_services
@require_services(['object-store'])
def my_swift_view(request):
...
Raises a NotFound exception if the requirements are not met.