Usage Examples

Flask-PASETO-Extended provides three classes for each purpose.

PasetoCookieSessionInterface

Flask stores session information as a Cookie value. By using this class, you can serialize the session information as an encrypted PASETO.

PasetoCookieSessionInterface can be used as follows:

import flask
from flask_paseto_extended import PasetoCookieSessionInterface

app = flask.Flask(__name__)
app.secret_key = "super secret string"

# Use PASETO("v4" by default) for cookie sessions.
app.session_interface = PasetoCookieSessionInterface()

See examples/cookie_session.py for a sample code that actually works.

PasetoLoginManager

By using this class together with Flask-Login, you can use PASETO for remember-me tokens which is also encoded into a Cookie value.

PasetoLoginManager can be used as follows:

import flask
import flask_login

# Import PasetoLoginManager instead of flask_login.LoginManager.
from flask_paseto_extended import PasetoLoginManager

app = flask.Flask(__name__)
app.secret_key = "super secret string"

login_manager = PasetoLoginManager(app)

See examples/login_manager.py for a sample code that actually works.

PasetoManager

This class can be used for verifying public (signed) PASETO. It is suitable for using PASETO as API tokens.

T.B.D.