Keycloak API Client for integrating authentication and authorization with FastAPI
Project description
FastAPI Keycloak Integration
Introduction
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
Docs are available at https://fastapi-keycloak.code-specialist.com/.
TLDR
FastAPI Keycloak enables you to do the following things without writing a single line of additional code:
- Verify identities and roles of users with Keycloak
- Get a list of available identity providers
- Create/read/delete users
- Create/read/delete roles
- Create/read/delete/assign groups (recursive). Thanks to @fabiothz
- Assign/remove roles from users
- Implement the
passwordor theauthorization_codeflow (login/callback/logout)
Contributions
We would like encourage anyone using this package to contribute to its improvement, if anything isn't working as expected or isn't well enough documented, please open an issue or a pull request. Please note that for any code contribution tests are required.
Testing
Tests are stored and executed in ./tests. To test the package, it is necessary to use the start_infra.sh script upfront, to set up Keycloak and Postgres. We do this to avoid
artificial testing conditions that occur by mocking all the keycloak requests. The issue here is that we currently see no way to offer public testing opportunities without
significant security issues, which is why you have to run these tests locally and provide a test_coverage.xml file. The test coverage is configured in the pytest.ini and will
be created once the tests finished running (locally).
Original authors
Shoutout to the original authors of this project:
- Yannic Schröer @yannicschroeer
- Jonas Scholl @JonasScholl
This project was in the Code Specialist organization before being moved here.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file fastapi_keycloak-1.1.1.tar.gz.
File metadata
- Download URL: fastapi_keycloak-1.1.1.tar.gz
- Upload date:
- Size: 24.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
81a3166257375de73b3ef8b9d7b402733c6c9401ce1f009464fba2e53d7a1cd4
|
|
| MD5 |
d9d4d8924faabab7baa6f68f7220be8e
|
|
| BLAKE2b-256 |
f71605ca4a6f85d66b523f048a24995102add4fad2e6ec2bd67cea707ff379b2
|
Provenance
The following attestation bundles were made for fastapi_keycloak-1.1.1.tar.gz:
Publisher:
publish.yml on fastapi-keycloak/fastapi-keycloak
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
fastapi_keycloak-1.1.1.tar.gz -
Subject digest:
81a3166257375de73b3ef8b9d7b402733c6c9401ce1f009464fba2e53d7a1cd4 - Sigstore transparency entry: 633852223
- Sigstore integration time:
-
Permalink:
fastapi-keycloak/fastapi-keycloak@2eaf8ab4b1ea4663465a3b82cfe2e3e969c70495 -
Branch / Tag:
refs/tags/v1.1.1 - Owner: https://github.com/fastapi-keycloak
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@2eaf8ab4b1ea4663465a3b82cfe2e3e969c70495 -
Trigger Event:
push
-
Statement type:
File details
Details for the file fastapi_keycloak-1.1.1-py3-none-any.whl.
File metadata
- Download URL: fastapi_keycloak-1.1.1-py3-none-any.whl
- Upload date:
- Size: 19.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2d36b6e2c790e8d1e496bb86a643394a635a21ff35953ae4470c1a767b66121d
|
|
| MD5 |
23bdb2516c9085a333c2478be66ba6b1
|
|
| BLAKE2b-256 |
75f7d83ecea7f213df8f78cd8cbf31661cb296eca8fbd0feb1d558a56d064b55
|
Provenance
The following attestation bundles were made for fastapi_keycloak-1.1.1-py3-none-any.whl:
Publisher:
publish.yml on fastapi-keycloak/fastapi-keycloak
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
fastapi_keycloak-1.1.1-py3-none-any.whl -
Subject digest:
2d36b6e2c790e8d1e496bb86a643394a635a21ff35953ae4470c1a767b66121d - Sigstore transparency entry: 633852264
- Sigstore integration time:
-
Permalink:
fastapi-keycloak/fastapi-keycloak@2eaf8ab4b1ea4663465a3b82cfe2e3e969c70495 -
Branch / Tag:
refs/tags/v1.1.1 - Owner: https://github.com/fastapi-keycloak
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@2eaf8ab4b1ea4663465a3b82cfe2e3e969c70495 -
Trigger Event:
push
-
Statement type: