API Reference

PASETO (Platform-Agnostic Security Tokens) for Flask applications. <https://github.com/dajiaji/flask-paseto-extended>

class flask_paseto_extended.PasetoCookieSessionInterface(paseto_version: int = 4)[source]

Bases: SessionInterface

open_session(app: Flask, request: Request) SessionMixin | None[source]

Opens a session.

save_session(app: Flask, session: SessionMixin, response: Response) None[source]

Saves a session.

class flask_paseto_extended.PasetoLoginManager(app=None, add_context_processor=True)[source]

Bases: LoginManager

init_app(app, add_context_processor=True)[source]

Configures an application. This registers an after_request call, and attaches this LoginManager to it as app.login_manager.

Parameters:
  • app (flask.Flask) – The flask.Flask object to configure.

  • add_context_processor (bool) – Whether to add a context processor to the app that adds a current_user variable to the template. Defaults to True.

class flask_paseto_extended.PasetoIssuer(app=None, add_context_processor=True)[source]

Bases: object

init_app(app, add_context_processor=True)[source]

Configures an Flask application to use this PasetoIssuer.

issue(payload: dict, kid: str = '') str[source]
class flask_paseto_extended.PasetoVerifier(app=None, add_context_processor=True)[source]

Bases: object

init_app(app, add_context_processor=True)[source]

Configures an Flask application to use this PasetoVerifier.

token_loader(cb: Callable[[Request], str]) Callable[[Request], str][source]
property token_loader_callback
verification_error_handler(cb: Callable[[None], Response]) Callable[[None], Response][source]
property verification_error_handler_callback
class flask_paseto_extended.Token(is_verified: bool, version: str = '', purpose: str = '', payload: bytes | dict = b'', footer: bytes | dict = b'', error: Exception | None = None)[source]

Bases: object

The parsed token object which can be referred as current_paseto in the views decorated by @token_required.

property is_verified: bool

If it is True, the token has been verified.

property version: str

The version of the token. It will be "v1", "v2", "v3" or "v4".

property purpose: str

The purpose of the token. It will be "local" or "public".

property header: bytes

The header of the token. It will be "<version>.<type>.". For example, "v1.local.".

property payload: bytes | dict

The payload of the token which is a decoded binary string. It’s not Base64 encoded data.

property footer: bytes | dict

The footer of the token which is a decoded binary string. It’s not Base64 encoded data.

property error: Exception | None

If is_verified is True, this property will be specified.

flask_paseto_extended.paseto_required()[source]
exception flask_paseto_extended.FlaskPasetoError[source]

Bases: Exception

Base class for all exceptions.

exception flask_paseto_extended.EncodeError[source]

Bases: FlaskPasetoError

An Exception occurred when a PASETO encoding process failed.

exception flask_paseto_extended.DecodeError[source]

Bases: FlaskPasetoError

An Exception occurred when a PASETO decoding process failed.