Skip to main content

Run oidc token verification

Project description

Flask OIDC Verifier

Implements implicit OIDC verification for Flask, similar to drf-oidc-auth in Django.

Quickstart

Assumptions: tokens are passed via headers of the form Authorization: Bearer $YOUR_TOKEN. These can be changed in the settings

  1. Install with pip install flask-oidc-verifier
  2. Add the following to your flask config (at a minimum, see the Config section for more options). Replace the values with relevant config values:
   class Config():
   ...
   OIDC_ENDPOINT = "https://my.oidc.endpoint"
   OIDC_AUDIENCES = ("MY_AUDIENCES", )
   ...
  1. Initialize the authentication provider:
from flask import Flask
from flask_oidc_verifier.decorators import JWTVerification
from typing import Dict, Any


app = Flask(__name__)


# Define a callback for what to do with the verified JWT contents
def on_verified(d: Dict[Any, Any]) -> None:
    # get_or_create_user
    ...

auth = auth.init_app(app, on_verified=on_verified)
  1. Use as a decorator:
@app.route("/protected/<path:filename>")
@auth.jwt_required
def protected_file(filename: str) -> None:
    return send_from_directory("protected", filename)

Config

TODO

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for flask-oidc-verifier, version 0.0.5
Filename, size File type Python version Upload date Hashes
Filename, size flask_oidc_verifier-0.0.5-py3-none-any.whl (8.2 kB) File type Wheel Python version py3 Upload date Hashes View
Filename, size flask_oidc_verifier-0.0.5.tar.gz (5.5 kB) File type Source Python version None Upload date Hashes View

Supported by

Pingdom Pingdom Monitoring Google Google Object Storage and Download Analytics Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page