Skip to main content

FastAPI Keycloak Extended

Project description

FastAPI Keycloak Integration


Welcome to fastapi-keycloak. This projects goal is to ease the integration of Keycloak (OpenID Connect) with Python, especially FastAPI. FastAPI is not necessary but is encouraged due to specific features. Currently, this package supports only the password and the authorization_code. However, the get_current_user() method accepts any JWT that was signed using Keycloak´s private key.

Docs

Refer to https://fastapi-keycloak.code-specialist.com/.

Adding some features:

  • KeycloakToken with more datas (refresh token, expires_in, etc.)
  • KeycloakRefreshToken represents the response after refresh token
  • KeycloakGroup with field attributes
  • Function to retrieve groups by attribute
  • Update call api GET (for users and groups) with param briefRepresentation as false. This allows to get the full representation of the object.
  • Update create_user and create_group
  • Function to refresh token
  • Override user_login to take an account more details
  • Update OIDCUser to add field from attributes

This exposes all fastapi_keycloak features under fastapi_keycloak_extended.

Keycloak version

Module tested with version of keycloak:

  • 16.0 (server uri must end with /auth )
  • 22.0
  • 26.5

Build and publish

Refer to https://packaging.python.org/en/latest/tutorials/packaging-projects/

Step:

  • python -m build
  • python -m twine upload --repository pypi dist/*

Change Log

[1.0.11] - 2026-03-20

Added

  • Add support for Keycloak 26.5
  • Add support for Python 3.14
  • Add support for FastAPI 0.135.1
  • Fix subGroups in Group representation by adding a recursive function to retrieve all subgroups (_with_children). This allows to get the full representation of the group with all its subgroups.

[1.0.10.1] - 2024-06-30

Added

  • KeycloakToken with more datas (refresh token, expires_in, etc.)
  • KeycloakRefreshToken represents the response after refresh token
  • KeycloakGroup with field attributes
  • Function to retrieve groups by attribute
  • Update call api GET (for users and groups) with param briefRepresentation as false. This allows to get the full representation of the object.
  • Update create_user and create_group
  • Function to refresh token
  • Override user_login to take an account more details
  • Update OIDCUser to add field from attributes

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

fastapi_keycloak_extended-1.0.11.tar.gz (19.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

fastapi_keycloak_extended-1.0.11-py3-none-any.whl (20.4 kB view details)

Uploaded Python 3

File details

Details for the file fastapi_keycloak_extended-1.0.11.tar.gz.

File metadata

File hashes

Hashes for fastapi_keycloak_extended-1.0.11.tar.gz
Algorithm Hash digest
SHA256 4ed20eb91edc21b20e454e326b045a7c2ed0acf3947848982e19def658197d87
MD5 d3e3a48959803647dc7f4591163cf98f
BLAKE2b-256 498331c9f7894291390bc5c649e8b1a5fe7880239adf535074ad2eb95684bc40

See more details on using hashes here.

File details

Details for the file fastapi_keycloak_extended-1.0.11-py3-none-any.whl.

File metadata

File hashes

Hashes for fastapi_keycloak_extended-1.0.11-py3-none-any.whl
Algorithm Hash digest
SHA256 d78d46f18fd1be3ea67883f2f255238c06ab37837c6a25ad848cbe66dd857352
MD5 8fae69091e888b943c45c8c53ef32b31
BLAKE2b-256 f8a1a5c2f446debedf358522b9d522ec9270f7b183f2db583f14e54d48ef936a

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page