diff --git a/clients/python/src/lightspeed_ai/platform_types.py b/clients/python/src/lightspeed_ai/platform_types.py index 4208dad3c..f54002fbc 100644 --- a/clients/python/src/lightspeed_ai/platform_types.py +++ b/clients/python/src/lightspeed_ai/platform_types.py @@ -22,7 +22,7 @@ class Principal(TypedDict): class Credential(TypedDict): - kind: Literal['session', 'cliSession', 'personalKey', 'serviceUserKey'] + kind: Literal['session', 'cliSession', 'personalKey', 'serviceUserKey', 'federated'] id: str diff --git a/clients/typescript/schema/platform.schema.json b/clients/typescript/schema/platform.schema.json index c41d3d440..da1780614 100644 --- a/clients/typescript/schema/platform.schema.json +++ b/clients/typescript/schema/platform.schema.json @@ -45,7 +45,8 @@ "session", "cliSession", "personalKey", - "serviceUserKey" + "serviceUserKey", + "federated" ] }, "id": { @@ -186,7 +187,8 @@ "session", "cliSession", "personalKey", - "serviceUserKey" + "serviceUserKey", + "federated" ] }, "id": { diff --git a/clients/typescript/src/generated/platform-types.ts b/clients/typescript/src/generated/platform-types.ts index 8bea2dddd..3e62cdfd1 100644 --- a/clients/typescript/src/generated/platform-types.ts +++ b/clients/typescript/src/generated/platform-types.ts @@ -16,7 +16,7 @@ export interface PlatformConnectionDetails { platformAdmin: boolean; }; credential: { - kind: "session" | "cliSession" | "personalKey" | "serviceUserKey"; + kind: "session" | "cliSession" | "personalKey" | "serviceUserKey" | "federated"; id: string; }; organizations: { @@ -62,7 +62,7 @@ export interface PlatformSessionReadResult { email: string | null; }; credential: { - kind: "session" | "cliSession" | "personalKey" | "serviceUserKey"; + kind: "session" | "cliSession" | "personalKey" | "serviceUserKey" | "federated"; id: string; }; session: { diff --git a/package-lock.json b/package-lock.json index 85df0a119..5dd1d44db 100644 --- a/package-lock.json +++ b/package-lock.json @@ -16770,7 +16770,6 @@ "version": "2.9.1", "resolved": "https://registry.npmjs.org/yaml/-/yaml-2.9.1.tgz", "integrity": "sha512-3NxN8+78OdzbT7C/WjGsyfPAtJaN3FNDsWxv7Y7mcDsT/oOmgW8BpyQQFFBnvZE3j9Y2Sdz1ULFLezL7Eb2yFw==", - "devOptional": true, "license": "ISC", "bin": { "yaml": "bin.mjs" @@ -16974,6 +16973,7 @@ "jose": "6.2.12", "pg": "^8.23.1", "tsx": "^4.23.15", + "yaml": "2.9.1", "zod": "^4.6.7" }, "devDependencies": { diff --git a/platform/backend/package.json b/platform/backend/package.json index 2e81518c8..3dfca6976 100644 --- a/platform/backend/package.json +++ b/platform/backend/package.json @@ -21,6 +21,7 @@ "jose": "6.2.12", "pg": "^8.23.1", "tsx": "^4.23.15", + "yaml": "2.9.1", "zod": "^4.6.7" }, "devDependencies": { diff --git a/platform/backend/src/auth-context.ts b/platform/backend/src/auth-context.ts index 2bc5a6bbd..81029f0cb 100644 --- a/platform/backend/src/auth-context.ts +++ b/platform/backend/src/auth-context.ts @@ -22,9 +22,10 @@ export type Principal = { export interface AuthContext { principal: Principal; credential: { - kind: "session" | "cliSession" | "personalKey" | "serviceUserKey"; + kind: "session" | "cliSession" | "personalKey" | "serviceUserKey" | "federated"; id: string; restrictions: CredentialRestrictions; + workload?: { issuer: string; subject: string }; }; actorId: string; session?: { id: string; createdAt: Date; expiresAt: Date }; diff --git a/platform/backend/src/authentication.ts b/platform/backend/src/authentication.ts index 4d9ba1a64..8fa142f3c 100644 --- a/platform/backend/src/authentication.ts +++ b/platform/backend/src/authentication.ts @@ -1,3 +1,5 @@ +import { compactJws, MAX_WORKLOAD_TOKEN_LENGTH } from "./federation.js"; +import { resolveFederatedBinding } from "./federated-binding.js"; import { eq } from "drizzle-orm"; import { schema } from "@lightspeed-ai/platform-db"; import { credentialRestrictionsSchema } from "@lightspeed-ai/platform-shared"; @@ -24,8 +26,15 @@ export async function authenticateRequest(ctx: AppContext, request: Request): Pr if (authorization !== null) { // An explicitly supplied invalid credential must never fall back to a broader cookie. const match = /^Bearer ([^\s,]+)$/i.exec(authorization); - if (!match || match[1]!.length > 4096) return null; + if (!match) return null; const secret = match[1]!; + if (ctx.env.federation && secret.length <= MAX_WORKLOAD_TOKEN_LENGTH && compactJws.test(secret)) { + const identity = await ctx.env.federation.verify(secret); + if (!identity) return null; + const binding = await ctx.db.transaction(tx => resolveFederatedBinding(tx, identity)); + return binding?.auth ? { auth: binding.auth } : null; + } + if (secret.length > 4096) return null; const configId = secret.startsWith(PERSONAL_KEY_PREFIX) ? PERSONAL_KEY_CONFIG : secret.startsWith(SERVICE_USER_KEY_PREFIX) ? SERVICE_USER_KEY_CONFIG : null; if (!configId) { // Ignore cookies completely when a bearer is explicit. Better Auth owns diff --git a/platform/backend/src/env.ts b/platform/backend/src/env.ts index 6d9759ddc..44765233e 100644 --- a/platform/backend/src/env.ts +++ b/platform/backend/src/env.ts @@ -1,3 +1,5 @@ +import { WorkloadFederation } from "./federation.js"; +import { readFederationConfig } from "./federation-config.js"; import { readFileSync } from "node:fs"; import { databaseWorkloadIdentityFromEnv, type DatabaseWorkloadIdentity } from "@lightspeed-ai/platform-db"; import { @@ -47,6 +49,7 @@ export interface ServerEnv { apiKeyMaxExpiryDays?: number; github: { clientId: string; clientSecret: string } | null; oidc?: OidcConfig | null; + federation?: WorkloadFederation; passwordSignIn?: "local" | "break-glass" | "off"; /// Authenticated Lightspeed runtime HTTP API endpoint. lightspeedApiUrl: string | null; @@ -115,6 +118,8 @@ export function loadEnv(): ServerEnv { apiKeyMaxExpiryDays: optionalIntegerEnv("LIGHTSPEED_PLATFORM_API_KEY_MAX_EXPIRY_DAYS", 1, 3650), github, oidc, + federation: process.env.LIGHTSPEED_PLATFORM_FEDERATION_FILE + ? new WorkloadFederation(readFederationConfig(process.env.LIGHTSPEED_PLATFORM_FEDERATION_FILE)) : undefined, passwordSignIn: passwordSignIn as ServerEnv["passwordSignIn"], lightspeedApiUrl: process.env.LIGHTSPEED_API_URL ?? null, lightspeedApiToken, diff --git a/platform/backend/src/federated-binding.integration.test.ts b/platform/backend/src/federated-binding.integration.test.ts new file mode 100644 index 000000000..6a197b7fe --- /dev/null +++ b/platform/backend/src/federated-binding.integration.test.ts @@ -0,0 +1,39 @@ +import { afterAll, beforeAll, expect, it } from "vitest"; +import { eq } from "drizzle-orm"; +import { schema } from "@lightspeed-ai/platform-db"; +import { identityEnv, identityFixture } from "../test/identity-fixture.js"; +import { workloadIssuer } from "../test/workload-issuer.js"; + +let source: Awaited>; +let fixture: Awaited>; +beforeAll(async () => { + source = await workloadIssuer(); + fixture = await identityFixture({ ...identityEnv, federation: source.federation }); +}, 30_000); +afterAll(async () => { await fixture?.postgres.close(); await source?.close(); }); + +it("admits a bound service user with current restrictions and enforces disablement, UID pinning and deletion on the next request", async () => { + const token = await source.mint({ "kubernetes.io": { serviceaccount: { uid: "uid-1" } } }); + const request = (path: string, bearer = token, method = "GET", body?: object) => + fixture.app.request(path, { method, headers: { authorization: `Bearer ${bearer}`, "content-type": "application/json" }, body: JSON.stringify(body) }); + const session = "/api/v1/platform/session"; + expect((await request(session)).status).toBe(401); + const organizationId = crypto.randomUUID(); + await fixture.db.insert(schema.organization).values({ id: organizationId, slug: "federated", name: "Federated", createdAt: new Date() }); + const [user] = await fixture.db.insert(schema.serviceUsers).values({ organizationId, name: "CI", role: "admin" }).returning(); + const [binding] = await fixture.db.insert(schema.federatedCredentials).values({ + serviceUserId: user!.id, issuer: source.issuer, subject: source.subject, serviceAccountUid: "uid-1", restrictions: { readOnly: true }, + }).returning(); + expect(await (await request(session)).json()).toMatchObject({ principal: { kind: "serviceUser", id: user!.id }, credential: { kind: "federated", id: binding!.id } }); + expect((await request("/api/ui/me")).status).toBe(401); + expect((await request(`/api/v1/platform/organizations/${organizationId}`, token, "PATCH", { name: "New" })).status).toBe(403); + expect((await request(session, await source.mint())).status).toBe(401); + const audit = await fixture.db.select().from(schema.identityAudit).where(eq(schema.identityAudit.action, "serviceUser.authenticate")); + expect(audit[0]?.details).toMatchObject({ credentialKind: "federated", issuer: source.issuer, subject: source.subject }); + expect(JSON.stringify(audit)).not.toContain(token); + await fixture.db.update(schema.serviceUsers).set({ enabled: false }).where(eq(schema.serviceUsers.id, user!.id)); + expect((await request(session)).status).toBe(401); + await fixture.db.update(schema.serviceUsers).set({ enabled: true }).where(eq(schema.serviceUsers.id, user!.id)); + await fixture.db.delete(schema.federatedCredentials).where(eq(schema.federatedCredentials.id, binding!.id)); + expect((await request(session)).status).toBe(401); +}); diff --git a/platform/backend/src/federated-binding.ts b/platform/backend/src/federated-binding.ts new file mode 100644 index 000000000..69d55b00c --- /dev/null +++ b/platform/backend/src/federated-binding.ts @@ -0,0 +1,32 @@ +import { and, eq } from "drizzle-orm"; +import { schema, type Db } from "@lightspeed-ai/platform-db"; +import { credentialRestrictionsSchema } from "@lightspeed-ai/platform-shared"; +import { auditAsSubject } from "./identity-audit.js"; +import type { AuthContext } from "./auth-context.js"; +import type { WorkloadIdentity } from "./federation.js"; + +/** An unusable binding still owns its subject and must never be eligible for enrollment. */ +export async function resolveFederatedBinding(db: Pick, identity: WorkloadIdentity) { + const { federatedCredentials, serviceUsers, organization } = schema; + const [row] = await db.select({ credential: federatedCredentials, serviceUser: serviceUsers, handle: organization.slug }) + .from(federatedCredentials) + .innerJoin(serviceUsers, eq(serviceUsers.id, federatedCredentials.serviceUserId)) + .innerJoin(organization, eq(organization.id, serviceUsers.organizationId)) + .where(and(eq(federatedCredentials.issuer, identity.issuer), eq(federatedCredentials.subject, identity.subject))); + if (!row) return null; + const limits = credentialRestrictionsSchema.safeParse(row.credential.restrictions); + if (!limits.success || !row.serviceUser.enabled || + (row.credential.serviceAccountUid !== null && row.credential.serviceAccountUid !== identity.serviceAccountUid)) { + return { auth: null }; + } + const { issuer, subject } = identity; + const auth: AuthContext = { + principal: { kind: "serviceUser", id: row.serviceUser.id, serviceUser: row.serviceUser, + organizationId: row.serviceUser.organizationId, platformAdmin: false }, + credential: { kind: "federated", id: row.credential.id, restrictions: limits.data, workload: { issuer, subject } }, + actorId: `serviceUser:${row.serviceUser.id}`, + }; + await db.update(federatedCredentials).set({ lastUsedAt: new Date() }).where(eq(federatedCredentials.id, row.credential.id)); + await auditAsSubject(db, auth, { action: "serviceUser.authenticate", targetId: row.serviceUser.id }); + return { auth, handle: row.handle, organizationId: row.serviceUser.organizationId }; +} diff --git a/platform/backend/src/federation-config.ts b/platform/backend/src/federation-config.ts new file mode 100644 index 000000000..2b1d75a26 --- /dev/null +++ b/platform/backend/src/federation-config.ts @@ -0,0 +1,52 @@ +import { readFileSync } from "node:fs"; +import { parse } from "yaml"; +import { z } from "zod"; +import { organizationCreateSchema, serviceUserCreateSchema } from "@lightspeed-ai/platform-shared"; + +const nonempty = z.string().min(1); +export const keySourceUrl = z.string().url().refine(value => { + const url = new URL(value); + return !url.username && !url.password && !url.hash && !url.search && + (url.protocol === "https:" || (url.protocol === "http:" && ["localhost", "127.0.0.1", "[::1]"].includes(url.hostname))); +}, "Use HTTPS, or HTTP on loopback"); + +const sources = z.union([ + z.strictObject({ jwksFile: nonempty }), + z.strictObject({ + discoveryUrl: keySourceUrl.optional(), jwksUrl: keySourceUrl.optional(), + caFile: nonempty.optional(), bearerTokenFile: nonempty.optional(), + }), +]); +const issuer = z.strictObject({ + name: nonempty, issuer: keySourceUrl, audiences: z.array(nonempty).min(1), + algorithms: z.array(z.enum(["RS256", "RS384", "RS512", "PS256", "PS384", "PS512", "ES256", "ES384", "ES512", "EdDSA", "Ed25519"])).min(1).default(["RS256"]), + keys: sources.default({}), maxTokenLifetimeSeconds: z.int().positive().optional(), + clockSkewSeconds: z.int().min(0).max(300).default(60), +}); +const rule = z.strictObject({ + issuer: nonempty, subjectPattern: nonempty.max(512), maxOrganizations: z.int().nonnegative(), + handlePattern: nonempty.optional().transform(value => value === undefined ? undefined : new RegExp(value, "u")), + organization: organizationCreateSchema.pick({ universeQuota: true }).default({}), + serviceUser: z.strictObject({ name: serviceUserCreateSchema.shape.name, role: z.literal("admin") }) + .default({ name: "deployer", role: "admin" }), +}); +export type TrustedIssuer = z.infer; +export type EnrollmentRule = z.infer; +export const federationConfig = z.strictObject({ + issuers: z.array(issuer).min(1), enrollment: z.array(rule).default([]), +}).superRefine(({ issuers, enrollment }, ctx) => { + const names = new Set(issuers.map(i => i.name)); + if (names.size !== issuers.length || new Set(issuers.map(i => i.issuer)).size !== issuers.length) + ctx.addIssue({ code: "custom", message: "Trusted issuer names and identifiers must be unique" }); + const patterns = new Set(); + for (const r of enrollment) { + const key = JSON.stringify([r.issuer, r.subjectPattern]); + if (!names.has(r.issuer) || patterns.has(key)) + ctx.addIssue({ code: "custom", message: "Enrollment rules must identify a trusted issuer and a unique subject pattern" }); + patterns.add(key); + } +}); + +export function readFederationConfig(path: string) { + return federationConfig.parse(parse(readFileSync(path, "utf8"))); +} diff --git a/platform/backend/src/federation-keys.ts b/platform/backend/src/federation-keys.ts new file mode 100644 index 000000000..ee67a2b91 --- /dev/null +++ b/platform/backend/src/federation-keys.ts @@ -0,0 +1,70 @@ +import { readFile } from "node:fs/promises"; +import http from "node:http"; +import https from "node:https"; +import { createLocalJWKSet, type JSONWebKeySet } from "jose"; +import { keySourceUrl, type TrustedIssuer } from "./federation-config.js"; + +const REFRESH_INTERVAL = 30_000; +const CACHE_TTL = 60 * 60_000; +const MAX_CACHE_AGE = 24 * CACHE_TTL; + +async function getJson(url: URL, ca?: Buffer, bearer?: string): Promise { + const get = url.protocol === "https:" ? https.get : http.get; + const response = await new Promise((resolve, reject) => { + get(url, { ca, headers: bearer ? { authorization: `Bearer ${bearer}` } : {}, + signal: AbortSignal.timeout(5000) }, resolve).on("error", reject); + }); + try { + if (response.statusCode !== 200) throw new Error("Key source unavailable"); + const chunks: Buffer[] = []; + let size = 0; + for await (const chunk of response) { + size += chunk.length; + if (size > 1024 * 1024) throw new Error("Oversized key source"); + chunks.push(chunk); + } + return JSON.parse(Buffer.concat(chunks).toString("utf8")); + } finally { response.destroy(); } +} + +async function loadKeys(config: TrustedIssuer) { + const source = config.keys; + let keys: unknown; + if ("jwksFile" in source) { + keys = JSON.parse(await readFile(source.jwksFile, "utf8")); + } else { + const discoveryUrl = new URL(source.discoveryUrl ?? config.issuer.replace(/\/$/, "") + "/.well-known/openid-configuration"); + const ca = source.caFile ? await readFile(source.caFile) : undefined; + const bearer = source.bearerTokenFile ? (await readFile(source.bearerTokenFile, "utf8")).trim() : undefined; + const discovery = await getJson(discoveryUrl, ca, bearer) as { issuer?: unknown; jwks_uri?: unknown } | null; + if (discovery?.issuer !== config.issuer) throw new Error("Discovery issuer mismatch"); + const url = new URL(source.jwksUrl ?? keySourceUrl.parse(discovery.jwks_uri)); + // Only explicitly configured origins may receive the operator's credential. + keys = await getJson(url, ca, source.jwksUrl || url.origin === discoveryUrl.origin ? bearer : undefined); + } + const resolve = createLocalJWKSet(keys as JSONWebKeySet); + return { resolve, kids: new Set((keys as JSONWebKeySet).keys.map(key => key.kid)), loaded: Date.now() }; +} + +/** One cache per configured issuer, shared by ordinary admission and enrollment. */ +export class IssuerKeys { + private cached?: Awaited>; + private pending?: Promise; + private attempted = -Infinity; + constructor(private readonly issuer: TrustedIssuer) {} + + async resolve(kid: string) { + const now = Date.now(); + if (!this.cached || now - this.cached.loaded >= CACHE_TTL || !this.cached.kids.has(kid)) { + if (!this.pending && now - this.attempted >= REFRESH_INTERVAL) { + this.attempted = now; + this.pending = loadKeys(this.issuer) + .then(cached => { this.cached = cached; }) + .finally(() => { this.pending = undefined; }); + } + try { await this.pending; } catch { /* Serve the last good set within its maximum age. */ } + } + if (!this.cached || Date.now() - this.cached.loaded >= MAX_CACHE_AGE) throw new Error("No current issuer keys"); + return this.cached.resolve; + } +} diff --git a/platform/backend/src/federation.test.ts b/platform/backend/src/federation.test.ts new file mode 100644 index 000000000..779f82100 --- /dev/null +++ b/platform/backend/src/federation.test.ts @@ -0,0 +1,95 @@ +import { createServer } from "node:http"; +import { once } from "node:events"; +import type { AddressInfo } from "node:net"; +import { writeFile } from "node:fs/promises"; +import { join } from "node:path"; +import { afterAll, beforeAll, expect, it, vi } from "vitest"; +import { workloadIssuer } from "../test/workload-issuer.js"; +import { federationConfig, readFederationConfig } from "./federation-config.js"; +import { WorkloadFederation } from "./federation.js"; + +let source: Awaited>; +beforeAll(async () => { source = await workloadIssuer(); }); +afterAll(async () => { await source.close(); }); + +it("verifies configured issuer, signature, audience, time claims and lifetime before accepting the subject", async () => { + const { mint, federation, issuer, audience, subject } = source; + expect(await federation.verify(await mint({ aud: ["other", audience] }))).toEqual({ issuer, subject }); + const now = Math.floor(Date.now() / 1000); + for (const claims of [{ iss: issuer.slice(0, -1) }, { aud: "other" }, { iat: undefined }, { exp: undefined }, + { exp: now }, { sub: "" }, { sub: "\uD800" }, { iat: now + 90 }, { nbf: now + 90 }, { exp: now + 800 }]) { + expect(await federation.verify(await mint(claims))).toBeNull(); + } + const other = await workloadIssuer(); + try { expect(await federation.verify(await other.mint())).toBeNull(); } finally { await other.close(); } + expect(await federation.verify(await mint({}, "absent"))).toBeNull(); + expect(await federation.verify(await mint({ extra: "x".repeat(16384) }))).toBeNull(); + expect(await federation.verify("malformed")).toBeNull(); + + const skew = new WorkloadFederation(federationConfig.parse({ issuers: [{ ...source.trusted, clockSkewSeconds: 60 }] })); + expect(await skew.verify(await mint({ iat: now - 300, exp: now - 20 }))).toEqual({ issuer, subject }); + const otherAlgorithm = new WorkloadFederation(federationConfig.parse({ issuers: [{ ...source.trusted, algorithms: ["RS256"] }] })); + expect(await otherAlgorithm.verify(await mint())).toBeNull(); +}); + +it("loads YAML at startup and refuses ambiguous issuer trust and invalid enrollment rules", async () => { + const path = join(source.dir, "federation.yaml"); + await writeFile(path, 'issuers:\n - name: cluster\n issuer: https://issuer.test\n audiences: [platform]\n'); + expect(readFederationConfig(path).issuers[0]?.algorithms).toEqual(["RS256"]); + for (const config of [ + { issuers: [source.trusted, source.trusted] }, + { issuers: [{ ...source.trusted, algorithms: ["HS256"] }] }, + { issuers: [{ ...source.trusted, keys: { jwksFile: "keys", jwksUrl: source.issuer } }] }, + { issuers: [source.trusted], enrollment: [{ issuer: "missing", subjectPattern: "*", maxOrganizations: 2 }] }, + ]) expect(federationConfig.safeParse(config).success).toBe(false); +}); + +it("coalesces discovery, rotates the projected fetch credential and bounds stale-key use", async () => { + let requests = 0; + let expected = "first"; + let servedIssuer = source.issuer; + let key = source.jwk; + const server = createServer((req, res) => { + requests++; + if (req.headers.authorization !== `Bearer ${expected}`) { res.writeHead(403).end(); return; } + res.end(JSON.stringify(req.url === "/keys" ? { keys: [key] } : { issuer: servedIssuer, jwks_uri: origin + "/keys" })); + }); + server.listen(0, "127.0.0.1"); + await once(server, "listening"); + const origin = `http://127.0.0.1:${(server.address() as AddressInfo).port}`; + const path = join(source.dir, "token"); + const rotated = await workloadIssuer(); + const clock = vi.spyOn(Date, "now"); + try { + await writeFile(path, expected); + const federation = new WorkloadFederation(federationConfig.parse({ issuers: [ + { ...source.trusted, keys: { discoveryUrl: origin + "/discovery", bearerTokenFile: path } }, + ] })); + const first = await source.mint(); + const second = await rotated.mint({}, "second"); + const start = Date.now(); + expect(await Promise.all([federation.verify(first), federation.verify(first)])).toEqual([ + { issuer: source.issuer, subject: source.subject }, { issuer: source.issuer, subject: source.subject }, + ]); + expect(await federation.verify(second)).toBeNull(); + expect(requests).toBe(2); + clock.mockReturnValue(start + 31_000); + key = { ...rotated.jwk, kid: "second" }; + expected = "rotated"; + await writeFile(path, expected); + expect(await federation.verify(second)).toBeTruthy(); + expect(await federation.verify(first)).toBeNull(); + expect(requests).toBe(4); + servedIssuer = "https://other.example.test/"; + clock.mockReturnValue(start + 2 * 3600_000); + expect(await federation.verify(second)).toBeTruthy(); + expect(requests).toBe(5); + clock.mockReturnValue(start + 25 * 3600_000); + expect(await federation.verify(second)).toBeNull(); + } finally { + clock.mockRestore(); + await rotated.close(); + server.close(); + await once(server, "close"); + } +}); diff --git a/platform/backend/src/federation.ts b/platform/backend/src/federation.ts new file mode 100644 index 000000000..b87c5d331 --- /dev/null +++ b/platform/backend/src/federation.ts @@ -0,0 +1,47 @@ +import { decodeJwt, decodeProtectedHeader, jwtVerify } from "jose"; +import type { z } from "zod"; +import type { federationConfig } from "./federation-config.js"; +import { IssuerKeys } from "./federation-keys.js"; + +export interface WorkloadIdentity { + issuer: string; + subject: string; + serviceAccountUid?: string; +} + +export const MAX_WORKLOAD_TOKEN_LENGTH = 16 * 1024; +export const compactJws = /^[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+$/; + +export class WorkloadFederation { + private readonly issuers; + constructor(readonly config: z.infer) { + this.issuers = new Map(config.issuers.map(issuer => [issuer.issuer, { issuer, keys: new IssuerKeys(issuer) }])); + } + + async verify(token: string): Promise { + if (token.length > MAX_WORKLOAD_TOKEN_LENGTH || !compactJws.test(token)) return null; + try { + const { iss } = decodeJwt(token); + const trusted = iss && this.issuers.get(iss); + if (!trusted) return null; + const { alg, kid } = decodeProtectedHeader(token); + const { issuer, keys } = trusted; + if (!kid || typeof kid !== "string" || !issuer.algorithms.some(a => a === alg)) return null; + const { payload } = await jwtVerify(token, await keys.resolve(kid), { + issuer: issuer.issuer, audience: issuer.audiences, algorithms: issuer.algorithms, + requiredClaims: ["exp", "sub", ...(issuer.maxTokenLifetimeSeconds ? ["iat"] : [])], + clockTolerance: issuer.clockSkewSeconds, + }); + // PostgreSQL text must represent the signed subject without replacement or truncation. + if (typeof payload.sub !== "string" || !payload.sub || /[\p{Cs}\u0000]/u.test(payload.sub) || Buffer.byteLength(payload.sub) > 1024) return null; + if (Array.isArray(payload.aud) && !payload.aud.every(value => typeof value === "string")) return null; + if (!Number.isFinite(payload.exp) || (payload.nbf !== undefined && !Number.isFinite(payload.nbf))) return null; + if (payload.iat !== undefined && (!Number.isFinite(payload.iat) || + payload.iat > Date.now() / 1000 + issuer.clockSkewSeconds || payload.exp! <= payload.iat || + (issuer.maxTokenLifetimeSeconds && payload.exp! - payload.iat > issuer.maxTokenLifetimeSeconds))) return null; + const kubernetes = payload["kubernetes.io"] as { serviceaccount?: { uid?: unknown } } | null | undefined; + const uid = kubernetes?.serviceaccount?.uid; + return { issuer: issuer.issuer, subject: payload.sub, ...(typeof uid === "string" ? { serviceAccountUid: uid } : {}) }; + } catch { return null; } + } +} diff --git a/platform/backend/src/identity-audit.ts b/platform/backend/src/identity-audit.ts index f48b91dae..37cf8e11d 100644 --- a/platform/backend/src/identity-audit.ts +++ b/platform/backend/src/identity-audit.ts @@ -12,5 +12,5 @@ export async function auditIdentity(db: AuditStore, event: AuditEvent): Promise< /** Principal and credential attribution for every Platform-native mutation. */ export async function auditAsSubject(db: AuditStore, auth: import("./auth-context.js").AuthContext, event: Omit): Promise { - return auditIdentity(db, { ...event, actorId: auth.actorId, details: { ...event.details, credentialId: auth.credential.id, credentialKind: auth.credential.kind } }); + return auditIdentity(db, { ...event, actorId: auth.actorId, details: { ...event.details, ...auth.credential.workload, credentialId: auth.credential.id, credentialKind: auth.credential.kind } }); } diff --git a/platform/backend/test/workload-issuer.ts b/platform/backend/test/workload-issuer.ts new file mode 100644 index 000000000..84e5aa527 --- /dev/null +++ b/platform/backend/test/workload-issuer.ts @@ -0,0 +1,27 @@ +import { exportJWK, generateKeyPair, SignJWT, type JWTPayload } from "jose"; +import { mkdtemp, writeFile, rm } from "node:fs/promises"; +import { tmpdir } from "node:os"; +import { join } from "node:path"; +import { federationConfig } from "../src/federation-config.js"; +import { WorkloadFederation } from "../src/federation.js"; + +export async function workloadIssuer() { + const issuer = "https://workloads.example.test/"; + const audience = "lightspeed-test"; + const subject = "system:serviceaccount:team-research:apply"; + const dir = await mkdtemp(join(tmpdir(), "lightspeed-issuer-")); + const jwksFile = join(dir, "keys.json"); + const pair = await generateKeyPair("ES256"); + const jwk = { ...await exportJWK(pair.publicKey), kid: "first" }; + await writeFile(jwksFile, JSON.stringify({ keys: [jwk] })); + const trusted = { name: "cluster", issuer, audiences: [audience], algorithms: ["ES256"], + keys: { jwksFile }, maxTokenLifetimeSeconds: 600, clockSkewSeconds: 0 }; + function mint(claims: JWTPayload = {}, kid = jwk.kid) { + const now = Math.floor(Date.now() / 1000); + return new SignJWT({ iss: issuer, aud: audience, sub: subject, iat: now, exp: now + 300, ...claims }) + .setProtectedHeader({ alg: "ES256", kid }).sign(pair.privateKey); + } + return { issuer, audience, subject, dir, jwksFile, jwk, trusted, mint, + federation: new WorkloadFederation(federationConfig.parse({ issuers: [trusted] })), + close: () => rm(dir, { force: true, recursive: true }) }; +} diff --git a/platform/db/migrations/0001_federated_credentials.sql b/platform/db/migrations/0001_federated_credentials.sql new file mode 100644 index 000000000..eb5b46a8f --- /dev/null +++ b/platform/db/migrations/0001_federated_credentials.sql @@ -0,0 +1,14 @@ +CREATE TABLE "federated_credentials" ( + "id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL, + "service_user_id" uuid NOT NULL, + "issuer" text NOT NULL, + "subject" text NOT NULL, + "service_account_uid" text, + "restrictions" jsonb DEFAULT '{}'::jsonb NOT NULL, + "created_at" timestamp with time zone DEFAULT now() NOT NULL, + "last_used_at" timestamp with time zone +); +--> statement-breakpoint +ALTER TABLE "federated_credentials" ADD CONSTRAINT "federated_credentials_service_user_id_service_users_id_fk" FOREIGN KEY ("service_user_id") REFERENCES "public"."service_users"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint +CREATE UNIQUE INDEX "federated_credentials_identity_idx" ON "federated_credentials" USING btree ("issuer","subject");--> statement-breakpoint +CREATE INDEX "federated_credentials_service_user_idx" ON "federated_credentials" USING btree ("service_user_id"); \ No newline at end of file diff --git a/platform/db/migrations/meta/0001_snapshot.json b/platform/db/migrations/meta/0001_snapshot.json new file mode 100644 index 000000000..5df1bffcb --- /dev/null +++ b/platform/db/migrations/meta/0001_snapshot.json @@ -0,0 +1,1951 @@ +{ + "id": "9e7ea8f0-5ff2-48cb-97cf-9d22578bea56", + "prevId": "9921a697-ee79-4d7e-acc1-6ba8a08a264c", + "version": "7", + "dialect": "postgresql", + "tables": { + "public.account": { + "name": "account", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "account_id": { + "name": "account_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "provider_id": { + "name": "provider_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "access_token": { + "name": "access_token", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "refresh_token": { + "name": "refresh_token", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "id_token": { + "name": "id_token", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "access_token_expires_at": { + "name": "access_token_expires_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "refresh_token_expires_at": { + "name": "refresh_token_expires_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "scope": { + "name": "scope", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "password": { + "name": "password", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true + } + }, + "indexes": { + "account_userId_idx": { + "name": "account_userId_idx", + "columns": [ + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "account_user_id_user_id_fk": { + "name": "account_user_id_user_id_fk", + "tableFrom": "account", + "tableTo": "user", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.apikey": { + "name": "apikey", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "config_id": { + "name": "config_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'default'" + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "start": { + "name": "start", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "reference_id": { + "name": "reference_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "prefix": { + "name": "prefix", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "key": { + "name": "key", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "refill_interval": { + "name": "refill_interval", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "refill_amount": { + "name": "refill_amount", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "last_refill_at": { + "name": "last_refill_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "enabled": { + "name": "enabled", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "rate_limit_enabled": { + "name": "rate_limit_enabled", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "rate_limit_time_window": { + "name": "rate_limit_time_window", + "type": "integer", + "primaryKey": false, + "notNull": false, + "default": 86400000 + }, + "rate_limit_max": { + "name": "rate_limit_max", + "type": "integer", + "primaryKey": false, + "notNull": false, + "default": 10 + }, + "request_count": { + "name": "request_count", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "remaining": { + "name": "remaining", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "last_request": { + "name": "last_request", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "expires_at": { + "name": "expires_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true + }, + "permissions": { + "name": "permissions", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "metadata": { + "name": "metadata", + "type": "text", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "apikey_config_idx": { + "name": "apikey_config_idx", + "columns": [ + { + "expression": "config_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "apikey_reference_idx": { + "name": "apikey_reference_idx", + "columns": [ + { + "expression": "reference_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "apikey_key_idx": { + "name": "apikey_key_idx", + "columns": [ + { + "expression": "key", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.device_code": { + "name": "device_code", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "device_code": { + "name": "device_code", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "user_code": { + "name": "user_code", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "expires_at": { + "name": "expires_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "last_polled_at": { + "name": "last_polled_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "polling_interval": { + "name": "polling_interval", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "client_id": { + "name": "client_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "scope": { + "name": "scope", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "approval_access_version": { + "name": "approval_access_version", + "type": "integer", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "device_code_device_code_idx": { + "name": "device_code_device_code_idx", + "columns": [ + { + "expression": "device_code", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "device_code_user_code_idx": { + "name": "device_code_user_code_idx", + "columns": [ + { + "expression": "user_code", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "device_code_user_id_user_id_fk": { + "name": "device_code_user_id_user_id_fk", + "tableFrom": "device_code", + "tableTo": "user", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.invitation": { + "name": "invitation", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "organization_id": { + "name": "organization_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "email": { + "name": "email", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "role": { + "name": "role", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'pending'" + }, + "expires_at": { + "name": "expires_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "inviter_id": { + "name": "inviter_id", + "type": "text", + "primaryKey": false, + "notNull": true + } + }, + "indexes": { + "invitation_organizationId_idx": { + "name": "invitation_organizationId_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "invitation_email_idx": { + "name": "invitation_email_idx", + "columns": [ + { + "expression": "email", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "invitation_organization_id_organization_id_fk": { + "name": "invitation_organization_id_organization_id_fk", + "tableFrom": "invitation", + "tableTo": "organization", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "invitation_inviter_id_user_id_fk": { + "name": "invitation_inviter_id_user_id_fk", + "tableFrom": "invitation", + "tableTo": "user", + "columnsFrom": [ + "inviter_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.member": { + "name": "member", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "organization_id": { + "name": "organization_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "role": { + "name": "role", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'member'" + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true + } + }, + "indexes": { + "member_organizationId_idx": { + "name": "member_organizationId_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "member_userId_idx": { + "name": "member_userId_idx", + "columns": [ + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "member_organization_user_idx": { + "name": "member_organization_user_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "member_organization_id_organization_id_fk": { + "name": "member_organization_id_organization_id_fk", + "tableFrom": "member", + "tableTo": "organization", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "member_user_id_user_id_fk": { + "name": "member_user_id_user_id_fk", + "tableFrom": "member", + "tableTo": "user", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.organization": { + "name": "organization", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "slug": { + "name": "slug", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "logo": { + "name": "logo", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true + }, + "metadata": { + "name": "metadata", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "personal_user_id": { + "name": "personal_user_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "universe_quota": { + "name": "universe_quota", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "base_universe_role": { + "name": "base_universe_role", + "type": "text", + "primaryKey": false, + "notNull": false, + "default": "'viewer'" + }, + "default_protected": { + "name": "default_protected", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "require_protected": { + "name": "require_protected", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "membership_policy": { + "name": "membership_policy", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'{}'::jsonb" + } + }, + "indexes": { + "organization_slug_uidx": { + "name": "organization_slug_uidx", + "columns": [ + { + "expression": "slug", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "organization_personal_user_id_user_id_fk": { + "name": "organization_personal_user_id_user_id_fk", + "tableFrom": "organization", + "tableTo": "user", + "columnsFrom": [ + "personal_user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "organization_slug_unique": { + "name": "organization_slug_unique", + "nullsNotDistinct": false, + "columns": [ + "slug" + ] + }, + "organization_personal_user_id_unique": { + "name": "organization_personal_user_id_unique", + "nullsNotDistinct": false, + "columns": [ + "personal_user_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.session": { + "name": "session", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "expires_at": { + "name": "expires_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true + }, + "token": { + "name": "token", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true + }, + "ip_address": { + "name": "ip_address", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "user_agent": { + "name": "user_agent", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "active_organization_id": { + "name": "active_organization_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "impersonated_by": { + "name": "impersonated_by", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "access_version": { + "name": "access_version", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "session_kind": { + "name": "session_kind", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'browser'" + } + }, + "indexes": { + "session_userId_idx": { + "name": "session_userId_idx", + "columns": [ + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "session_user_id_user_id_fk": { + "name": "session_user_id_user_id_fk", + "tableFrom": "session", + "tableTo": "user", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "session_token_unique": { + "name": "session_token_unique", + "nullsNotDistinct": false, + "columns": [ + "token" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.user": { + "name": "user", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "email": { + "name": "email", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "email_verified": { + "name": "email_verified", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "image": { + "name": "image", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "role": { + "name": "role", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "banned": { + "name": "banned", + "type": "boolean", + "primaryKey": false, + "notNull": false, + "default": false + }, + "ban_reason": { + "name": "ban_reason", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "ban_expires": { + "name": "ban_expires", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "identity_source": { + "name": "identity_source", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'local'" + }, + "oidc_issuer": { + "name": "oidc_issuer", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "oidc_subject": { + "name": "oidc_subject", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "directory_groups": { + "name": "directory_groups", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'[]'::jsonb" + }, + "company_admitted": { + "name": "company_admitted", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "provider_checked_at": { + "name": "provider_checked_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "emergency_admin": { + "name": "emergency_admin", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "access_version": { + "name": "access_version", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + } + }, + "indexes": { + "user_oidc_identity_idx": { + "name": "user_oidc_identity_idx", + "columns": [ + { + "expression": "oidc_issuer", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "oidc_subject", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "user_email_unique": { + "name": "user_email_unique", + "nullsNotDistinct": false, + "columns": [ + "email" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.verification": { + "name": "verification", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "identifier": { + "name": "identifier", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "value": { + "name": "value", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "expires_at": { + "name": "expires_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "verification_identifier_idx": { + "name": "verification_identifier_idx", + "columns": [ + { + "expression": "identifier", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.credential_bindings": { + "name": "credential_bindings", + "schema": "", + "columns": { + "key_id": { + "name": "key_id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "service_user_id": { + "name": "service_user_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "restrictions": { + "name": "restrictions", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'{}'::jsonb" + }, + "created_by": { + "name": "created_by", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "credential_bindings_user_idx": { + "name": "credential_bindings_user_idx", + "columns": [ + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "credential_bindings_service_user_idx": { + "name": "credential_bindings_service_user_idx", + "columns": [ + { + "expression": "service_user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "credential_bindings_key_id_apikey_id_fk": { + "name": "credential_bindings_key_id_apikey_id_fk", + "tableFrom": "credential_bindings", + "tableTo": "apikey", + "columnsFrom": [ + "key_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "credential_bindings_user_id_user_id_fk": { + "name": "credential_bindings_user_id_user_id_fk", + "tableFrom": "credential_bindings", + "tableTo": "user", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "credential_bindings_service_user_id_service_users_id_fk": { + "name": "credential_bindings_service_user_id_service_users_id_fk", + "tableFrom": "credential_bindings", + "tableTo": "service_users", + "columnsFrom": [ + "service_user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "credential_bindings_one_principal": { + "name": "credential_bindings_one_principal", + "value": "(\"credential_bindings\".\"user_id\" IS NOT NULL) <> (\"credential_bindings\".\"service_user_id\" IS NOT NULL)" + } + }, + "isRLSEnabled": false + }, + "public.federated_credentials": { + "name": "federated_credentials", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "service_user_id": { + "name": "service_user_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "issuer": { + "name": "issuer", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "subject": { + "name": "subject", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "service_account_uid": { + "name": "service_account_uid", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "restrictions": { + "name": "restrictions", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'{}'::jsonb" + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "last_used_at": { + "name": "last_used_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "federated_credentials_identity_idx": { + "name": "federated_credentials_identity_idx", + "columns": [ + { + "expression": "issuer", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "subject", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "federated_credentials_service_user_idx": { + "name": "federated_credentials_service_user_idx", + "columns": [ + { + "expression": "service_user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "federated_credentials_service_user_id_service_users_id_fk": { + "name": "federated_credentials_service_user_id_service_users_id_fk", + "tableFrom": "federated_credentials", + "tableTo": "service_users", + "columnsFrom": [ + "service_user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.identity_audit": { + "name": "identity_audit", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "actor_id": { + "name": "actor_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "action": { + "name": "action", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "target_id": { + "name": "target_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "universe_id": { + "name": "universe_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "outcome": { + "name": "outcome", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "details": { + "name": "details", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'{}'::jsonb" + } + }, + "indexes": { + "identity_audit_created_idx": { + "name": "identity_audit_created_idx", + "columns": [ + { + "expression": "created_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.platform_settings": { + "name": "platform_settings", + "schema": "", + "columns": { + "key": { + "name": "key", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "value": { + "name": "value", + "type": "jsonb", + "primaryKey": false, + "notNull": true + }, + "updated_by": { + "name": "updated_by", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.service_users": { + "name": "service_users", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "enabled": { + "name": "enabled", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "role": { + "name": "role", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'member'" + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "service_users_organization_idx": { + "name": "service_users_organization_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "service_users_organization_name_idx": { + "name": "service_users_organization_name_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "name", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "service_users_organization_id_organization_id_fk": { + "name": "service_users_organization_id_organization_id_fk", + "tableFrom": "service_users", + "tableTo": "organization", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.universe_grants": { + "name": "universe_grants", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "universe_id": { + "name": "universe_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "service_user_id": { + "name": "service_user_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "role": { + "name": "role", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "universe_grants_user_idx": { + "name": "universe_grants_user_idx", + "columns": [ + { + "expression": "universe_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "universe_grants_service_user_idx": { + "name": "universe_grants_service_user_idx", + "columns": [ + { + "expression": "universe_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "service_user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "universe_grants_universe_id_universes_id_fk": { + "name": "universe_grants_universe_id_universes_id_fk", + "tableFrom": "universe_grants", + "tableTo": "universes", + "columnsFrom": [ + "universe_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "universe_grants_user_id_user_id_fk": { + "name": "universe_grants_user_id_user_id_fk", + "tableFrom": "universe_grants", + "tableTo": "user", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "universe_grants_service_user_id_service_users_id_fk": { + "name": "universe_grants_service_user_id_service_users_id_fk", + "tableFrom": "universe_grants", + "tableTo": "service_users", + "columnsFrom": [ + "service_user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "universe_grants_one_principal": { + "name": "universe_grants_one_principal", + "value": "(\"universe_grants\".\"user_id\" IS NOT NULL) <> (\"universe_grants\".\"service_user_id\" IS NOT NULL)" + } + }, + "isRLSEnabled": false + }, + "public.universes": { + "name": "universes", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "lightspeed_universe_id": { + "name": "lightspeed_universe_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "handle": { + "name": "handle", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "created_by": { + "name": "created_by", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "access_policy": { + "name": "access_policy", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'{}'::jsonb" + }, + "runtime_configuration": { + "name": "runtime_configuration", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'{}'::jsonb" + }, + "icon": { + "name": "icon", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'orbit'" + }, + "icon_color": { + "name": "icon_color", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'default'" + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'active'" + }, + "features": { + "name": "features", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'{}'::jsonb" + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "universes_organization_id_organization_id_fk": { + "name": "universes_organization_id_organization_id_fk", + "tableFrom": "universes", + "tableTo": "organization", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "universes_lightspeed_universe_id_unique": { + "name": "universes_lightspeed_universe_id_unique", + "nullsNotDistinct": false, + "columns": [ + "lightspeed_universe_id" + ] + }, + "universes_handle_unique": { + "name": "universes_handle_unique", + "nullsNotDistinct": false, + "columns": [ + "handle" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + } + }, + "enums": {}, + "schemas": {}, + "sequences": {}, + "roles": {}, + "policies": {}, + "views": {}, + "_meta": { + "columns": {}, + "schemas": {}, + "tables": {} + } +} \ No newline at end of file diff --git a/platform/db/migrations/meta/_journal.json b/platform/db/migrations/meta/_journal.json index ecc0f1113..d1c282273 100644 --- a/platform/db/migrations/meta/_journal.json +++ b/platform/db/migrations/meta/_journal.json @@ -8,6 +8,13 @@ "when": 1794949711889, "tag": "0000_initial_platform", "breakpoints": true + }, + { + "idx": 1, + "version": "7", + "when": 1795096286064, + "tag": "0001_federated_credentials", + "breakpoints": true } ] } \ No newline at end of file diff --git a/platform/db/scripts/check-migrations.ts b/platform/db/scripts/check-migrations.ts index a909ac3c8..93d3bbe17 100644 --- a/platform/db/scripts/check-migrations.ts +++ b/platform/db/scripts/check-migrations.ts @@ -113,7 +113,7 @@ async function requirePlatformShape(pool: pg.Pool): Promise { await requireTable(pool, "member"); await requireTable(pool, "identity_audit"); await requireTable(pool, "platform_settings"); - for (const table of ["apikey", "service_users", "credential_bindings", "universe_grants", "device_code"]) { + for (const table of ["apikey", "service_users", "credential_bindings", "federated_credentials", "universe_grants", "device_code"]) { await requireTable(pool, table); } await requireColumn(pool, "user", "oidc_subject"); diff --git a/platform/db/src/schema/platform.ts b/platform/db/src/schema/platform.ts index e15e7fcfe..6a17a30b0 100644 --- a/platform/db/src/schema/platform.ts +++ b/platform/db/src/schema/platform.ts @@ -112,6 +112,21 @@ export const credentialBindings = pgTable("credential_bindings", { index("credential_bindings_service_user_idx").on(table.serviceUserId), ]); +/** Bind the verified issuer identifier, so reusing a configuration name cannot transfer authority. */ +export const federatedCredentials = pgTable("federated_credentials", { + id: uuid("id").primaryKey().defaultRandom(), + serviceUserId: uuid("service_user_id").notNull().references(() => serviceUsers.id, { onDelete: "cascade" }), + issuer: text("issuer").notNull(), + subject: text("subject").notNull(), + serviceAccountUid: text("service_account_uid"), + restrictions: jsonb("restrictions").$type().default({}).notNull(), + createdAt: createdAt(), + lastUsedAt: timestamp("last_used_at", { withTimezone: true }), +}, table => [ + uniqueIndex("federated_credentials_identity_idx").on(table.issuer, table.subject), + index("federated_credentials_service_user_idx").on(table.serviceUserId), +]); + export const universesRelations = relations(universes, ({ one }) => ({ organization: one(organization, { fields: [universes.organizationId], diff --git a/platform/shared/contract/platform.schema.json b/platform/shared/contract/platform.schema.json index c41d3d440..da1780614 100644 --- a/platform/shared/contract/platform.schema.json +++ b/platform/shared/contract/platform.schema.json @@ -45,7 +45,8 @@ "session", "cliSession", "personalKey", - "serviceUserKey" + "serviceUserKey", + "federated" ] }, "id": { @@ -186,7 +187,8 @@ "session", "cliSession", "personalKey", - "serviceUserKey" + "serviceUserKey", + "federated" ] }, "id": { diff --git a/platform/shared/src/session-api.ts b/platform/shared/src/session-api.ts index 5a12525c5..a58f36f16 100644 --- a/platform/shared/src/session-api.ts +++ b/platform/shared/src/session-api.ts @@ -2,7 +2,7 @@ import { z } from "zod"; export const platformSessionViewSchema = z.object({ principal: z.object({ kind: z.enum(["user", "serviceUser"]), id: z.string(), name: z.string(), email: z.string().nullable() }), - credential: z.object({ kind: z.enum(["session", "cliSession", "personalKey", "serviceUserKey"]), id: z.string() }), + credential: z.object({ kind: z.enum(["session", "cliSession", "personalKey", "serviceUserKey", "federated"]), id: z.string() }), session: z.object({ id: z.string(), createdAt: z.string().datetime(), expiresAt: z.string().datetime() }).nullable(), }); export const SESSION_OPERATIONS = { diff --git a/release/metadata.env b/release/metadata.env index c98b32f93..d5118e02f 100644 --- a/release/metadata.env +++ b/release/metadata.env @@ -19,5 +19,5 @@ LIGHTSPEED_CONTROLLER_PROTOCOL_VERSION=4 LIGHTSPEED_SCHEMA_REVISION=7 # Drizzle journal length and the oldest platform migration boundary accepted by # the current release's automated upgrade gate. -LIGHTSPEED_PLATFORM_SCHEMA_REVISION=1 +LIGHTSPEED_PLATFORM_SCHEMA_REVISION=2 LIGHTSPEED_PLATFORM_UPGRADE_FROM=0000_initial_platform