Design Prot Merge #1

Merged
NotS1mp merged 217 commits from design-prot into master 2026-09-21 15:48:16 +00:00
3 changed files with 11 additions and 6 deletions
Showing only changes of commit 757c74b899 - Show all commits
+3
View File
@@ -16,5 +16,8 @@ SESSION_SECRET=change-me-to-a-long-random-string
# SESSION_REFRESH_THRESHOLD_SECONDS=30
# AUTH_FLOW_TTL_SECONDS=600
# Dev already allows a plain-HTTP issuer. Set this only to allow it in a production build (never with a public issuer).
# AUTH_ALLOW_INSECURE_HTTP=true
# Backend API base URL (used from later parts)
API_BASE_URL=http://localhost:5111
+5 -6
View File
@@ -1,5 +1,6 @@
import * as client from 'openid-client';
import { EncryptJWT, jwtDecrypt } from 'jose';
import { dev } from '$app/environment';
import { authConfig } from '$lib/server/config';
import type { SessionUser } from '$lib/types';
@@ -16,13 +17,12 @@ export interface Session extends SessionUser {
expiresAt: number;
}
let configPromise: Promise<client.Configuration> | null = null;
let configPromise: Promise<client.Configuration>;
export function getOidcConfig(): Promise<client.Configuration> {
configPromise ??= (async () => {
const issuer = new URL(authConfig.issuer);
const options =
issuer.protocol === 'http:' ? { execute: [client.allowInsecureRequests] } : undefined;
const insecureAllowed = (dev || authConfig.allowInsecureHttp) && issuer.protocol === 'http:';
const options = insecureAllowed ? { execute: [client.allowInsecureRequests] } : undefined;
const secret = authConfig.clientSecret;
return secret
@@ -32,8 +32,7 @@ export function getOidcConfig(): Promise<client.Configuration> {
return configPromise;
}
let keyPromise: Promise<Uint8Array> | null = null;
let keyPromise: Promise<Uint8Array>;
function sessionKey(): Promise<Uint8Array> {
keyPromise ??= crypto.subtle
.digest('SHA-256', new TextEncoder().encode(authConfig.sessionSecret))
+3
View File
@@ -40,5 +40,8 @@ export const authConfig = {
},
get flowTtlSeconds() {
return positiveInt(env.AUTH_FLOW_TTL_SECONDS, 600);
},
get allowInsecureHttp() {
return env.AUTH_ALLOW_INSECURE_HTTP === 'true';
}
};