feat(oidc): honor remember-me in SSO login (#1927)

This commit is contained in:
jubnl
2026-08-15 22:48:03 +02:00
parent cb41d082be
commit 61e03fdfde
10 changed files with 263 additions and 26 deletions
+16 -1
View File
@@ -1,7 +1,22 @@
import { oidcCallbackQuerySchema, oidcExchangeQuerySchema } from './oidc.schema';
import { oidcCallbackQuerySchema, oidcExchangeQuerySchema, oidcLoginQuerySchema } from './oidc.schema';
import { describe, it, expect } from 'vitest';
describe('oidcLoginQuerySchema', () => {
it('accepts invite and remember flags, both optional', () => {
expect(oidcLoginQuerySchema.safeParse({}).success).toBe(true);
expect(oidcLoginQuerySchema.safeParse({ invite: 'tok' }).success).toBe(true);
expect(oidcLoginQuerySchema.safeParse({ remember: '1' }).success).toBe(true);
expect(oidcLoginQuerySchema.safeParse({ invite: 'tok', remember: '0' }).success).toBe(true);
});
it('rejects remember values other than the "0"/"1" wire flags', () => {
expect(oidcLoginQuerySchema.safeParse({ remember: 'yes' }).success).toBe(false);
expect(oidcLoginQuerySchema.safeParse({ remember: 'true' }).success).toBe(false);
expect(oidcLoginQuerySchema.safeParse({ remember: 1 }).success).toBe(false);
});
});
describe('oidcCallbackQuerySchema', () => {
it('accepts code+state, an error, or nothing (all optional)', () => {
expect(oidcCallbackQuerySchema.safeParse({ code: 'c', state: 's' }).success).toBe(true);
+9
View File
@@ -8,6 +8,15 @@ import { z } from 'zod';
* /login, and the auth-code on /exchange). These schemas pin those query shapes;
* the cryptographic verification + provisioning live in the OIDC service.
*/
export const oidcLoginQuerySchema = z.object({
invite: z.string().optional(),
// '1' → remember-me session (SESSION_DURATION_REMEMBER), '0' → browser-session
// cookie, absent → the historical default duration. String flags because the
// value survives a redirect query, not a JSON body.
remember: z.enum(['0', '1']).optional(),
});
export type OidcLoginQuery = z.infer<typeof oidcLoginQuerySchema>;
export const oidcCallbackQuerySchema = z.object({
code: z.string().optional(),
state: z.string().optional(),