Sample implementation for OIDC with FastAPI and Authlib.
This is a sample implementation for OpenID Connect with Python, FastAPI and Authlib.
It uses...
- Authorization Code Flow
- Cookie to store ID token
- HttpOnly: true, SameSite: Lax, Secure: true
- nginx for path routing
Related post (Japanese): よくあるSPA+API構成でのOpenID Connectクライアント実装
- docker / docker compose
- Some OpenID Provider
- Set Redirect URI (Allowed Callback URLs) as
http://localhost:8080/api/auth
- Set Redirect URI (Allowed Callback URLs) as
Fill .env
with each value below.
- Client ID
- Client Secret
- OpenID Configuration Endpoint
docker compose build
docker compose up
Open http://localhost:8080/ in your browser and try it out!