feat(auth): let admins keep the login page on OIDC-only instances (#2925)

A new app setting oidc_auto_redirect (default on) is part of the admin form
and the public app config. Off, an instance without password login no longer
sends visitors straight to the IdP: the login page shows its SSO button,
also while the cached config is read. Admin toggle on desktop and phone.
This commit is contained in:
Maurice
2026-11-13 09:35:18 +01:00
parent d5d9428cf2
commit 924b4e0787
45 changed files with 227 additions and 8 deletions
+22
View File
@@ -120,6 +120,28 @@ describe('Auth e2e (real auth guard + real service + real cookie service + temp
expect(res.body.permissions).toBeUndefined();
});
it('PUT /app-settings oidc_auto_redirect reaches the public app-config the login page reads (#2925)', async () => {
const admin = createUser(db as never, {
username: 'redirect-admin',
email: 'redirect-admin@example.test',
role: 'admin',
});
const autoRedirect = async () => (await request(server).get('/api/auth/app-config')).body.oidc_auto_redirect;
try {
expect(await autoRedirect()).toBe(true);
const res = await request(server)
.put('/api/auth/app-settings')
.set('Cookie', sessionCookie(admin.user.id))
.send({ oidc_auto_redirect: false });
expect(res.status).toBe(200);
expect(await readAppSetting(orm, 'oidc_auto_redirect')).toBe('false');
expect(await autoRedirect()).toBe(false);
} finally {
await deleteRows(orm, AppSettings, { key: 'oidc_auto_redirect' });
}
});
it('GET /me requires a session (401 without a cookie)', async () => {
expect((await request(server).get('/api/auth/me')).status).toBe(401);
});