The most complete open-source travel planner: real-time collaboration, bookings, budgets, packing lists, journals, offline PWA, SSO and an AI-ready MCP server, with planet-wide place search and routing built in.
TypeScript budget-trackercollaborativedockeritinerarymcp-serveroffline-firstopen-sourceopenstreetmappacking-listpwareal-timeself-hostedselfhostedtraveltravel-apptravel-journaltravel-plannertripitwanderlog
feat: add OIDC-only mode to disable password authentication
Stephen Wheet9f8d3f8d99fd
diff --git a/client/src/i18n/translations/de.ts b/client/src/i18n/translations/de.tsindex 2bec291a1..0421e1ff4 100644--- a/client/src/i18n/translations/de.ts+++ b/client/src/i18n/translations/de.ts@@ -206,6 +206,7 @@ const de: Record<string, string> = {'login.oidc.invalidState': 'Ungültige Sitzung. Bitte erneut versuchen.','login.demoFailed': 'Demo-Login fehlgeschlagen','login.oidcSignIn': 'Anmelden mit {name}',+ 'login.oidcOnly': 'Passwort-Authentifizierung ist deaktiviert. Bitte melde dich über deinen SSO-Anbieter an.','login.demoHint': 'Demo ausprobieren — ohne Registrierung',// Register@@ -285,6 +286,8 @@ const de: Record<string, string> = {'admin.oidcIssuer': 'Issuer URL','admin.oidcIssuerHint': 'Die OpenID Connect Issuer URL des Anbieters. z.B. https://accounts.google.com','admin.oidcSaved': 'OIDC-Konfiguration gespeichert',+ 'admin.oidcOnlyMode': 'Passwort-Authentifizierung deaktivieren',+ 'admin.oidcOnlyModeHint': 'Wenn aktiviert, ist nur SSO-Login erlaubt. Passwort-Login und Registrierung werden blockiert.',// File Types'admin.fileTypes': 'Erlaubte Dateitypen',diff --git a/client/src/i18n/translations/en.ts b/client/src/i18n/translations/en.tsindex 73c42a2e1..33c828ae4 100644--- a/client/src/i18n/translations/en.ts+++ b/client/src/i18n/translations/en.ts@@ -206,6 +206,7 @@ const en: Record<string, string> = {'login.oidc.invalidState': 'Invalid session. Please try again.','login.demoFailed': 'Demo login failed','login.oidcSignIn': 'Sign in with {name}',+ 'login.oidcOnly': 'Password authentication is disabled. Please sign in using your SSO provider.','login.demoHint': 'Try the demo — no registration needed',// Register@@ -285,6 +286,8 @@ const en: Record<string, string> = {'admin.oidcIssuer': 'Issuer URL','admin.oidcIssuerHint': 'The OpenID Connect Issuer URL of the provider. e.g. https://accounts.google.com','admin.oidcSaved': 'OIDC configuration saved',+ 'admin.oidcOnlyMode': 'Disable password authentication',+ 'admin.oidcOnlyModeHint': 'When enabled, only SSO login is permitted. Password-based login and registration are blocked.',// File Types'admin.fileTypes': 'Allowed File Types',diff --git a/client/src/pages/AdminPage.tsx b/client/src/pages/AdminPage.tsxindex 8f72c836b..23369ef6c 100644--- a/client/src/pages/AdminPage.tsx+++ b/client/src/pages/AdminPage.tsx@@ -39,6 +39,7 @@ interface OidcConfig {client_secret: stringclient_secret_set: booleandisplay_name: string+ oidc_only: boolean}interface UpdateInfo {@@ -72,7 +73,7 @@ export default function AdminPage(): React.ReactElement {const [createForm, setCreateForm] = useState<{ username: string; email: string; password: string; role: string }>({ username: '', email: '', password: '', role: 'user' })// OIDC config- const [oidcConfig, setOidcConfig] = useState<OidcConfig>({ issuer: '', client_id: '', client_secret: '', client_secret_set: false, display_name: '' })+ const [oidcConfig, setOidcConfig] = useState<OidcConfig>({ issuer: '', client_id: '', client_secret: '', client_secret_set: false, display_name: '', oidc_only: false })const [savingOidc, setSavingOidc] = useState<boolean>(false)// Registration toggle@@ -715,11 +716,31 @@ export default function AdminPage(): React.ReactElement {className="w-full px-3 py-2 border border-slate-300 rounded-lg text-sm focus:ring-2 focus:ring-slate-400 focus:border-transparent"/></div>+ {/* OIDC-only mode toggle */}+ <div className="flex items-center justify-between pt-2 border-t border-slate-100">+ <div>+ <p className="text-sm font-medium text-slate-700">{t('admin.oidcOnlyMode')}</p>+ <p className="text-xs text-slate-400 mt-0.5">{t('admin.oidcOnlyModeHint')}</p>+ </div>+ <button+ onClick={() => setOidcConfig(c => ({ ...c, oidc_only: !c.oidc_only }))}+ className={`relative inline-flex h-6 w-11 items-center rounded-full transition-colors flex-shrink-0 ml-4 ${+ oidcConfig.oidc_only ? 'bg-slate-900' : 'bg-slate-300'+ }`}+ >+ <span+ className={`inline-block h-4 w-4 transform rounded-full bg-white transition-transform ${+ oidcConfig.oidc_only ? 'translate-x-6' : 'translate-x-1'+ }`}+ />+ </button>+ </div>+<buttononClick={async () => {setSavingOidc(true)try {- const payload = { issuer: oidcConfig.issuer, client_id: oidcConfig.client_id, display_name: oidcConfig.display_name }+ const payload: Record<string, unknown> = { issuer: oidcConfig.issuer, client_id: oidcConfig.client_id, display_name: oidcConfig.display_name, oidc_only: oidcConfig.oidc_only }if (oidcConfig.client_secret) payload.client_secret = oidcConfig.client_secretawait adminApi.updateOidc(payload)toast.success(t('admin.oidcSaved'))diff --git a/client/src/pages/LoginPage.tsx b/client/src/pages/LoginPage.tsxindex 5ed542389..f846ad90a 100644--- a/client/src/pages/LoginPage.tsx+++ b/client/src/pages/LoginPage.tsx@@ -12,6 +12,7 @@ interface AppConfig {demo_mode: booleanoidc_configured: booleanoidc_display_name?: string+ oidc_only_mode: boolean}export default function LoginPage(): React.ReactElement {@@ -104,7 +105,10 @@ export default function LoginPage(): React.ReactElement {}}- const showRegisterOption = appConfig?.allow_registration || !appConfig?.has_users+ const showRegisterOption = (appConfig?.allow_registration || !appConfig?.has_users) && !appConfig?.oidc_only_mode++ // In OIDC-only mode, show a minimal page that redirects directly to the IdP+ const oidcOnly = appConfig?.oidc_only_mode && appConfig?.oidc_configuredconst inputBase: React.CSSProperties = {width: '100%', padding: '11px 12px 11px 40px', border: '1px solid #e5e7eb',@@ -434,6 +438,34 @@ export default function LoginPage(): React.ReactElement {</div><div style={{ background: 'white', borderRadius: 20, border: '1px solid #e5e7eb', padding: '36px 32px', boxShadow: '0 2px 16px rgba(0,0,0,0.06)' }}>+ {oidcOnly ? (+ <>+ <h2 style={{ margin: '0 0 4px', fontSize: 22, fontWeight: 800, color: '#111827' }}>{t('login.title')}</h2>+ <p style={{ margin: '0 0 24px', fontSize: 13.5, color: '#9ca3af' }}>{t('login.oidcOnly')}</p>+ {error && (+ <div style={{ padding: '10px 14px', background: '#fef2f2', border: '1px solid #fecaca', borderRadius: 10, fontSize: 13, color: '#dc2626', marginBottom: 16 }}>+ {error}+ </div>+ )}+ <a href="/api/auth/oidc/login"+ style={{+ width: '100%', padding: '12px',+ background: '#111827', color: 'white',+ border: 'none', borderRadius: 12,+ fontSize: 14, fontWeight: 700, cursor: 'pointer',+ fontFamily: 'inherit', display: 'flex', alignItems: 'center', justifyContent: 'center', gap: 8,+ textDecoration: 'none', transition: 'all 0.15s',+ boxSizing: 'border-box',+ }}+ onMouseEnter={(e: React.MouseEvent<HTMLAnchorElement>) => { e.currentTarget.style.background = '#1f2937' }}+ onMouseLeave={(e: React.MouseEvent<HTMLAnchorElement>) => { e.currentTarget.style.background = '#111827' }}+ >+ <Shield size={16} />+ {t('login.oidcSignIn', { name: appConfig?.oidc_display_name || 'SSO' })}+ </a>+ </>+ ) : (+ <><h2 style={{ margin: '0 0 4px', fontSize: 22, fontWeight: 800, color: '#111827' }}>{mode === 'register' ? (!appConfig?.has_users ? t('login.createAdmin') : t('login.createAccount')) : t('login.title')}</h2>@@ -524,10 +556,11 @@ export default function LoginPage(): React.ReactElement {</button></p>)}+ </>)}</div>- {/* OIDC / SSO login button */}- {appConfig?.oidc_configured && (+ {/* OIDC / SSO login button (only when OIDC is configured but not in oidc-only mode) */}+ {appConfig?.oidc_configured && !oidcOnly && (<><div style={{ display: 'flex', alignItems: 'center', gap: 12, marginTop: 16 }}><div style={{ flex: 1, height: 1, background: '#e5e7eb' }} />diff --git a/client/src/pages/SettingsPage.tsx b/client/src/pages/SettingsPage.tsxindex bf19952dd..1d138811f 100644--- a/client/src/pages/SettingsPage.tsx+++ b/client/src/pages/SettingsPage.tsx@@ -71,6 +71,13 @@ export default function SettingsPage(): React.ReactElement {const [currentPassword, setCurrentPassword] = useState<string>('')const [newPassword, setNewPassword] = useState<string>('')const [confirmPassword, setConfirmPassword] = useState<string>('')+ const [oidcOnlyMode, setOidcOnlyMode] = useState<boolean>(false)++ useEffect(() => {+ authApi.getAppConfig?.().then((config) => {+ if (config?.oidc_only_mode) setOidcOnlyMode(true)+ }).catch(() => {})+ }, [])useEffect(() => {setMapTileUrl(settings.map_tile_url || '')@@ -398,6 +405,7 @@ export default function SettingsPage(): React.ReactElement {</div>{/* Change Password */}+ {!oidcOnlyMode && (<div style={{ paddingTop: 8, marginTop: 8, borderTop: '1px solid var(--border-secondary)' }}><label className="block text-sm font-medium text-slate-700 mb-3">{t('settings.changePassword')}</label><div className="space-y-3">@@ -446,6 +454,7 @@ export default function SettingsPage(): React.ReactElement {</button></div></div>+ )}<div className="flex items-center gap-4"><div style={{ position: 'relative', flexShrink: 0 }}>diff --git a/server/src/routes/admin.ts b/server/src/routes/admin.tsindex 53e538b2d..f6d0afd96 100644--- a/server/src/routes/admin.ts+++ b/server/src/routes/admin.ts@@ -122,16 +122,18 @@ router.get('/oidc', (_req: Request, res: Response) => {client_id: get('oidc_client_id'),client_secret_set: !!secret,display_name: get('oidc_display_name'),+ oidc_only: get('oidc_only') === 'true',});});router.put('/oidc', (req: Request, res: Response) => {- const { issuer, client_id, client_secret, display_name } = req.body;+ const { issuer, client_id, client_secret, display_name, oidc_only } = req.body;const set = (key: string, val: string) => db.prepare("INSERT OR REPLACE INTO app_settings (key, value) VALUES (?, ?)").run(key, val || '');set('oidc_issuer', issuer);set('oidc_client_id', client_id);if (client_secret !== undefined) set('oidc_client_secret', client_secret);set('oidc_display_name', display_name);+ set('oidc_only', oidc_only ? 'true' : 'false');res.json({ success: true });});diff --git a/server/src/routes/auth.ts b/server/src/routes/auth.tsindex 2996128ec..7516d3a60 100644--- a/server/src/routes/auth.ts+++ b/server/src/routes/auth.ts@@ -59,6 +59,17 @@ function rateLimiter(maxAttempts: number, windowMs: number) {}const authLimiter = rateLimiter(10, RATE_LIMIT_WINDOW);+function isOidcOnlyMode(): boolean {+ const get = (key: string) => (db.prepare("SELECT value FROM app_settings WHERE key = ?").get(key) as { value: string } | undefined)?.value || null;+ const enabled = get('oidc_only') === 'true';+ if (!enabled) return false;+ const oidcConfigured = !!(+ (process.env.OIDC_ISSUER || get('oidc_issuer')) &&+ (process.env.OIDC_CLIENT_ID || get('oidc_client_id'))+ );+ return oidcConfigured;+}+function maskKey(key: string | null | undefined): string | null {if (!key) return null;if (key.length <= 8) return '--------';@@ -89,6 +100,8 @@ router.get('/app-config', (_req: Request, res: Response) => {(process.env.OIDC_ISSUER || (db.prepare("SELECT value FROM app_settings WHERE key = 'oidc_issuer'").get() as { value: string } | undefined)?.value) &&(process.env.OIDC_CLIENT_ID || (db.prepare("SELECT value FROM app_settings WHERE key = 'oidc_client_id'").get() as { value: string } | undefined)?.value));+ const oidcOnlySetting = (db.prepare("SELECT value FROM app_settings WHERE key = 'oidc_only'").get() as { value: string } | undefined)?.value;+ const oidcOnlyMode = oidcConfigured && oidcOnlySetting === 'true';res.json({allow_registration: isDemo ? false : allowRegistration,has_users: userCount > 0,@@ -96,6 +109,7 @@ router.get('/app-config', (_req: Request, res: Response) => {has_maps_key: hasGoogleKey,oidc_configured: oidcConfigured,oidc_display_name: oidcConfigured ? (oidcDisplayName || 'SSO') : undefined,+ oidc_only_mode: oidcOnlyMode,allowed_file_types: (db.prepare("SELECT value FROM app_settings WHERE key = 'allowed_file_types'").get() as { value: string } | undefined)?.value || 'jpg,jpeg,png,gif,webp,heic,pdf,doc,docx,xls,xlsx,txt,csv',demo_mode: isDemo,demo_email: isDemo ? '[email protected]' : undefined,@@ -118,6 +132,9 @@ router.post('/register', authLimiter, (req: Request, res: Response) => {const { username, email, password } = req.body;const userCount = (db.prepare('SELECT COUNT(*) as count FROM users').get() as { count: number }).count;+ if (userCount > 0 && isOidcOnlyMode()) {+ return res.status(403).json({ error: 'Password authentication is disabled. Please sign in with SSO.' });+ }if (userCount > 0) {const setting = db.prepare("SELECT value FROM app_settings WHERE key = 'allow_registration'").get() as { value: string } | undefined;if (setting?.value === 'false') {@@ -167,6 +184,10 @@ router.post('/register', authLimiter, (req: Request, res: Response) => {});router.post('/login', authLimiter, (req: Request, res: Response) => {+ if (isOidcOnlyMode()) {+ return res.status(403).json({ error: 'Password authentication is disabled. Please sign in with SSO.' });+ }+const { email, password } = req.body;if (!email || !password) {@@ -205,6 +226,9 @@ router.get('/me', authenticate, (req: Request, res: Response) => {router.put('/me/password', authenticate, rateLimiter(5, RATE_LIMIT_WINDOW), (req: Request, res: Response) => {const authReq = req as AuthRequest;+ if (isOidcOnlyMode()) {+ return res.status(403).json({ error: 'Password authentication is disabled.' });+ }if (process.env.DEMO_MODE === 'true' && authReq.user.email === '[email protected]') {return res.status(403).json({ error: 'Password change is disabled in demo mode.' });}