Skip to content

About

A reference implementation for securing a FastAPI application using Keycloak.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

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

A reference implementation for securing a FastAPI application using Keycloak.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Contributors

Languages