/** * Component: OIDC Configuration Step * Documentation: documentation/features/audiobookshelf-integration.md */ 'use client'; import { useState } from 'react'; import { Button } from '@/components/ui/Button'; import { Input } from '@/components/ui/Input'; interface OIDCConfigStepProps { oidcProviderName: string; oidcIssuerUrl: string; oidcClientId: string; oidcClientSecret: string; oidcAccessControlMethod: string; oidcAccessGroupClaim: string; oidcAccessGroupValue: string; oidcAllowedEmails: string; oidcAllowedUsernames: string; oidcAdminClaimEnabled: boolean; oidcAdminClaimName: string; oidcAdminClaimValue: string; oidcTested: boolean; onUpdate: (field: string, value: any) => void; onNext: () => void; onBack: () => void; } export function OIDCConfigStep({ oidcProviderName, oidcIssuerUrl, oidcClientId, oidcClientSecret, oidcAccessControlMethod, oidcAccessGroupClaim, oidcAccessGroupValue, oidcAllowedEmails, oidcAllowedUsernames, oidcAdminClaimEnabled, oidcAdminClaimName, oidcAdminClaimValue, oidcTested, onUpdate, onNext, onBack, }: OIDCConfigStepProps) { const [testing, setTesting] = useState(false); const [testResult, setTestResult] = useState<{ success: boolean; message: string; } | null>( oidcTested ? { success: true, message: 'OIDC configuration verified previously.' } : null ); const testConnection = async () => { setTesting(true); setTestResult(null); try { const response = await fetch('/api/setup/test-oidc', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ issuerUrl: oidcIssuerUrl, clientId: oidcClientId, clientSecret: oidcClientSecret, }), }); const data = await response.json(); if (response.ok && data.success) { setTestResult({ success: true, message: 'OIDC discovery successful! Provider configuration validated.', }); onUpdate('oidcTested', true); } else { setTestResult({ success: false, message: data.error || 'OIDC discovery failed', }); onUpdate('oidcTested', false); } } catch (error) { setTestResult({ success: false, message: error instanceof Error ? error.message : 'Connection test failed', }); onUpdate('oidcTested', false); } finally { setTesting(false); } }; const handleNext = () => { if (!testResult?.success) { setTestResult({ success: false, message: 'Please test the OIDC configuration before proceeding', }); return; } onNext(); }; return (
Set up single sign-on authentication with your OIDC provider (Authentik, Keycloak, etc.)
Display name for the login button (e.g., "Authentik", "Keycloak", "SSO")
The OIDC issuer URL from your identity provider configuration
The OAuth2 client ID from your OIDC provider
The OAuth2 client secret from your OIDC provider
{testResult.message}
Configuration Tips
Control who can log in to your application. This is separate from admin permissions.
{oidcAccessControlMethod === 'open' && 'Anyone who can authenticate with your OIDC provider will have access'} {oidcAccessControlMethod === 'group_claim' && 'Only users with a specific group/claim can access'} {oidcAccessControlMethod === 'allowed_list' && 'Only explicitly allowed users can access'} {oidcAccessControlMethod === 'admin_approval' && 'New users must be approved by an admin before access is granted'}
The OIDC claim field that contains group membership (usually "groups" or "roles")
Users must be in this group to access the application
Enter email addresses separated by commas
Enter usernames separated by commas
Automatically grant admin permissions based on OIDC claims (e.g., group membership). The first user will always become admin.
Automatically grant admin role to users with specific OIDC claim values
The OIDC claim field to check for admin role (usually "groups" or "roles")
Users with this value in their claim will be granted admin role
Example Configuration
In Authentik: Create a group called "readmeabook-admin", add users to it, and set "Admin Claim Value" to "readmeabook-admin"