deckhand.control.middleware module

class deckhand.control.middleware.ContextMiddleware[source]

Bases: object

process_resource(req, resp, resource, params)[source]

Handle the authentication needs of the routed request.

Parameters:
  • reqfalcon request object that will be examined for method
  • resourcefalcon resource class that will be examined for authentication needs by looking at the no_authentication_methods list of http methods. By default, this will assume that all requests need authentication unless noted in this array. Note that this does not bypass any authorization checks, which will fail if the user is not authenticated.
Raises:

falcon.HTTPUnauthorized: when value of the ‘X-Identity-Status’ header is not ‘Confirmed’ and anonymous access is disallowed.

class deckhand.control.middleware.HookableMiddlewareMixin[source]

Bases: object

Provides methods to extract before and after hooks from WSGI Middleware Prior to falcon 0.2.0b1, it’s necessary to provide falcon with middleware as “hook” functions that are either invoked before (to process requests) or after (to process responses) the API endpoint code runs. This mixin allows the process_request and process_response methods from a typical WSGI middleware object to be extracted for use as these hooks, with the appropriate method signatures.

as_after_hook()[source]

Extract process_response method as “after” hook :return: after hook function

as_before_hook()[source]

Extract process_request method as “before” hook :return: before hook function

class deckhand.control.middleware.LoggingMiddleware[source]

Bases: object

process_resource(req, resp, resource, params)[source]
process_response(req, resp, resource, req_succeeded)[source]
class deckhand.control.middleware.YAMLTranslator[source]

Bases: deckhand.control.middleware.HookableMiddlewareMixin, object

Middleware for converting all responses (error and success) to YAML.

falcon error exceptions use JSON formatting and headers by default. This middleware will intercept all responses and guarantee they are YAML format.

Note

This does not include the 401 Unauthorized that is raised by keystonemiddleware which is executed in the pipeline before falcon middleware.

process_request(req, resp)[source]

Performs content type enforcement on behalf of REST verbs.

process_response(req, resp, resource, req_succeeded)[source]

Converts responses to application/x-yaml content type.