ilyesAj / keycloak-fastAPI-integration

This repository illustrates how we can integrate keycloak with fastAPI for authetification

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

keycloak-fastAPI-integration

This repository illustrates how we can integrate keycloak with fastAPI for authetification. This repo can be used as a template/code base for your app .

setup env

I used pipenv for my env setup.

  1. install pipenv
  2. install dependencies using pipenv install
  3. run keycloak instance using:
docker run -p 8080:8080 -v ./keycloak/keycloak_data:/opt/keycloak/data/h2 -e KEYCLOAK_ADMIN=admin -e KEYCLOAK_ADMIN_PASSWORD=admin quay.io/keycloak/keycloak:22.0.3 start-dev
  1. now you can run your fastAPI app using pipenv run python main.py

Demo

  1. access to fastAPI swagger using http://127.0.0.1:8081/docs
  2. get token using authorize
  3. make your query for /secure demo

About

This repository illustrates how we can integrate keycloak with fastAPI for authetification

License:MIT License


Languages

Language:Python 100.0%