Releases: intility/fastapi-azure-auth
Releases · intility/fastapi-azure-auth
3.1.0 - Trio support
3.0.3 - Fix syntax for FastAPI version
3.0.2 - Loosen FastAPI version requirement
3.0.1 - Cryptography requirement upgrade and documentation fixes
3.0.0 - Rewrite, v2 token support, single- and multi-tenant support
This release contains breaking changes for how to setup your application, but also a bunch of new features.
The new documentation contains a full tutorial on how to configure Azure AD and FastAPI for both single- and multi-tenant applications.
Features
- Add
v2
token support (and default) for single-tenant applications. - Full multi-tenant support
- Option to provide a callable which returns valid
iss
(issuers), for those who has multi-tenant applications, but only for specific tenants
- Option to provide a callable which returns valid
Other
- User object is reworked, now also contain
access_token
for easier Azure Graph implementation - Add support for denying requests with wrong scopes, when
Securiy()
is used (an alternativ toDepends()
) - Moved
InvalidAuth
toexceptions.py
- Documentation for everything from role checks, guest users, locking down tenants etc.
- No longer inheriting
OAuth2AuthorizationCodeBearer
, solving mypy errors. - Rename
provider_config.py
toopenid_config.py
andProviderConfig()
toOpenIdConfig()
- Removal of pre-instance of
provider_config
due to OpenAPI authorization URL issues. This is now instanced onSingleTenantAzureAuthorizationCodeBearer
orMultiTenantAzureAuthorizationCodeBearer
.
3.0.0-rc1 - Release candidate
Release candidate for 3.0.0
.
Release notes will be written for the actual release.
2.0.1 - Make `upn` an optional field in the `User` model
2.0.0 - `FastAPI` application is no longer passed to the `AzureAuthorizationCodeBearer`
Breaking changes
- Removal of
app
parameter fromAzureAuthorizationCodeBearer
AzureAuthorizationCodeBearer
now returns aUser
object instead of a dictionary with claims
Other
- Documentation on how to create your own dependencies for checking
roles
,scp
or similar - Add docs on how to load provider config on startup, it is no longer auto-loaded by
AzureAuthorizationCodeBearer
Upgrade guide from v1 to v2
I strongly suggest reading the entire README.md
again, as it's a bit more verbose compared to before.
With that said, these are the steps you have to do in order to bump from v1 to v2:
- Remove
app=app
from yourAzureAuthorizationCodeBearer()
inmain.py
. - If you have a
dependencies.py
file or similar, move theazure_scheme = AzureAuthorizationCodeBearer( ... )
to that file.
2.1. In yourmain.py
, importazure_scheme
fromdependencies.py
- In your
main.py
file, load the provider config on startup:
@app.on_event('startup')
async def load_config() -> None:
"""
Load config on startup.
"""
await provider_config.load_config()
- If you've overwritten the default
tenant_id
, you can also add that toload_config()
@app.on_event('startup')
async def load_config() -> None:
"""
Load config on startup.
"""
+ provider_config.tenant_id = 'my-tenant-id'
await provider_config.load_config()