diff --git a/.github/workflows/host-app.yml b/.github/workflows/host-app.yml index 4d6a82a..904c606 100644 --- a/.github/workflows/host-app.yml +++ b/.github/workflows/host-app.yml @@ -74,6 +74,9 @@ jobs: env: REPO: ${{ inputs.repo }} REQUESTED_BY: ${{ inputs.requested_by }} + # Approved public apps, edited on the bizops portal's Public apps + # page. Only repo admins (and the portal's token) can change it. + PUBLIC_APPS: ${{ vars.PUBLIC_APPS }} run: scripts/read-platform.sh app # The page the app shows until its first deploy, built from this repo diff --git a/README.md b/README.md index f269c51..92a3121 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,7 @@ Hosts Virtuals' internal apps on Google Cloud Run, so anyone who builds a tool - **Who can open them:** anyone signed in with a `@virtuals.io` Google account. Google checks this (Identity-Aware Proxy) before a request reaches the app. The few apps built for the public, such as the support portal, are open to - everyone instead, once approved in [`public-apps.txt`](public-apps.txt). + everyone instead, once the platform team approves them (see "Public apps"). - **How they deploy:** every push to the app repo's `main` builds and deploys it, in about 3 minutes. @@ -44,7 +44,7 @@ A request is refused unless all of these hold: | `owner` in the repo's `platform.yaml` is the person asking | Only someone who can push to the repo could have written that | | The app passes [the checker](actions/check/check.mjs) | It will deploy and run as expected | | The app name isn't used by another repo | Names are the service's and secrets' names | -| A `public: true` app is listed in [`public-apps.txt`](public-apps.txt) | Opening an app to the internet needs a platform engineer's review | +| A `public: true` app is approved as public (see "Public apps") | Opening an app to the internet needs a platform engineer's say-so | Deploys check again that the app was hosted from the same repo, so one repo can't deploy over another's app. @@ -66,7 +66,31 @@ An app is one Node.js container that: Not available yet, so ask the platform team: Postgres, Redis, scheduled jobs, custom domains, anything bigger than `medium`. Public (no sign-in) apps need -the platform team to add them to [`public-apps.txt`](public-apps.txt). +the platform team's approval (see "Public apps"). + +## Public apps + +An app whose `platform.yaml` says `public: true` is open to anyone, with no +Google sign-in. Hosting refuses it unless the app's name and repo are in this +repo's `PUBLIC_APPS` Actions variable (Settings > Secrets and variables > +Actions > Variables), a JSON list: + +```json +[{ "name": "acp-ticket-cms", "repo": "acp-ticket-cms", "approvedBy": "someone@virtuals.io", "approvedAt": "2026-11-17T00:00:00Z" }] +``` + +- **To approve an app:** open **Tech help → Public apps** in the bizops portal (platform + approvers only), add the app's name and repo, then have its owner host it again with the + **Host an app** form. No change to this repo, no deploy. Only list apps built for the + public, such as a customer support page, never an internal tool. +- **Who can change the list:** the approvers the portal names (`PUBLIC_APP_APPROVERS` in its + `lib/access.ts`), through the portal's GitHub token, and this repo's admins directly. GitHub's + organization audit log records every change. +- **Taking approval away** stops the app being hosted as public again, but doesn't close an + app that is already open. The owner closes it by setting `public: false` and hosting it + again, which puts it behind Google sign-in. To shut it at once, a platform engineer runs + `gcloud run services update --iap --invoker-iam-check --region asia-southeast1 --project virtuals-internal-apps`, + which locks everyone out until the owner hosts it again with `public: false`. ## The Claude plugin diff --git a/actions/check/check.mjs b/actions/check/check.mjs index ad6ae2d..2994d61 100755 --- a/actions/check/check.mjs +++ b/actions/check/check.mjs @@ -150,7 +150,7 @@ if (cfg) { cfg.public ??= false; if (typeof cfg.public !== "boolean") err("platform.yaml: public must be true or false"); - else if (cfg.public) warn("platform.yaml: public: true opens the app to anyone, with no sign-in. Hosting refuses it unless the platform team has approved the app in public-apps.txt"); + else if (cfg.public) warn("platform.yaml: public: true opens the app to anyone, with no sign-in. Hosting refuses it until the platform team approves the app (bizops portal: Tech help → Public apps)"); cfg.needs ??= {}; if (typeof cfg.needs !== "object") err("platform.yaml: needs must be a section (storage: true/false)"); diff --git a/plugin/.claude-plugin/plugin.json b/plugin/.claude-plugin/plugin.json index 5a19275..f7999fe 100644 --- a/plugin/.claude-plugin/plugin.json +++ b/plugin/.claude-plugin/plugin.json @@ -1,7 +1,7 @@ { "name": "virtuals-platform", "description": "How to build internal apps that host on the Virtuals platform (Google Cloud Run, through projects-autodeploy): rules, templates and a checker", - "version": "1.1.0", + "version": "1.1.1", "author": { "name": "Virtuals Protocol" }, "repository": "https://github.com/Virtual-Protocol/projects-autodeploy" } diff --git a/plugin/skills/internal-app/scripts/check.mjs b/plugin/skills/internal-app/scripts/check.mjs index ad6ae2d..2994d61 100755 --- a/plugin/skills/internal-app/scripts/check.mjs +++ b/plugin/skills/internal-app/scripts/check.mjs @@ -150,7 +150,7 @@ if (cfg) { cfg.public ??= false; if (typeof cfg.public !== "boolean") err("platform.yaml: public must be true or false"); - else if (cfg.public) warn("platform.yaml: public: true opens the app to anyone, with no sign-in. Hosting refuses it unless the platform team has approved the app in public-apps.txt"); + else if (cfg.public) warn("platform.yaml: public: true opens the app to anyone, with no sign-in. Hosting refuses it until the platform team approves the app (bizops portal: Tech help → Public apps)"); cfg.needs ??= {}; if (typeof cfg.needs !== "object") err("platform.yaml: needs must be a section (storage: true/false)"); diff --git a/plugin/skills/internal-app/templates/platform.yaml b/plugin/skills/internal-app/templates/platform.yaml index a80f53b..795d5ac 100644 --- a/plugin/skills/internal-app/templates/platform.yaml +++ b/plugin/skills/internal-app/templates/platform.yaml @@ -9,7 +9,7 @@ size: small # small = 1 vCPU / 1 GB, up to 3 copies | medium = 2 vCP # max_copies: 1 # optional: fewer copies than the size allows, e.g. 1 for an app # whose copies would clash over files in its storage folder # public: true # optional: anyone on the internet can open it, with no sign-in. - # Only for apps the platform team approves (public-apps.txt). + # Only for apps the platform team approves in the bizops portal. needs: storage: false # true -> a private Cloud Storage bucket, its name in STORAGE_BUCKET diff --git a/public-apps.txt b/public-apps.txt deleted file mode 100644 index 4dc967c..0000000 --- a/public-apps.txt +++ /dev/null @@ -1,10 +0,0 @@ -# Apps anyone on the internet may open, with no Google sign-in. -# -# Hosting an app whose platform.yaml says "public: true" is refused unless the -# app is listed here, and changes to this file need a platform engineer's -# review like any change to main. Only list apps built for the public, such as -# a customer support page, never an internal tool. -# -# One app per line: - -acp-ticket-cms acp-ticket-cms diff --git a/scripts/provision.sh b/scripts/provision.sh index 472744b..0474510 100755 --- a/scripts/provision.sh +++ b/scripts/provision.sh @@ -76,7 +76,7 @@ if [[ "$STORAGE" == true ]]; then fi if [[ "$PUBLIC" == true ]]; then - # Approved in public-apps.txt (read-platform.sh checked). Turning off + # Approved in PUBLIC_APPS (read-platform.sh checked). Turning off # Cloud Run's invoker check opens it without granting anything to allUsers. step "The Cloud Run service, open to everyone" access=public diff --git a/scripts/read-platform.sh b/scripts/read-platform.sh index 1c06e12..9f8e56e 100755 --- a/scripts/read-platform.sh +++ b/scripts/read-platform.sh @@ -1,9 +1,12 @@ #!/usr/bin/env bash # Reads the app's platform.yaml and checks it against the request: the person # asking must be the owner the repo names, which only someone who can push to -# the repo could have written there, and a public app must be on the reviewed -# list in public-apps.txt. +# the repo could have written there, and a public app must be approved. # scripts/read-platform.sh +# Needs: REPO REQUESTED_BY GITHUB_OUTPUT GITHUB_STEP_SUMMARY +# Optional: PUBLIC_APPS, the approved public apps (this repo's PUBLIC_APPS +# Actions variable, which the bizops portal's Public apps page edits): +# [{"name": "", "repo": "", ...}] set -euo pipefail dir="$1" @@ -40,8 +43,14 @@ storage=$(field .needs.storage) public=$(field .public) if [[ "$public" == true ]]; then - awk -v name="$name" -v repo="$REPO" '$1 == name && $2 == repo { found = 1 } END { exit !found }' public-apps.txt || - fail "platform.yaml says public: true, but \"$name\" isn't an approved public app. Public apps need the platform team's approval: ask them to add it to public-apps.txt in projects-autodeploy." + # Both the name and the repo must match, so approving one app doesn't let + # another repo take its name and be public too. A missing or broken list + # approves nothing. + jq -e --arg name "$name" --arg repo "$REPO" ' + type == "array" and + any(.[]; type == "object" and .name == $name and ((.repo // "") | ascii_downcase) == ($repo | ascii_downcase)) + ' <<<"${PUBLIC_APPS:-[]}" >/dev/null 2>&1 || + fail "platform.yaml says public: true, but \"$name\" from $REPO isn't an approved public app. Public apps need the platform team's approval: ask them to approve it under Tech help → Public apps in the bizops portal, then host it again." else public=false fi diff --git a/templates/app/platform.yaml b/templates/app/platform.yaml index a80f53b..795d5ac 100644 --- a/templates/app/platform.yaml +++ b/templates/app/platform.yaml @@ -9,7 +9,7 @@ size: small # small = 1 vCPU / 1 GB, up to 3 copies | medium = 2 vCP # max_copies: 1 # optional: fewer copies than the size allows, e.g. 1 for an app # whose copies would clash over files in its storage folder # public: true # optional: anyone on the internet can open it, with no sign-in. - # Only for apps the platform team approves (public-apps.txt). + # Only for apps the platform team approves in the bizops portal. needs: storage: false # true -> a private Cloud Storage bucket, its name in STORAGE_BUCKET