fix login that it not shows 500 when authentik is to slow
Build and Push Docker Container / build-and-push (push) Successful in 1m51s

This commit is contained in:
2026-04-01 21:17:01 +02:00
parent 7b77387182
commit d9b7c88ccf
+10
View File
@@ -20,9 +20,12 @@ REDIRECT_URI_SCHEME = os.getenv('REDIRECT_URI_SCHEME', 'http')
async def get_oidc_metadata():
async with httpx.AsyncClient() as client:
try:
response = await client.get(OIDC_METADATA_URL)
response.raise_for_status()
return response.json()
except httpx.ReadTimeout:
return await get_oidc_metadata()
@auth_login_bp.route('/login', methods=['GET'])
@auth_login_bp.route('/auth', methods=['GET'])
@@ -87,12 +90,18 @@ async def auth_callback():
)
# Exchange code for token
token_fetched = False
while not token_fetched:
try:
token = await client.fetch_token(
metadata['token_endpoint'],
code=code,
grant_type='authorization_code'
)
await logger.debug(f'Auth Callback | token: {token}')
token_fetched = True
except httpx.ReadTimeout:
pass
# Decode ID token
id_token = token.get('id_token')
@@ -126,6 +135,7 @@ async def auth_callback():
return await render_template('views/api/token.htm', error="You don't have Permissions to Access this API"), 403
session['user'] = claims
response = await make_response(redirect(url_for('side_main.index')))
response.set_cookie('auth_id', '', max_age=0, httponly=True, secure=True, samesite='Lax')
return response