reshut.middleware

class AsgiAuthorizationMiddleware(apikey_token_evaluator=None, basic_token_evaluator=None, bearer_token_evaluator=None, revokation_evaluator=None)

Bases: AsgiMiddlewareWithProcessResource

ASGI-compatible Authorization Middleware

— Intercepts resource requests to apply Authorization logic.

property supports_apikey: bool
property supports_basic: bool
property supports_bearer: bool
property supports_revokation: bool
async process_resource(req, resp, resource, params)

Intercept for process_resource that evaluates authorization data in the request against authorization requirements of the resource handler.

Return type:

None

class AuthorizationEvaluator(apikey_token_evaluator=None, basic_token_evaluator=None, bearer_token_evaluator=None, revokation_evaluator=None)

Bases: object

Evaluates the authorization data in a request against the authorization requirements of a resource handler.

property supports_apikey: bool
property supports_basic: bool
property supports_bearer: bool
property supports_revokation: bool
evaluate(req, handler)

Evaluate authorization data in req against authorization requirements of handler.

Raises:
  • falcon.HTTPBadRequest – When the request has missing or invalid Authorization data.

  • falcon.HTTPUnauthorized – When claim rule checks fail.

Return type:

None

class TokenEvaluator(key)

Bases: object

Evaluates a token given an Algorithm and Key.

evaluate(token, deny_claims, allow_claims, require_claims)

Evaluate a token against the supplied claim rules.

Parameters:
  • token (str) – The token to be evaluated.

  • deny_claims (dict[str, Union[str, Callable[[Any], bool]]]) – Claim DENY rules.

  • allow_claims (dict[str, Union[str, Callable[[Any], bool]]]) – Claim ALLOW rules.

  • require_claims (dict[str, Union[str, Callable[[Any], bool]]]) – Claim REQUIRE rules.

Raises:

falcon.HTTPUnauthorized – When claim rule checks fail.

Return type:

bool

Returns:

A boolean indicating success or failure, on failure the calling code should raise an appopriate exception.

class WsgiAuthorizationMiddleware(apikey_token_evaluator=None, basic_token_evaluator=None, bearer_token_evaluator=None, revokation_evaluator=None)

Bases: WsgiMiddlewareWithProcessResource

WSGI-compatible Authorization Middleware

— Intercepts resource requests to apply Authorization logic.

property supports_apikey: bool
property supports_basic: bool
property supports_bearer: bool
property supports_revokation: bool
process_resource(req, resp, resource, params)

Intercept for process_resource that evaluates authorization data in the request against authorization requirements of the resource handler.

Return type:

None