connexion.middleware.security

Module Contents

Classes

SecurityOperation

SecurityAPI

Abstract base class for generic types.

SecurityMiddleware

Middleware to check if operation is accessible on scope.

Attributes

logger

connexion.middleware.security.logger
class connexion.middleware.security.SecurityOperation(next_app: starlette.types.ASGIApp, *, security_handler_factory: connexion.security.SecurityHandlerFactory, security: list, security_schemes: dict)
classmethod from_operation(cls, operation: connexion.operations.AbstractOperation, *, next_app: starlette.types.ASGIApp, security_handler_factory: connexion.security.SecurityHandlerFactory) SecurityOperation
async __call__(self, scope: starlette.types.Scope, receive: starlette.types.Receive, send: starlette.types.Send) None
class connexion.middleware.security.SecurityAPI(*args, auth_all_paths: bool = False, **kwargs)

Bases: connexion.middleware.abstract.RoutedAPI[SecurityOperation]

Abstract base class for generic types.

A generic type is typically declared by inheriting from this class parameterized with one or more type variables. For example, a generic mapping type might be defined as:

class Mapping(Generic[KT, VT]):
    def __getitem__(self, key: KT) -> VT:
        ...
    # Etc.

This class can then be used as follows:

def lookup_name(mapping: Mapping[KT, VT], key: KT, default: VT) -> VT:
    try:
        return mapping[key]
    except KeyError:
        return default

Base API class with only minimal behavior related to the specification.

Parameters:
  • specification – OpenAPI specification. Can be provided either as dict, or as path to file.

  • base_path – Base path to host the API.

  • resolver – Callable that maps operationID to a function

  • resolver_error_handler – Callable that generates an Operation used for handling ResolveErrors

  • arguments – Jinja arguments to resolve in specification.

  • options – New style options dictionary.

operation_cls
__slots__ = []
add_auth_on_not_found(self) None

Register a default SecurityOperation for routes that are not found.

make_operation(self, operation: connexion.operations.AbstractOperation) SecurityOperation

Create an operation of the operation_cls type.

add_paths(self) None
add_operation(self, path: str, method: str) None
classmethod __class_getitem__(cls, params)
classmethod __init_subclass__(cls, *args, **kwargs)
class connexion.middleware.security.SecurityMiddleware(app: starlette.types.ASGIApp)

Bases: connexion.middleware.abstract.RoutedMiddleware[SecurityAPI]

Middleware to check if operation is accessible on scope.

api_cls
__slots__ = []
add_api(self, specification: Union[pathlib.Path, str, dict], **kwargs) None
async __call__(self, scope: starlette.types.Scope, receive: starlette.types.Receive, send: starlette.types.Send) None

Fetches the operation related to the request and calls it.

classmethod __class_getitem__(cls, params)
classmethod __init_subclass__(cls, *args, **kwargs)
exception connexion.middleware.security.MissingSecurityOperation(status=400, title=None, detail=None, type=None, instance=None, headers=None, ext=None)

Bases: connexion.exceptions.ProblemException

Common base class for all non-exit exceptions.

This exception holds arguments that are going to be passed to the connexion.problem function to generate a proper response.

class __cause__

exception cause

class __context__

exception context

class __suppress_context__
class __traceback__
class args
to_problem(self)
__delattr__()

Implement delattr(self, name).

__dir__()

Default dir() implementation.

__eq__()

Return self==value.

__format__()

Default object formatter.

__ge__()

Return self>=value.

__getattribute__()

Return getattr(self, name).

__gt__()

Return self>value.

__hash__()

Return hash(self).

__le__()

Return self<=value.

__lt__()

Return self<value.

__ne__()

Return self!=value.

__reduce__()

Helper for pickle.

__reduce_ex__()

Helper for pickle.

__repr__()

Return repr(self).

__setattr__()

Implement setattr(self, name, value).

__setstate__()
__sizeof__()

Size of object in memory, in bytes.

__str__()

Return str(self).

__subclasshook__()

Abstract classes can override this to customize issubclass().

This is invoked early on by abc.ABCMeta.__subclasscheck__(). It should return True, False or NotImplemented. If it returns NotImplemented, the normal algorithm is used. Otherwise, it overrides the normal algorithm (and the outcome is cached).

with_traceback()

Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.