Repository navigation
Conversation
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>
Contributor
There was a problem hiding this comment.
🟡 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
Protect copied settings through Hub release · New Validate listing conditions before apply in unexpected-only mode · New Validate saved state and share group before empty-state shortcut · New Sync pending revocations before restoring public ingress · New Reject missing Hub origin when sharing is enabled · New Check all configurable fields in the image-only guard · New Recognize managed grants left by failed provisioning · New Wait for reader readiness before switching custom origin · New Keep cleanup available while sharing is off · New Enforce or revise the no-route network boundary claim · New Add focused tests for uncovered grant-verification branches · New
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.`) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Agent assessment
Self-reported assessment, not an independent review.
Assessed revision:
f6dac1cdfd43ece7756e570ed6b8b51e0f9b603e↑ 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:
Create keeps sharing off without asking, because the decision depends on Hub's hostname. Non-default choices are saved as
publicSharein 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.iohostname 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 savesallowSharedSiteand setsHUB_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 needsHUB_APPLICATION_ORIGINand complete GitHub sign-in, matching PR 2's startup checks.What's created, in a new
<name>-sharegroup:flowchart LR hub["Hub app (API and workers)"] -- "Storage Blob Data Contributor, container only" --> exports[("<name>pub / public-share-exports")] reader["<name>-share reader app"] -- "Storage Blob Data Reader, listing denied" --> exports reader -- AcrPull --> acr["Installation registry"] env["<name>-share-environment (no subnet)"] -. logs .-> logs["Hub's Log Analytics"] reader --- envprevent_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_CONTAINERand, with the override,HUB_PUBLIC_SHARE_ALLOW_SHARED_SITE, all unset when off. The reader gets only its ownPUBLIC_SHARE_*settings andAZURE_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-sharinglists the Staging steps.