Skip to main content

Manage Staging Web App Access

Who can open https://app.qubital-test.com is decided in Cloudflare Zero Trust, not in any repository. Most steps here are for the owner of the Cloudflare account. How the protection works is in Staging Web App Access.

Give someone access​

  1. Cloudflare dashboard → Zero Trust → Access controls → Policies → email-access-policy → Edit.
  2. Under Include, add their email address to the Emails list.
  3. Save.

They can sign in at once: open https://app.qubital-test.com, enter that email, then the code Cloudflare sends.

If the policy is also attached to other applications (such as this docs site), the address opens those too.

Remove someone​

Do both steps. The first stops new sign-ins; the second ends the sessions already open, which otherwise last up to a month.

  1. Zero Trust → Access controls → Policies → email-access-policy → Edit → remove their address → Save. If the policy is attached to other applications, this removes them from those too.
  2. Zero Trust → Team & Resources → Users → tick the person → Action → Revoke.

Sign out​

Open https://app.qubital-test.com/cdn-cgi/access/logout. This signs you out of every Access-protected application of the organisation, this docs site included.

Keep CI's service token alive​

The token ci-staging-web-smoke lets the staging deploy's smoke check through Access. It expires a year after it was created.

Why it matters: once it expires, the smoke check of every staging deploy fails. The new version is already live on staging, but the deploy is recorded as failed, and a web release only ships a commit whose staging deploy succeeded. So no commit deployed after the token expires can be released until the token works again.

  • The warning: the account's alert Expiring Service Token Alert (Cloudflare dashboard → Manage account → Alerts) covers all service tokens, current and future, and emails a week before one expires. A second alert, Leaked Service Token Alert, emails if a token is reported as leaked. If one is disabled, turn it back on: the three dots → Enable. If one is missing, add it with Create a notification, choosing the event Expiring Access Service Token Alert (or Leaked Access Service Token Alert), then All service tokens.
  • Extending it: Zero Trust → Access controls → Service credentials → Service Tokens → ci-staging-web-smoke → Refresh. This adds a year and keeps the same values, so nothing changes in GitHub.

Replace CI's token secret​

Do this when the secret may have been exposed, or as a routine rotation. The Client ID stays the same; only the Client Secret changes.

  1. Zero Trust → Access controls → Service credentials → Service Tokens → ci-staging-web-smoke → the three dots → Rotate secret.

  2. Keep the current secret valid for: 1 hour for a routine rotation, or Revoke immediately if it was exposed. Then Rotate. Cloudflare shows the new Client Secret once.

  3. Store it in GitHub. The command prompts for the value and doesn't echo it:

    gh secret set STAGING_ACCESS_CLIENT_SECRET -R StartingQuoTechDivision/qubital-apps
  4. Replace it in the password manager.

  5. If Cloudflare had disabled the token after a leak report, turn it on again: the three dots → Enable token → Enable. Rotating doesn't turn it back on.

  6. Check the new secret right away; the next deploy may be days later. In bash, paste each value when asked. They aren't echoed, and they don't appear in the command line or the shell history:

    read -rs -p 'Client ID: ' id; echo
    read -rs -p 'Client Secret: ' secret; echo
    printf 'CF-Access-Client-Id: %s\nCF-Access-Client-Secret: %s\n' "$id" "$secret" \
    | curl -sS -o /dev/null -w '%{http_code}\n' -H @- https://app.qubital-test.com/healthz
    unset id secret

    200 means it works. Anything else (a 302 to the sign-in page, a 401 or a 403) means Access refused the token.

Never paste the secret anywhere else: not in a chat, an issue, a pull request or a log.

Re-check Cloudflare's address list​

Do this once a year, or when Cloudflare announces a change. In a checkout of qubital-infra, compare Cloudflare's IPv4 list with the allow list in staging/webapp.json:

diff <(curl -s https://www.cloudflare.com/ips-v4/ | sort) \
<(jq -r '.. | .addresses? // empty | .[]' staging/webapp.json | sort)

No output means they match. Otherwise, open a pull request in qubital-infra that copies Cloudflare's list into staging/webapp.json. Merging it applies the new list without restarting the web app.