mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-11-27 07:07:31 +00:00
feat(oidc): honor remember-me in SSO login (#1927)
This commit is contained in:
@@ -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);
|
||||
|
||||
@@ -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(),
|
||||
|
||||
Reference in New Issue
Block a user