Skip to content

feat(infrastructure): manage public sharing in setup - #449

Draft
weastler wants to merge 2 commits into
build/hub/newfrom
weastler-public-sharing-terraform-wizard
Draft

weastler wants to merge 2 commits into
build/hub/newfrom
weastler-public-sharing-terraform-wizard

Conversation

@weastler

@weastler weastler commented Dec 1, 2026

Copy link
Copy Markdown
Contributor

Agent assessment

Self-reported assessment, not an independent review.

Assessed revision: f6dac1cdfd43ece7756e570ed6b8b51e0f9b603e

Dimension Assessment Rationale
Change confidence 8/10 ↑ Follows the #432 private prototype service pattern, sharing its state guard, grant checks and certificate binding.
↑ A separate agent wrote the tests: 1217 installer tests, 115 release-keeper tests and 10 Terraform plan tests pass locally.
↑ One independent review passed the exact head; its one finding (empty saved state with Off) is fixed.
↓ Plan-level only: nothing has run against real Azure, so storage refresh by the workflow identity, the reader's revision start, and the custom-domain certificate flow are unverified.
↓ CI not yet inspected for this branch.

Why

PR 1 (#438) added the read-only public share reader, and PR 2 (#448) adds Hub's export, share records and UI. Neither is deployed. This is PR 3 of ADR 0003: the setup wizard and Terraform now install and manage public sharing, so turning it on, off or back is a reviewed, repeatable Update step, as #432 did for the private prototype service. Sharing does nothing in Hub until PR 2 lands.

What changes

One new Update question. After the private prototype service, Update asks how to set public sharing:

  • Off is the default, on first install and on upgrade. A configuration that never turned sharing on creates nothing. After sharing has been on, Off keeps a reader placeholder without ingress, removes Hub's export grant, and keeps all storage and data.
  • On creates or updates the export storage, the reader and the grants, then releases Hub with its sharing settings.
  • Remove is the rollback. It deletes the reader app, its custom domain and every reader and Hub export grant, and keeps the export storage, container, data, environment and identity.

Create keeps sharing off without asking, because the decision depends on Hub's hostname. Non-default choices are saved as publicShare in the installation configuration, so non-interactive Update applies them, and re-running with the same choice changes only the image.

Hub's hostname. Every generated azurecontainerapps.io hostname is one site, so On is refused while Hub's origin is generated. Only then does the wizard offer the non-production override: it shows the warning and requires the operator to select that the installation isn't production, then saves allowSharedSite and sets HUB_PUBLIC_SHARE_ALLOW_SHARED_SITE=true. It's refused when Hub has a custom domain, so Production never receives it. The installer has no production marker, so the override relies on that selection plus Production's custom domain. On also needs HUB_APPLICATION_ORIGIN and complete GitHub sign-in, matching PR 2's startup checks.

What's created, in a new <name>-share group:

flowchart LR
  hub["Hub app (API and workers)"] -- "Storage Blob Data Contributor, container only" --> exports[("&lt;name&gt;pub / public-share-exports")]
  reader["&lt;name&gt;-share reader app"] -- "Storage Blob Data Reader, listing denied" --> exports
  reader -- AcrPull --> acr["Installation registry"]
  env["&lt;name&gt;-share-environment (no subnet)"] -. logs .-> logs["Hub's Log Analytics"]
  reader --- env
Loading
  • A separate storage account and container with shared keys and anonymous access off. Blobs aren't versioned or soft-deleted, because Hub deletes copies within 24 hours; the container can be restored for 7 days.
  • The reader app runs Hub's image digest with the reader's start command, HTTPS-only ingress and TCP probes. It has its own identity and environment, with no path to Hub's database, Key Vault or storage.
  • The account, container, environment, identity and group have prevent_destroy. The plan check allows only creates, reader app updates, and deletions of the reader app, its grants, its custom domain and Hub's grant.

Settings. Hub gets HUB_PUBLIC_SHARE_ENABLED, HUB_PUBLIC_SHARE_ORIGIN, HUB_PUBLIC_SHARE_STORAGE_ACCOUNT, HUB_PUBLIC_SHARE_STORAGE_CONTAINER and, with the override, HUB_PUBLIC_SHARE_ALLOW_SHARED_SITE, all unset when off. The reader gets only its own PUBLIC_SHARE_* settings and AZURE_CLIENT_ID. Links use the reader's generated hostname. An optional custom domain is bound with a managed certificate after its DNS records resolve; then Hub's origin switches to it and the reader accepts both.

Order. As in #432, Update applies what the running Hub may still use before the release, then removes what the new Hub no longer uses, only if the serving Hub still has the released settings. Saved state uses the same fail-closed lineage checks. Post-setup refuses to change Hub's origin while sharing is on.

Releases from GitHub Actions. A new "Keep public sharing" step copies Hub's live HUB_PUBLIC_SHARE_* settings into the release, checks them against the reader's saved state, and moves the reader to the release image with a plan that may change nothing else.

Shared code. Grant listing, managed-certificate binding, the state guard's wording and the image-only plan check were extracted from the private prototype service, without changing its behavior.

Known gaps. The workflow identity's refresh of the new storage account, the reader's first start, and the custom-domain certificate flow haven't run against Azure. infrastructure/README.md#public-sharing lists the Staging steps.

weastler and others added 2 commits November 30, 2026 19:26
Add the public sharing Terraform root, setup wizard choice, release
workflow keeper and docs. Sharing is off by default; Remove deletes the
reader and grants but keeps the export storage and data.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Public sharing now needs complete GitHub sign-in, matching Hub's startup
check. Off or Remove after an On that stopped before creating anything
no longer creates the export storage from empty saved state.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot AI adaptive review requested due to automatic review settings December 1, 2026 03:53

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Critical sharing-lifecycle flaws can re-expose revoked links and leave public readers serving after Hub’s sharing settings are removed.

11 open issues
1 file not reviewed
  • infrastructure/azure/public-share/.terraform.lock.hcl: Generated file
What changed in this PR

Adds setup and Azure lifecycle management for the public share reader introduced in #438, preparing deployment support for Hub’s export integration in #448.

Changes:

  • Adds saved Off, On and Remove choices with hostname, sign-in and non-production override checks.
  • Provisions separate export storage, reader resources and scoped grants, with state checks and release ordering.
  • Preserves sharing settings during workflow releases and adds tests and operator guidance.
File Description
scripts/​check-ci-workflows/​index.ts Checks public-sharing release step placement and inputs.
infrastructure/​README.md Documents setup choices, resources, releases and rollback.
infrastructure/​installer/​wizard/​public-share-settings.test.ts Tests wizard persistence, validation and resume behavior.
infrastructure/​installer/​wizard/​index.ts Integrates public-sharing questions and saved choices.
infrastructure/​installer/​types.ts Defines public-sharing configuration types.
infrastructure/​installer/​public-share-choice/​index.ts Implements sharing, hostname and override prompts.
infrastructure/​installer/​public-share-choice/​index.test.ts Tests prompt defaults and accepted choices.
infrastructure/​installer/​index.tsx Updates installer help text.
infrastructure/​installer/​config/​index.ts Parses and validates saved sharing choices.
infrastructure/​installer/​config/​index.test.ts Tests sharing configuration validation and persistence.
infrastructure/​azure/​public-share/​tests/​modes.tftest.hcl Tests enabled, custom-domain, Off and Remove plans.
infrastructure/​azure/​public-share/​tests/​disabled.tftest.hcl Tests disabled defaults and resource restrictions.
infrastructure/​azure/​public-share/​main.tf Defines export storage, reader resources and grants.
infrastructure/​azure/​public-share/​.terraform.lock.hcl Locks the public-share module’s Azure provider.
infrastructure/​azure/​post/​configure/​index.ts Blocks origin changes while sharing is enabled.
infrastructure/​azure/​post/​configure/​index.test.ts Tests origin-change protection.
infrastructure/​azure/​install/​public-share/​settings/​index.ts Calculates target and transitional sharing states.
infrastructure/​azure/​install/​public-share/​settings/​index.test.ts Tests hostname transitions and state validation.
infrastructure/​azure/​install/​public-share/​plan/​index.ts Restricts allowed Terraform resource changes.
infrastructure/​azure/​install/​public-share/​plan/​index.test.ts Tests allowed and blocked plans.
infrastructure/​azure/​install/​public-share/​index.ts Coordinates reader deployment, readiness and cleanup.
infrastructure/​azure/​install/​public-share/​index.test.ts Tests deployment transitions and failure handling.
infrastructure/​azure/​install/​public-share/​hub-environment/​index.ts Validates choices and generates Hub sharing settings.
infrastructure/​azure/​install/​public-share/​hub-environment/​index.test.ts Tests Hub settings and sharing prerequisites.
infrastructure/​azure/​install/​public-share/​grants/​index.ts Verifies reader and Hub export permissions.
infrastructure/​azure/​install/​private-preview/​state-guard/​index.ts Adds service-specific state-guard wording.
infrastructure/​azure/​install/​private-preview/​index.ts Uses the shared certificate-binding helper.
infrastructure/​azure/​install/​private-preview/​hub-environment/​index.ts Exposes the complete GitHub sign-in check.
infrastructure/​azure/​install/​private-preview/​grants/​index.ts Uses shared effective-grant utilities.
infrastructure/​azure/​install/​managed-certificate/​index.ts Extracts managed-certificate binding logic.
infrastructure/​azure/​install/​index.ts Adds sharing preparation and post-release cleanup.
infrastructure/​azure/​install/​index.test.ts Tests integration ordering and prerequisite failures.
infrastructure/​azure/​install/​effective-grants/​index.ts Extracts grant listing, scope and condition checks.
infrastructure/​azure/​install/​approval/​index.ts Adds sharing consequences to deployment approval.
infrastructure/​azure/​deploy-hub/​public-share/​index.ts Preserves live sharing settings and updates reader images.
infrastructure/​azure/​deploy-hub/​public-share/​index.test.ts Tests release preservation and rejection paths.
infrastructure/​azure/​deploy-hub/​private-preview/​index.ts Makes the image-change guard’s failure handler reusable.
hub/​docs/​deployment.md Documents reader deployment and installer-owned settings.
.github/​workflows/​hub-infrastructure.yml Adds public-share Terraform and release-tool checks.
.github/​workflows/​hub-azure-deploy.yml Runs public-sharing preservation before Hub rollout.

Review effort: Max (adaptive)

Comment on lines +153 to +156
await writeFile(variablesPath, JSON.stringify({
...variables,
runtime_environment_variables: { ...environment, ...hubSettings },
}), { mode: 0o600 })
for (const grant of reader) {
const match = wanted.find(([role, scope]) => grant.roleDefinitionName === role && same(grant.scope, scope))
if (!match) problems.push(`The share reader identity has an unexpected grant: ${grant.id}.`)
else if (!unexpectedOnly && !match[2](grant))
Comment on lines +133 to +136
const snapshot = await terraform.stateSnapshot()
if (choice.reader !== "on" && !stateHasResources(snapshot))
return { inputs: hubShareInputs(inputs), finish: async () => [] }
const current = readShareState(snapshot)
read, expectedGrants(expand, (existingReader as string[])[0]), { unexpectedOnly: true },
)
if (problems.length) block(`${problems.join("\n")}\nRemove or review that access before retrying. No changes were made.`)
const { bound } = await applyVariables(expand)
Comment on lines +129 to +131
const origins = [readerEnv.get("PUBLIC_SHARE_GENERATED_ORIGIN"), readerEnv.get("PUBLIC_SHARE_CUSTOM_ORIGIN")]
const mismatched = [
["the link origin", origins.includes(hubSettings.HUB_PUBLIC_SHARE_ORIGIN)],
Comment on lines +33 to +35
const wanted: [string, string, (grant: Parameters<typeof deniesListing>[0]) => boolean][] =
expected.reader === "absent"
? []
}
// A sharing Hub keeps sharing while a new reader revision starts; first enablement waits for it.
if (ready || hubShares) {
const origin = choice.hostname && bound ? `https://${choice.hostname}` : generated
reader,
custom_hostname: hostname,
bind_custom_hostname: hostname !== null && (current.boundHostname === hostname || dnsReady),
writer: enabled,
Comment on lines +181 to +182
# Its own environment, without a subnet: no network path to Hub's database, Key Vault or storage.
resource "azurerm_container_app_environment" "share" {
Comment on lines +46 to +58
for (const [role, scope] of unexpectedOnly || !expected.readerPrincipalId ? [] : wanted)
if (!reader.some((grant) => grant.roleDefinitionName === role && same(grant.scope, scope)))
problems.push(`The share reader identity is missing ${role} on ${scope}.`)
const hub = (await effectiveGrants(read, expected.subscriptionId, expected.hubPrincipalId))
.filter((grant) => reaches(grant.scope, expected.containerId))
const writers = hub.filter((grant) =>
grant.roleDefinitionName === writerRole && same(grant.scope, expected.containerId) &&
same(grant.principalId, expected.hubPrincipalId))
for (const grant of hub)
if (!expected.writer || !writers.includes(grant))
problems.push(`The Hub identity has access to the export container that the wizard does not manage: ${grant.id}.`)
if (!unexpectedOnly && expected.writer && writers.length !== 1)
problems.push(`The Hub identity does not have exactly one ${writerRole} grant on the export container.`)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants