From fa32e33ea52a61118ca71b7932c8832a7ef8c78f Mon Sep 17 00:00:00 2001 From: adityachandelgit <> Date: Wed, 14 May 2025 14:17:27 -0600 Subject: [PATCH] - Silently fallback to local login if OIDC config is incorrect --- booklore-ui/src/app/auth-initializer.ts | 25 +++++++++++++------ .../authentication-settings.component.html | 4 +-- 2 files changed, 19 insertions(+), 10 deletions(-) diff --git a/booklore-ui/src/app/auth-initializer.ts b/booklore-ui/src/app/auth-initializer.ts index 72a02ef16..af809db5c 100644 --- a/booklore-ui/src/app/auth-initializer.ts +++ b/booklore-ui/src/app/auth-initializer.ts @@ -21,9 +21,9 @@ export function initializeAuthFactory() { scope: 'openid profile email offline_access', redirectUri: window.location.origin + '/oauth2-callback', responseType: 'code', - showDebugInformation: true, - requireHttps: false, - strictDiscoveryDocumentValidation: false, + showDebugInformation: false, + requireHttps: true, + strictDiscoveryDocumentValidation: true, }); oauthService.events @@ -36,11 +36,20 @@ export function initializeAuthFactory() { authService.saveOidcTokens(accessToken, refreshToken ?? ''); }); - oauthService.loadDiscoveryDocumentAndTryLogin().then(() => { - oauthService.setupAutomaticSilentRefresh(); - websocketInitializer(authService); - resolve(); - }); + oauthService.loadDiscoveryDocumentAndTryLogin() + .then(() => { + oauthService.setupAutomaticSilentRefresh(); + websocketInitializer(authService); + resolve(); + }) + .catch(err => { + console.error( + 'OIDC initialization failed: Unable to complete OpenID Connect discovery or login. ' + + 'This may be due to an incorrect issuer URL, client ID, or network issue. ' + + 'Falling back to local login. Details:', err + ); + resolve(); + }); } else { resolve(); } diff --git a/booklore-ui/src/app/oauth2-management/authentication-settings.component.html b/booklore-ui/src/app/oauth2-management/authentication-settings.component.html index 425f5cb5a..e39136916 100644 --- a/booklore-ui/src/app/oauth2-management/authentication-settings.component.html +++ b/booklore-ui/src/app/oauth2-management/authentication-settings.component.html @@ -77,7 +77,7 @@ pInputText id="issuerUri" [(ngModel)]="oidcProvider.issuerUri" - placeholder="e.g. https://auth.example.com/realms/myrealm" + placeholder="e.g. https://authentik.your-domain.com/application/o/booklore/" class="w-full"/>
@@ -86,7 +86,7 @@ pInputText id="jwksUrl" [(ngModel)]="oidcProvider.jwksUrl" - placeholder="e.g. https://auth.example.com/realms/myrealm/protocol/openid-connect/certs" + placeholder="e.g. https://authentik.your-domain.com/application/o/booklore/jwks/" class="w-full"/>