Add provider id field, relaxing name

This commit is contained in:
phil 2025-01-10 00:09:12 +01:00
parent 57041e9233
commit 170e663ee8
4 changed files with 10 additions and 9 deletions

View file

@ -51,7 +51,7 @@ _providers = {}
for provider in settings.oidc.providers:
authlib_oauth.register(
name=provider.name,
name=provider.id,
server_metadata_url=provider.openid_configuration,
client_kwargs={
"scope": "openid email offline_access profile roles",
@ -62,10 +62,10 @@ for provider in settings.oidc.providers:
# update_token=update_token,
# client_id="some-client-id", # if enabled, authlib will also check that the access token belongs to this client id (audience)
)
fastapi_providers[provider.name] = OpenIdConnect(
fastapi_providers[provider.id] = OpenIdConnect(
openIdConnectUrl=provider.openid_configuration
)
_providers[provider.name] = provider
_providers[provider.id] = provider
# Endpoints for the login / authorization process
@ -73,7 +73,7 @@ for provider in settings.oidc.providers:
@app.get("/login/{oidc_provider_id}")
async def login(request: Request, oidc_provider_id: str) -> RedirectResponse:
"""Login with the provider name,
"""Login with the provider id,
by giving the browser a redirect to its authorize page.
After successful authentification, the provider replies with an encrypted
auth token that only we can decode and contains userinfo,