The horizon.decorators ModuleΒΆ

General-purpose decorators for use with Horizon.

horizon.decorators.enforce_admin_access(view_func)[source]

Marks a view as requiring the "admin" role for access.

horizon.decorators.require_auth(view_func)[source]

Performs user authentication check.

Similar to Django’s login_required decorator, except that this throws NotAuthenticated exception if the user is not signed-in.

horizon.decorators.require_roles(view_func, required)[source]

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.

horizon.decorators.require_services(view_func, required)[source]

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.

Previous topic

The horizon.version Module

Next topic

The horizon.time Module

This Page