Skip to main content

WIP | COMING SOON A simple library for parsing and verifying externally issued OIDC ID tokens in fastapi.

Project description

fastapi OIDC WIP | COMING SOON

Verify and decrypt 3rd party OIDC ID tokens to protect your fastapi endpoints.

ReadTheDocs:

Source code: github

Table of Contents

  • Quick start
  • Troubleshooting
  • ReadTheDocs
  • Example

Quick Start

pip install fastapi-oidc

Verify ID Tokens Issued by Third Party

This is great if you just want to use something like Okta or google to handle your auth. All you need to do is verify the token and then you can extract user ID info from it.

from fastapi import Depends
from fastapi import FastAPI

# Set up our OIDC
from fastapi_oidc import IDToken
from fastapi_oidc import get_auth

OIDC_config = {
    "client_id": "",
    "base_authorization_server_uri": "",
    "issuer": "",
    "signature_cache_ttl": int,
}

authenticate_user: Callable = get_auth(**OIDC_config)

app = FastAPI()

@app.get("/protected")
def protected(id_token: IDToken = Depends(authenticate_user)):
    return {"Hello": "World", "user_email": id_token.email}

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 fastapi-oidc, version 0.0.4
Filename, size File type Python version Upload date Hashes
Filename, size fastapi_oidc-0.0.4-py3-none-any.whl (5.1 kB) File type Wheel Python version py3 Upload date Hashes View
Filename, size fastapi-oidc-0.0.4.tar.gz (4.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