{"categories":[{"label":"Security","url":"https://skillfed.io/packages/category/security/3"}],"enrichment":{"capability":"FastAPI middleware that integrates Keycloak for OIDC-based authentication and authorization, validating access tokens and enforcing role-based access control on endpoints.","skillfed_tags":["keycloak","oidc","rbac"],"use_cases":["Protect FastAPI endpoints with Keycloak authentication, validating bearer tokens on each request.","Enforce role-based access control (RBAC) on specific routes using decorators without manual token inspection.","Retrieve the authenticated user object or authorization result within endpoint handlers via FastAPI dependencies.","Integrate a FastAPI microservice into an existing Keycloak-based identity infrastructure.","Map Keycloak roles to application-specific permissions through custom callback functions."],"what_it_does":"fastapi-keycloak-middleware is a FastAPI middleware that bridges your application to Keycloak for user authentication and authorization. It handles OIDC token validation (either locally using Keycloak's public key or via the token introspection endpoint), stores user identity and authorization scopes in the request context, and provides decorators and dependencies to enforce role or permission checks on individual endpoints. The package wraps python-keycloak and integrates with Starlette's authentication mechanisms, so it fits naturally into the FastAPI ecosystem.\n\nYou use it by installing the middleware into your FastAPI app, configuring it with your Keycloak server details, and then decorating endpoints or using dependency injection to require specific roles or permissions. It supports custom callbacks to fetch user objects from your database and to map Keycloak roles to application-specific permissions, making it flexible for varied authorization schemes.","worth_installing":"Yes, if you are already using Keycloak and FastAPI. The package significantly reduces boilerplate for token validation and role enforcement. However, verify the license before use in commercial settings, and note that maintenance is aging (215 days since last release)\u2014acceptable for stable middleware but monitor for security updates or breaking changes in FastAPI or Keycloak."},"id":"fastapi-keycloak-middleware","links":{"html":"https://skillfed.io/packages/fastapi-keycloak-middleware","md":"https://skillfed.io/packages/fastapi-keycloak-middleware.md","pypi":"https://pypi.org/project/fastapi-keycloak-middleware/"},"maintenance":{"status":"aging"},"meta":{"latest_release":"2026-01-11","license_spdx":null,"license_treatment":"unclear","name":"fastapi-keycloak-middleware","python_support":"supports_current","summary":"Middleware for FastAPI to authenticate a user against keycloak"},"popularity":{"monthly_downloads":78032,"position":14474,"tier":"top_15000"},"security":{"n_vulnerabilities":0},"version":"1.6.0"}
