Skip to content

w1nte/fastapi-keycloak-minimal-example

Repository files navigation

🚀 FastAPI + Keycloak Minimal Example

A minimal working example demonstrating how to secure a FastAPI application using Keycloak for authentication and authorization via OAuth2/OpenID Connect.


📦 Getting Started

Prerequisites

🔧 Start the Project

docker compose up

This will spin up both Keycloak and the FastAPI app.

🔐 Keycloak Configuration

  1. Open Keycloak at http://localhost:8080
    Login with:
  • Username: admin
  • Password: admin
  1. Create a new client with the following settings:
  • Client ID: example
  • Valid Redirect URIs: http://localhost:5001/
  • Post Logout Redirect URIs: http://localhost:5001/
  • Web Origins: *
  • Enable Standard Flow
  • PKCE Method: S256

🚀 Access the App

Once everything is running:

The app should redirect you to Keycloak for login and then back to the FastAPI app once authenticated.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors