Easy and secure Azure Entra ID authentication for FastAPI APIs with B2C, single-tenant, and multi-tenant support.
FastAPI-Azure-Auth is a Python library that simplifies adding Azure Entra ID (formerly Azure AD) authentication to FastAPI applications. It handles the complexities of OAuth2 and OpenID Connect, allowing developers to focus on building features rather than security implementation.
Python developers building FastAPI applications that require secure authentication with Azure Entra ID, including those creating internal single-tenant APIs, customer-facing multi-tenant APIs, or B2C applications.
Developers choose this library because it abstracts away the intricacies of Azure authentication, provides a clean, type-safe interface that aligns with FastAPI's dependency injection system, and automatically integrates an 'Authorize' button into Swagger UI for easy testing.
Easy and secure implementation of Azure Entra ID (previously AD) for your FastAPI APIs 🔒 B2C, single- and multi-tenant support.
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.
Handles single-tenant, multi-tenant, and B2C setups out of the box, covering all major Azure Entra ID use cases as highlighted in the Key Features section.
Automatically adds an 'Authorize' button to Swagger UI for easy testing, demonstrated in the setup and example images in the README.
Enables scope, tenant, and role validation with minimal configuration, leveraging FastAPI's Security() or Depends() patterns as shown in the dependencies setup.
Integrates cleanly with FastAPI's dependency injection system, providing a type-safe interface that aligns with Python best practices, as stated in the Philosophy.
Tightly coupled to Azure's ecosystem; switching to another identity provider would require significant code changes and reimplementation of auth logic.
Requires precise Azure app registration and setup, with the README advising users to follow the documentation exactly first, indicating a steep learning curve for Azure novices.
Does not support simpler authentication methods like API keys or basic auth out of the box, forcing OAuth2 overhead even for basic use cases.
Relies on Azure's endpoints for token validation and config loading, which can introduce network latency and potential downtime risks compared to self-contained solutions.