Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
8b98c8f
feat(infrastructure): add Azure deployment foundations
weastler Nov 6, 2026
eb477f4
fix(infrastructure): lock Azure providers for Linux CI
weastler Nov 6, 2026
3301038
feat(infrastructure): add guided Azure deployment wizard
weastler Nov 6, 2026
4c891ea
fix(infrastructure): verify complete Hub shutdown and plan placement
weastler Nov 6, 2026
8cc9239
fix(infrastructure): validate provisioning identity boundaries
weastler Nov 6, 2026
b161744
docs(infrastructure): clarify deployment prerequisites and proxy choice
weastler Nov 6, 2026
9595a12
fix(installer): protect deployment inputs and unattended consent
weastler Nov 6, 2026
fd0cb97
chore(infrastructure): merge reviewed deployment foundations
weastler Nov 6, 2026
6af4386
feat(infrastructure): streamline guided installation
weastler Nov 9, 2026
9e5f270
feat(infrastructure): preflight regional SKUs and retry provisioning
weastler Nov 10, 2026
0c55263
feat(infrastructure): add guarded deployment removal
weastler Nov 12, 2026
d540913
chore: integrate latest Hub base
weastler Nov 12, 2026
fd7203c
fix(infrastructure): parse Azure PostgreSQL capability enums
weastler Nov 12, 2026
8f89f9b
fix(infrastructure): harden installer recovery and removal checks
weastler Nov 13, 2026
bbe5e58
chore: integrate Hub root-context image build
weastler Nov 13, 2026
b436496
fix(infrastructure): align approved image snapshots with root builds
weastler Nov 13, 2026
6734b12
refactor(installer): remove one installation per operation
weastler Nov 13, 2026
f8b97c2
feat(infrastructure): configure non-secret runtime settings
weastler Nov 13, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions hub/Dockerfile.dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@
!hub/
!hub/**
!packages/
packages/*
!packages/learning/
packages/learning/*
!packages/learning/package.json
!packages/learning/package-lock.json
!packages/learning/.npmrc
Expand All @@ -19,6 +21,7 @@ hub/.env*
hub/.devcontainer
hub/.local
hub/.npm
hub/.react-router
hub/node_modules
hub/dist
hub/coverage
Expand Down
2 changes: 1 addition & 1 deletion hub/docs/architecture.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ The API responds to a health check and gives signed-in members read access to th

Contributors can use PostgreSQL and Prisma locally or in the devcontainer. The database has a provider-neutral identity transaction foundation with explicit GitHub and single-tenant Microsoft Entra sign-in adapters. A reusable deployment bootstrap secret can enroll a verified provider identity as a Hub administrator. Members can browse a seeded, read-only repository index. The app cannot yet discover real repositories, import Builds, host published previews, edit product data, or support live multi-user reviews.

The [production runtime](deployment.md) serves the built frontend and API and runs both workers in one image. Deployment runs database and job setup separately before starting that image.
The [production runtime](deployment.md) serves the built frontend and API and runs both workers in one image. Deployment runs database and job setup separately before starting that image. The Azure installation uses an explicit startup entrypoint to retrieve configured Key Vault values through each workload's managed identity before importing provisioning, setup, or runtime code. Local entrypoints and direct environment configuration remain unchanged.

## Backend

Expand Down
8 changes: 8 additions & 0 deletions hub/docs/deployment.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,14 @@ The runtime serves built frontend navigation and static files on the API port. U

On termination, combined mode stops all three roles and drains work within the configured deadline. A required role failing or stopping unexpectedly fails the container. Roles remain independently runnable for future deployments; cross-instance WebSocket delivery is not implemented.

### Azure startup secret retrieval

The Azure installation invokes `node dist/server/scripts/azure-entrypoint/index.js runtime`, `setup`, or `provision` instead of using platform-managed Key Vault references. Rebuild and publish the image from this source before applying these commands; earlier images do not contain this entrypoint. `AZURE_CLIENT_ID` explicitly selects the assigned workload identity. `AZURE_KEY_VAULT_SECRET_REFERENCES` is a non-secret JSON map of destination environment names to public-cloud HTTPS Key Vault secret URLs. The entrypoint validates all references, reads their values through the selected identity, and populates the workload's in-memory environment before importing its existing entrypoint. Retrieved secret values never enter Terraform inputs, Azure container configuration, or startup logs.

Runtime and setup require `DATABASE_URL`; setup accepts no additional references. Provisioning requires exactly `DATABASE_URL`, `HUB_MIGRATION_PASSWORD`, and `HUB_RUNTIME_PASSWORD`, with versioned URLs. Runtime may additionally reference validated configuration names, but references cannot replace deployment-owned fields or already-defined values. Retrieval has a shared 30-second startup deadline and cancellation support. Failure prevents workload imports and database work; it does not fall back to operator credentials, a system-assigned identity, or old environment values.

Versioned references make rotation explicit. An unversioned runtime/setup URL is resolved once at startup; there is no background refresh or automatic revision restart. Use the installation's serialized release procedure to load a rotated value. Source development, local image runs with directly supplied protected environment values, and the existing setup/provisioning scripts retain their original entrypoints and behavior.

## Setup before release

Run `npm run setup` from `hub/`, or invoke `node dist/server/scripts/setup/index.js` inside the image. Normal API and worker startup never runs setup.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,298 @@
import { describe, expect, it, onTestFinished, vi } from "vitest"

const mocks = vi.hoisted(() => ({ unexpectedCredential: vi.fn() }))
vi.mock("@azure/identity", () => {
class UnexpectedCredential {
constructor() {
mocks.unexpectedCredential()
throw new Error("Synthetic credential fallback is prohibited")
}
}
return {
ManagedIdentityCredential: UnexpectedCredential,
DefaultAzureCredential: UnexpectedCredential,
AzureCliCredential: UnexpectedCredential,
EnvironmentCredential: UnexpectedCredential,
}
})

import { getAzureKeyVaultSecret } from "."

describe("getAzureKeyVaultSecret()", () => {
it("awaits the vault-audience token before requesting the exact secret version with no redirects", async () => {
const url = `https://fixture.vault.azure.net/secrets/Runtime-Database/${"A".repeat(32)}`
const signal = new AbortController().signal
let issueToken!: (token: { token: string; expiresOnTimestamp: number }) => void
const getToken = vi.fn(
() =>
new Promise<{ token: string; expiresOnTimestamp: number }>((resolve) => {
issueToken = resolve
}),
)
const fetchSecret = vi
.fn<typeof fetch>()
.mockResolvedValue(
new Response(JSON.stringify({ value: "synthetic-database-url" }), { status: 200 }),
)
vi.stubGlobal("fetch", fetchSecret)

const retrieval = getAzureKeyVaultSecret({ url, credential: { getToken }, signal })
void retrieval.catch(() => {})
onTestFinished(async () => {
issueToken?.({
token: "synthetic-bearer-token",
expiresOnTimestamp: Date.now() + 60_000,
})
await retrieval.catch(() => {})
})

expect(getToken).toHaveBeenCalledExactlyOnceWith("https://vault.azure.net/.default", {
abortSignal: signal,
})
expect(fetchSecret).not.toHaveBeenCalled()

issueToken({ token: "synthetic-bearer-token", expiresOnTimestamp: Date.now() + 60_000 })

expect(await retrieval).toBe("synthetic-database-url")
expect(fetchSecret).toHaveBeenCalledTimes(1)
const [input, options] = fetchSecret.mock.calls[0]!
const request = new Request(input, options)
expect(request.url).toBe(`${url}?api-version=7.4`)
expect(request.method).toBe("GET")
expect(request.headers.get("Authorization")).toBe("Bearer synthetic-bearer-token")
expect(["error", "manual"]).toContain(request.redirect)
expect(options?.signal ?? (input instanceof Request ? input.signal : undefined)).toBe(signal)
expect(mocks.unexpectedCredential).not.toHaveBeenCalled()
})

it("preserves an unversioned URL and leaves an empty string for consuming configuration validation", async () => {
const url = "https://fixture.vault.azure.net/secrets/optional-setting"
const signal = new AbortController().signal
const credential = {
getToken: vi.fn().mockResolvedValue({
token: "synthetic-bearer-token",
expiresOnTimestamp: Date.now() + 60_000,
}),
}
const fetchSecret = vi
.fn<typeof fetch>()
.mockResolvedValue(new Response(JSON.stringify({ value: "" }), { status: 200 }))
vi.stubGlobal("fetch", fetchSecret)

expect(await getAzureKeyVaultSecret({ url, credential, signal })).toBe("")
expect(fetchSecret).toHaveBeenCalledTimes(1)
const [input, options] = fetchSecret.mock.calls[0]!
expect(new Request(input, options).url).toBe(`${url}?api-version=7.4`)
})

it.each([
"https://synthetic-user:synthetic-password@fixture.vault.azure.net/secrets/database",
"https://other.example/secrets/database",
"https://fixture.vault.azure.net/secrets/database?token=synthetic-query-token",
])("validates direct integration calls before obtaining a token", async (url) => {
const credential = { getToken: vi.fn() }
const fetchSecret = vi.fn<typeof fetch>()
vi.stubGlobal("fetch", fetchSecret)

const failure = await getAzureKeyVaultSecret({
url,
credential,
signal: new AbortController().signal,
}).catch((error: unknown) => error)

expect(failure).toMatchObject({ name: "AzureKeyVaultSecretError" })
expect(failure).not.toHaveProperty("cause")
expect(String(failure)).not.toMatch(/synthetic-|other\.example|fixture\.vault/)
expect(credential.getToken).not.toHaveBeenCalled()
expect(fetchSecret).not.toHaveBeenCalled()
})

it.each([null, { token: "", expiresOnTimestamp: 1 }])(
"does not fetch a secret or try another credential when managed identity returns no token",
async (token) => {
const credential = { getToken: vi.fn().mockResolvedValue(token) }
const fetchSecret = vi.fn<typeof fetch>()
vi.stubGlobal("fetch", fetchSecret)

await expect(
getAzureKeyVaultSecret({
url: "https://fixture.vault.azure.net/secrets/database",
credential,
signal: new AbortController().signal,
}),
).rejects.toMatchObject({ name: "AzureKeyVaultSecretError" })
expect(credential.getToken).toHaveBeenCalledTimes(1)
expect(fetchSecret).not.toHaveBeenCalled()
expect(mocks.unexpectedCredential).not.toHaveBeenCalled()
},
)

it("replaces token-provider exceptions rather than preserving their messages or causes", async () => {
const original = new Error("synthetic-token-provider-secret", {
cause: { token: "synthetic-provider-token" },
})
const credential = { getToken: vi.fn().mockRejectedValue(original) }
const fetchSecret = vi.fn<typeof fetch>()
vi.stubGlobal("fetch", fetchSecret)

const failure = await getAzureKeyVaultSecret({
url: "https://fixture.vault.azure.net/secrets/database",
credential,
signal: new AbortController().signal,
}).catch((error: unknown) => error)

expect(failure).toBeInstanceOf(Error)
expect(failure).not.toBe(original)
expect(failure).toMatchObject({ name: "AzureKeyVaultSecretError" })
expect(failure).not.toHaveProperty("cause")
expect(String(failure)).not.toMatch(/synthetic-token-provider-secret|synthetic-provider-token/)
expect(fetchSecret).not.toHaveBeenCalled()
expect(credential.getToken).toHaveBeenCalledTimes(1)
expect(mocks.unexpectedCredential).not.toHaveBeenCalled()
})

it.each([201, 302, 403])(
"rejects HTTP %i without accepting its secret-shaped body, following redirects, or retrying",
async (status) => {
const credential = {
getToken: vi.fn().mockResolvedValue({
token: "synthetic-bearer-token",
expiresOnTimestamp: Date.now() + 60_000,
}),
}
const fetchSecret = vi.fn<typeof fetch>().mockResolvedValue(
new Response(JSON.stringify({ value: "synthetic-rejected-body-secret" }), {
status,
headers: { Location: "https://other.example/collect-synthetic-token" },
}),
)
vi.stubGlobal("fetch", fetchSecret)

const failure = await getAzureKeyVaultSecret({
url: "https://fixture.vault.azure.net/secrets/database",
credential,
signal: new AbortController().signal,
}).catch((error: unknown) => error)

expect(failure).toMatchObject({ name: "AzureKeyVaultSecretError" })
expect(failure).not.toHaveProperty("cause")
expect(String(failure)).not.toMatch(/synthetic-|other\.example/)
expect(credential.getToken).toHaveBeenCalledTimes(1)
expect(fetchSecret).toHaveBeenCalledTimes(1)
const [input, options] = fetchSecret.mock.calls[0]!
expect(["error", "manual"]).toContain(new Request(input, options).redirect)
expect(mocks.unexpectedCredential).not.toHaveBeenCalled()
},
)

it.each([null, ["synthetic-body-secret"], { token: "synthetic-body-token" }, { value: 42 }])(
"requires a JSON object with a string secret value",
async (body) => {
const credential = {
getToken: vi.fn().mockResolvedValue({
token: "synthetic-bearer-token",
expiresOnTimestamp: Date.now() + 60_000,
}),
}
const fetchSecret = vi
.fn<typeof fetch>()
.mockResolvedValue(new Response(JSON.stringify(body), { status: 200 }))
vi.stubGlobal("fetch", fetchSecret)

const failure = await getAzureKeyVaultSecret({
url: "https://fixture.vault.azure.net/secrets/database",
credential,
signal: new AbortController().signal,
}).catch((error: unknown) => error)

expect(failure).toMatchObject({ name: "AzureKeyVaultSecretError" })
expect(failure).not.toHaveProperty("cause")
expect(String(failure)).not.toMatch(/synthetic-body-secret|synthetic-body-token/)
expect(fetchSecret).toHaveBeenCalledTimes(1)
},
)

it.each(["transport", "JSON"] as const)(
"redacts secret-bearing %s exceptions without retrying",
async (stage) => {
const original = new Error("synthetic-transport-token synthetic-response-secret", {
cause: new Error("synthetic-private-cause"),
})
const credential = {
getToken: vi.fn().mockResolvedValue({
token: "synthetic-bearer-token",
expiresOnTimestamp: Date.now() + 60_000,
}),
}
const fetchSecret = vi.fn<typeof fetch>()
if (stage === "transport") {
fetchSecret.mockRejectedValue(original)
} else {
const response = new Response('{"value":"synthetic-invalid-json', { status: 200 })
vi.spyOn(response, "json").mockRejectedValue(original)
fetchSecret.mockResolvedValue(response)
}
vi.stubGlobal("fetch", fetchSecret)

const failure = await getAzureKeyVaultSecret({
url: "https://fixture.vault.azure.net/secrets/database",
credential,
signal: new AbortController().signal,
}).catch((error: unknown) => error)

expect(failure).not.toBe(original)
expect(failure).toMatchObject({ name: "AzureKeyVaultSecretError" })
expect(failure).not.toHaveProperty("cause")
expect(String(failure)).not.toMatch(/synthetic-/)
expect(credential.getToken).toHaveBeenCalledTimes(1)
expect(fetchSecret).toHaveBeenCalledTimes(1)
expect(mocks.unexpectedCredential).not.toHaveBeenCalled()
},
)

it("does not obtain a token after cancellation", async () => {
const controller = new AbortController()
controller.abort(new Error("synthetic-abort-secret"))
const credential = { getToken: vi.fn() }
const fetchSecret = vi.fn<typeof fetch>()
vi.stubGlobal("fetch", fetchSecret)

const failure = await getAzureKeyVaultSecret({
url: "https://fixture.vault.azure.net/secrets/database",
credential,
signal: controller.signal,
}).catch((error: unknown) => error)

expect(failure).toMatchObject({ name: "AzureKeyVaultSecretError" })
expect(String(failure)).not.toContain("synthetic-abort-secret")
expect(credential.getToken).not.toHaveBeenCalled()
expect(fetchSecret).not.toHaveBeenCalled()
})

it("does not return a secret when cancellation occurs while decoding the response", async () => {
const controller = new AbortController()
const credential = {
getToken: vi.fn().mockResolvedValue({
token: "synthetic-bearer-token",
expiresOnTimestamp: Date.now() + 60_000,
}),
}
const response = new Response(null, { status: 200 })
vi.spyOn(response, "json").mockImplementation(() => {
controller.abort(new Error("synthetic-abort-token"))
return Promise.resolve({ value: "synthetic-late-secret" })
})
const fetchSecret = vi.fn<typeof fetch>().mockResolvedValue(response)
vi.stubGlobal("fetch", fetchSecret)

const failure = await getAzureKeyVaultSecret({
url: "https://fixture.vault.azure.net/secrets/database",
credential,
signal: controller.signal,
}).catch((error: unknown) => error)

expect(failure).toMatchObject({ name: "AzureKeyVaultSecretError" })
expect(String(failure)).not.toMatch(/synthetic-abort-token|synthetic-late-secret/)
expect(fetchSecret).toHaveBeenCalledTimes(1)
})
})
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
import type { AzureKeyVaultSecretRequest } from "./types.ts"

export async function getAzureKeyVaultSecret({
url,
credential,
signal,
}: AzureKeyVaultSecretRequest): Promise<string> {
let retryable = false
try {
if (
!/^https:\/\/[a-zA-Z0-9-]+\.vault\.azure\.net\/secrets\/[a-zA-Z0-9-]+(?:\/[a-fA-F0-9]{32})?$/.test(
url,
)
) {
throw new Error("Invalid Azure secret URL.")
}
signal.throwIfAborted()
const token = await credential.getToken("https://vault.azure.net/.default", {
abortSignal: signal,
})
if (!token?.token) throw new Error("Azure managed identity returned no token.")
const target = new URL(url)
target.searchParams.set("api-version", "7.4")
const response = await fetch(target, {
method: "GET",
headers: { Authorization: `Bearer ${token.token}` },
redirect: "error",
signal,
})
if (response.status !== 200) {
retryable =
response.status === 403 ||
response.status === 429 ||
response.status === 500 ||
response.status === 502 ||
response.status === 503 ||
response.status === 504
await response.body?.cancel()
throw new Error("Azure Key Vault rejected secret retrieval.")
}
const result: unknown = await response.json()
if (
result === null ||
typeof result !== "object" ||
!("value" in result) ||
typeof result.value !== "string"
) {
throw new Error("Azure Key Vault returned an invalid secret.")
}
signal.throwIfAborted()
return result.value
} catch {
const error = new Error("Azure Key Vault secret retrieval failed.")
error.name = "AzureKeyVaultSecretError"
Object.defineProperty(error, "retryable", { value: retryable })
throw error
}
}
Loading
Loading