@if (testConnectionResult) {
diff --git a/frontend/src/app/core/security/oauth2-management/authentication-settings.component.scss b/frontend/src/app/core/security/oauth2-management/authentication-settings.component.scss
index dec327697..f11b927ac 100644
--- a/frontend/src/app/core/security/oauth2-management/authentication-settings.component.scss
+++ b/frontend/src/app/core/security/oauth2-management/authentication-settings.component.scss
@@ -230,6 +230,12 @@
line-height: 1.4;
}
+.field-error {
+ font-size: 0.75rem;
+ color: var(--p-red-400);
+ line-height: 1.4;
+}
+
// Claims Section
.claims-section {
margin-top: 1rem;
@@ -251,6 +257,71 @@
margin: 0 0 0.75rem;
}
+.redirect-uri-input {
+ display: flex;
+ align-items: center;
+ width: 100%;
+ min-height: 2.25rem;
+ padding: 0.25rem 0.5rem;
+ border: 1px solid var(--p-content-border-color);
+ border-radius: 6px;
+ background: var(--p-inputtext-background);
+ transition: border-color 0.2s ease, box-shadow 0.2s ease;
+
+ &:focus-within {
+ border-color: var(--p-primary-color);
+ box-shadow: 0 0 0 1px color-mix(in srgb, var(--p-primary-color) 35%, transparent);
+ }
+
+ &.has-error {
+ border-color: var(--p-red-400);
+ }
+
+ input {
+ border: 0;
+ box-shadow: none;
+ background: transparent;
+ min-width: 11rem;
+ flex: 1 1 11rem;
+ padding: 0.25rem 0;
+
+ &:focus {
+ box-shadow: none;
+ }
+ }
+}
+
+.redirect-uri-chip-list {
+ display: flex;
+ align-items: center;
+ gap: 0.375rem;
+ flex-wrap: wrap;
+ width: 100%;
+}
+
+.redirect-uri-chip {
+ max-width: 100%;
+ flex-shrink: 1;
+ font-size: 0.8125rem;
+
+ ::ng-deep .p-chip {
+ padding: 0.1563rem 0.4063rem;
+ border-radius: 0.375rem;
+ line-height: 1.125rem;
+ }
+
+ ::ng-deep .p-chip-label {
+ overflow: hidden;
+ text-overflow: ellipsis;
+ white-space: nowrap;
+ }
+
+ ::ng-deep .p-chip-remove-icon {
+ font-size: 0.65rem;
+ opacity: 0.6;
+ }
+}
+
.claims-grid {
display: grid;
grid-template-columns: repeat(4, 1fr);
diff --git a/frontend/src/app/core/security/oauth2-management/authentication-settings.component.spec.ts b/frontend/src/app/core/security/oauth2-management/authentication-settings.component.spec.ts
index eea1d87c2..71b64203e 100644
--- a/frontend/src/app/core/security/oauth2-management/authentication-settings.component.spec.ts
+++ b/frontend/src/app/core/security/oauth2-management/authentication-settings.component.spec.ts
@@ -18,6 +18,7 @@ function createSettings(overrides: Partial
= {}): AppSettings {
oidcEnabled: false,
oidcAutoProvisionDetails: undefined,
oidcProviderDetails: undefined,
+ oidcRedirectUris: ['grimmory://oauth2-callback'],
oidcSessionDurationHours: null,
oidcGroupSyncMode: null,
oidcForceOnlyMode: false,
@@ -127,6 +128,7 @@ describe('AuthenticationSettingsComponent', () => {
name: 'given_name',
groups: '',
});
+ expect(component.mobileRedirectUris).toEqual(['grimmory://oauth2-callback']);
expect(groupMappingService.getAll).not.toHaveBeenCalled();
});
@@ -174,6 +176,7 @@ describe('AuthenticationSettingsComponent', () => {
name: 'displayName',
groups: 'memberOf',
});
+ expect(component.mobileRedirectUris).toEqual(['grimmory://oauth2-callback']);
expect(component.groupMappings).toEqual(mappings);
expect(groupMappingService.getAll).toHaveBeenCalledOnce();
});
@@ -272,6 +275,7 @@ describe('AuthenticationSettingsComponent', () => {
it('saves OIDC provider settings with the session duration only when OIDC is enabled', () => {
appSettingsService.saveSettings.mockReturnValue(of(void 0));
component.oidcProvider = completeProvider();
+ component.mobileRedirectUris = ['grimmory://oauth2-callback', 'grimmory://auth/return'];
component.oidcEnabled = false;
component.sessionDurationHours = 24;
@@ -281,6 +285,10 @@ describe('AuthenticationSettingsComponent', () => {
{
key: AppSettingKey.OIDC_PROVIDER_DETAILS,
newValue: component.oidcProvider,
+ },
+ {
+ key: AppSettingKey.OIDC_REDIRECT_URIS,
+ newValue: ['grimmory://oauth2-callback', 'grimmory://auth/return'],
}
]);
@@ -292,6 +300,10 @@ describe('AuthenticationSettingsComponent', () => {
key: AppSettingKey.OIDC_PROVIDER_DETAILS,
newValue: component.oidcProvider,
},
+ {
+ key: AppSettingKey.OIDC_REDIRECT_URIS,
+ newValue: ['grimmory://oauth2-callback', 'grimmory://auth/return'],
+ },
{
key: AppSettingKey.OIDC_SESSION_DURATION_HOURS,
newValue: 24,
@@ -299,6 +311,64 @@ describe('AuthenticationSettingsComponent', () => {
]);
});
+ it('adds a mobile redirect URI from input and clears the field', () => {
+ component.mobileRedirectUris = ['grimmory://oauth2-callback'];
+ component.mobileRedirectUriInput = 'grimmory://auth/return';
+
+ component.addMobileRedirectUriFromInput();
+
+ expect(component.mobileRedirectUris).toEqual(['grimmory://oauth2-callback', 'grimmory://auth/return']);
+ expect(component.mobileRedirectUriInput).toBe('');
+ });
+
+ it('adds the pending mobile redirect URI before saving', () => {
+ appSettingsService.saveSettings.mockReturnValue(of(void 0));
+ component.oidcProvider = completeProvider();
+ component.mobileRedirectUris = ['grimmory://oauth2-callback'];
+ component.mobileRedirectUriInput = 'grimmory://auth/return';
+
+ component.saveOidcProvider();
+
+ expect(appSettingsService.saveSettings).toHaveBeenCalledWith(expect.arrayContaining([
+ {
+ key: AppSettingKey.OIDC_REDIRECT_URIS,
+ newValue: ['grimmory://oauth2-callback', 'grimmory://auth/return'],
+ }
+ ]));
+ expect(component.mobileRedirectUriInput).toBe('');
+ });
+
+ it('removes the last mobile redirect URI when delete is pressed on an empty input', () => {
+ component.mobileRedirectUris = ['grimmory://oauth2-callback', 'grimmory://auth/return'];
+ const preventDefault = vi.fn();
+
+ component.onMobileRedirectUriKeydown({
+ key: 'Delete',
+ preventDefault,
+ } as unknown as KeyboardEvent);
+
+ expect(preventDefault).toHaveBeenCalledOnce();
+ expect(component.mobileRedirectUris).toEqual(['grimmory://oauth2-callback']);
+ });
+
+ it('surfaces backend redirect URI validation failures in the toast', () => {
+ component.oidcProvider = completeProvider();
+ component.mobileRedirectUris = ['grimmory://oauth2-callback'];
+ appSettingsService.saveSettings.mockReturnValue(
+ throwError(() => new HttpErrorResponse({
+ status: 400,
+ error: {message: 'Wildcard redirect URI must be the only value'}
+ }))
+ );
+
+ component.saveOidcProvider();
+
+ expect(messageService.add).toHaveBeenCalledWith(expect.objectContaining({
+ severity: 'error',
+ detail: 'Wildcard redirect URI must be the only value',
+ }));
+ });
+
it('saves the group sync mode and reports failures', () => {
appSettingsService.saveSettings.mockReturnValueOnce(of(void 0));
component.groupSyncMode = 'ON_LOGIN_ADDITIVE';
diff --git a/frontend/src/app/core/security/oauth2-management/authentication-settings.component.ts b/frontend/src/app/core/security/oauth2-management/authentication-settings.component.ts
index 0ebdf49c0..1be459fb7 100644
--- a/frontend/src/app/core/security/oauth2-management/authentication-settings.component.ts
+++ b/frontend/src/app/core/security/oauth2-management/authentication-settings.component.ts
@@ -1,3 +1,4 @@
+import {HttpErrorResponse} from '@angular/common/http';
import {Component, effect, inject} from '@angular/core';
import {FormsModule, ReactiveFormsModule} from '@angular/forms';
import {InputText} from 'primeng/inputtext';
@@ -18,6 +19,7 @@ import {Select} from 'primeng/select';
import {TableModule} from 'primeng/table';
import {Dialog} from 'primeng/dialog';
import {TagComponent} from '../../../shared/components/tag/tag.component';
+import {Chip} from 'primeng/chip';
@Component({
selector: 'app-authentication-settings',
@@ -38,11 +40,14 @@ import {TagComponent} from '../../../shared/components/tag/tag.component';
Select,
TableModule,
Dialog,
- TagComponent
+ TagComponent,
+ Chip
],
styleUrls: ['./authentication-settings.component.scss']
})
export class AuthenticationSettingsComponent {
+ readonly defaultMobileRedirectUri = 'grimmory://oauth2-callback';
+ readonly wildcardMobileRedirectUri = '*';
availablePermissions = [
{label: 'Upload Books', value: 'permissionUpload', selected: false, translationKey: 'perms.uploadBooks'},
{label: 'Download Books', value: 'permissionDownload', selected: false, translationKey: 'perms.downloadBooks'},
@@ -82,6 +87,8 @@ export class AuthenticationSettingsComponent {
sessionDurationHours: number | null = null;
backchannelLogoutUri = `${window.location.origin}/api/v1/auth/oidc/backchannel-logout`;
oidcForceOnlyMode = false;
+ mobileRedirectUris: string[] = [this.defaultMobileRedirectUri];
+ mobileRedirectUriInput = '';
infoItems = [
{labelKey: 'infoPanel.redirectUri', value: `${window.location.origin}/oauth2-callback`},
@@ -158,6 +165,10 @@ export class AuthenticationSettingsComponent {
this.sessionDurationHours = settings.oidcSessionDurationHours ?? null;
this.groupSyncMode = settings.oidcGroupSyncMode ?? 'DISABLED';
this.oidcForceOnlyMode = settings.oidcForceOnlyMode ?? false;
+ this.mobileRedirectUris = settings.oidcRedirectUris?.length
+ ? [...settings.oidcRedirectUris]
+ : [this.defaultMobileRedirectUri];
+ this.mobileRedirectUriInput = '';
this.oidcProvider = {
providerName: settings.oidcProviderDetails?.providerName || '',
@@ -198,10 +209,16 @@ export class AuthenticationSettingsComponent {
}
saveOidcProvider(): void {
+ this.addMobileRedirectUriFromInput();
+
const payload: {key: AppSettingKey; newValue: unknown}[] = [
{
key: AppSettingKey.OIDC_PROVIDER_DETAILS,
newValue: this.oidcProvider
+ },
+ {
+ key: AppSettingKey.OIDC_REDIRECT_URIS,
+ newValue: this.mobileRedirectUris
}
];
if (this.oidcEnabled) {
@@ -216,10 +233,10 @@ export class AuthenticationSettingsComponent {
summary: this.t.translate('settingsAuth.toast.saved'),
detail: this.t.translate('settingsAuth.toast.providerSaved')
}),
- error: () => this.messageService.add({
+ error: (error: HttpErrorResponse) => this.messageService.add({
severity: 'error',
summary: this.t.translate('common.error'),
- detail: this.t.translate('settingsAuth.toast.providerError')
+ detail: error?.error?.message || this.t.translate('settingsAuth.toast.providerError')
})
});
}
@@ -259,6 +276,36 @@ export class AuthenticationSettingsComponent {
});
}
+ addMobileRedirectUriFromInput(): void {
+ const value = this.mobileRedirectUriInput.trim();
+ if (!value) {
+ this.mobileRedirectUriInput = '';
+ return;
+ }
+
+ this.mobileRedirectUris = [...this.mobileRedirectUris, value];
+ this.mobileRedirectUriInput = '';
+ }
+
+ removeMobileRedirectUri(index: number): void {
+ this.mobileRedirectUris = this.mobileRedirectUris.filter((_, currentIndex) => currentIndex !== index);
+ }
+
+ onMobileRedirectUriKeydown(event: KeyboardEvent): void {
+ if ((event.key === 'Enter' || event.key === ',') && this.mobileRedirectUriInput.trim()) {
+ event.preventDefault();
+ this.addMobileRedirectUriFromInput();
+ return;
+ }
+
+ if ((event.key === 'Backspace' || event.key === 'Delete')
+ && !this.mobileRedirectUriInput
+ && this.mobileRedirectUris.length > 0) {
+ event.preventDefault();
+ this.removeMobileRedirectUri(this.mobileRedirectUris.length - 1);
+ }
+ }
+
saveOidcAutoProvisionSettings(): void {
const provisionDetails = {
enableAutoProvisioning: this.autoUserProvisioningEnabled,
diff --git a/frontend/src/app/shared/model/app-settings.model.ts b/frontend/src/app/shared/model/app-settings.model.ts
index e66efea79..5d41f248e 100644
--- a/frontend/src/app/shared/model/app-settings.model.ts
+++ b/frontend/src/app/shared/model/app-settings.model.ts
@@ -184,6 +184,7 @@ export interface AppSettings {
remoteAuthEnabled: boolean;
oidcEnabled: boolean;
oidcProviderDetails: OidcProviderDetails;
+ oidcRedirectUris: string[];
oidcAutoProvisionDetails: OidcAutoProvisionDetails;
maxFileUploadSizeInMb: number;
metadataProviderSettings: MetadataProviderSettings;
@@ -233,6 +234,7 @@ export enum AppSettingKey {
KOMGA_GROUP_UNKNOWN = 'KOMGA_GROUP_UNKNOWN',
OIDC_ENABLED = 'OIDC_ENABLED',
OIDC_PROVIDER_DETAILS = 'OIDC_PROVIDER_DETAILS',
+ OIDC_REDIRECT_URIS = 'OIDC_REDIRECT_URIS',
OIDC_AUTO_PROVISION_DETAILS = 'OIDC_AUTO_PROVISION_DETAILS',
MAX_FILE_UPLOAD_SIZE_IN_MB = 'MAX_FILE_UPLOAD_SIZE_IN_MB',
METADATA_PROVIDER_SETTINGS = 'METADATA_PROVIDER_SETTINGS',
diff --git a/frontend/src/app/shared/service/app-settings.service.spec.ts b/frontend/src/app/shared/service/app-settings.service.spec.ts
index f4cbf3b02..b3c025908 100644
--- a/frontend/src/app/shared/service/app-settings.service.spec.ts
+++ b/frontend/src/app/shared/service/app-settings.service.spec.ts
@@ -43,6 +43,7 @@ function buildAppSettings(overrides: Partial = {}): AppSettings {
remoteAuthEnabled: publicSettings.remoteAuthEnabled,
oidcEnabled: publicSettings.oidcEnabled,
oidcProviderDetails: publicSettings.oidcProviderDetails,
+ oidcRedirectUris: ['grimmory://oauth2-callback'],
oidcAutoProvisionDetails: {
enableAutoProvisioning: false,
allowLocalAccountLinking: false,
diff --git a/frontend/src/i18n/en/settings-auth.json b/frontend/src/i18n/en/settings-auth.json
index 2db93d1d4..ce149fd21 100644
--- a/frontend/src/i18n/en/settings-auth.json
+++ b/frontend/src/i18n/en/settings-auth.json
@@ -47,6 +47,15 @@
"backchannelLogoutUri": "Back-Channel Logout URI",
"backchannelLogoutHint": "Configure this URI in your OIDC provider to enable server-initiated session revocation."
},
+ "mobileRedirectUris": {
+ "title": "Mobile Redirect URIs",
+ "description": "Whitelist the mobile redirect URIs your OIDC flow is allowed to return to.",
+ "label": "Allowed Mobile Redirect URIs",
+ "placeholder": "Add a redirect URI or *",
+ "hintPrefix": "The default redirect URI is",
+ "hintSuffix": "To allow any URI, just use",
+ "removeLabel": "Remove {{uri}}"
+ },
"provisioning": {
"sectionTitle": "User Provisioning",
"sectionDesc": "Configure how new OIDC users are created and what permissions they receive.",