qunicorn_core.api package

Subpackages

Submodules

qunicorn_core.api.flask_api_utils module

Module containing utilities for flask smorest APIs.

class qunicorn_core.api.flask_api_utils.MaBaseSchema(*, only: Optional[Union[Sequence[str], Set[str]]] = None, exclude: Union[Sequence[str], Set[str]] = (), many: bool = False, context: dict | None = None, load_only: Union[Sequence[str], Set[str]] = (), dump_only: Union[Sequence[str], Set[str]] = (), partial: Union[bool, Sequence[str], Set[str]] = False, unknown: str | None = None)

Bases: Schema

Base schema that automatically changes python snake case to camelCase in json.

on_bind_field(field_name: str, field_obj: Field)

Hook to modify a field when it is bound to the Schema.

No-op by default.

opts: SchemaOpts = <marshmallow.schema.SchemaOpts object>
class qunicorn_core.api.flask_api_utils.SecurityBlueprint(*args: Any, **kwargs)

Bases: Blueprint, JWTMixin

Blueprint that is aware of jwt tokens and how to document them.

Use this Blueprint if you want to document security requirements for your api.

qunicorn_core.api.flask_api_utils.camelcase(s: str) str

Turn a string from python snake_case into camelCase.

qunicorn_core.api.jwt module

Module containing JWT security features for the API.

class qunicorn_core.api.jwt.DemoUser(username: str)

Bases: object

This class should be replaced by the actual user class!

username: str
qunicorn_core.api.jwt.JWT = <flask_jwt_extended.jwt_manager.JWTManager object>

Basic JWT security scheme.

class qunicorn_core.api.jwt.JWTMixin

Bases: object

Extend Blueprint to add security documentation and jwt handling

require_jwt(security_scheme: Union[str, Dict[str, List[Any]]], *, fresh: bool = False, optional: bool = False, refresh_token: bool = False) Callable[[Callable[[...], RT]], Callable[[...], RT]]

Decorator validating jwt tokens and documenting them for openapi specification (only version 3…).

qunicorn_core.api.jwt.JWT_REFRESH_SCHEME = {'bearerFormat': 'JWT', 'description': 'The jwt refresh token as returned by login. Must only be used to get a new access token.', 'scheme': 'bearer', 'type': 'http'}

Security schemes to be added to the swagger.json api documentation.

qunicorn_core.api.jwt.JWT_SCHEME = {'bearerFormat': 'JWT', 'description': 'The jwt access token as returned by login or refresh.', 'scheme': 'bearer', 'type': 'http'}

JWT security scheme for JWT refresh tokens.

qunicorn_core.api.jwt.loadUserObject(jwt_header: dict, jwt_payload: dict)
qunicorn_core.api.jwt.load_user_identity(user: DemoUser)
qunicorn_core.api.jwt.on_expired_token(jwt_header: dict, jwt_payload: dict)
qunicorn_core.api.jwt.on_invalid_token(message: str)
qunicorn_core.api.jwt.on_revoked_token(jwt_header: dict, jwt_payload: dict)
qunicorn_core.api.jwt.on_stale_token(jwt_header: dict, jwt_payload: dict)
qunicorn_core.api.jwt.on_unauthorized(message: str)
qunicorn_core.api.jwt.on_user_load_error(jwt_header: dict, jwt_payload: dict)
qunicorn_core.api.jwt.register_jwt(app: Flask)

Register jwt manager with flask app.

Module contents

Module containing all API related code of the project.

class qunicorn_core.api.RootView

Bases: MethodView

get() Dict[str, str]

Get the Root API information containing the links to all versions of this api.

methods: t.ClassVar[t.Collection[str] | None] = {'GET'}

The methods this view is registered for. Uses the same default (["GET", "HEAD", "OPTIONS"]) as route and add_url_rule by default.

class qunicorn_core.api.VersionsRootSchema(*, only: Optional[Union[Sequence[str], Set[str]]] = None, exclude: Union[Sequence[str], Set[str]] = (), many: bool = False, context: dict | None = None, load_only: Union[Sequence[str], Set[str]] = (), dump_only: Union[Sequence[str], Set[str]] = (), partial: Union[bool, Sequence[str], Set[str]] = False, unknown: str | None = None)

Bases: MaBaseSchema

opts: SchemaOpts = <marshmallow.schema.SchemaOpts object>
qunicorn_core.api.register_root_api(app: Flask)

Register the API with the flask app.