signature-worker¶
Cloudflare Worker that hosts the QMS signature ceremony UI and callback backend.
What It Does¶
- Serves signer-facing ceremony page at
GET /sign. - Accepts stable signer links from QMS workflows and rebuilds signing context from the latest request comment.
- Uses GitHub OAuth App login for identity verification (
read:userscope). - Enforces a second-factor 6-digit signature PIN stored as salted PBKDF2-SHA256 hash in Cloudflare KV.
- Applies automatic PIN TTL deletion after 60 days (
expirationTtl=5184000). - Returns
pin_expiring_soonwhen less than 7 days remain. - Validates signer eligibility against the latest PR signature request comment.
- Posts immutable attestation comment back to the PR (
<!-- SIGNATURE_ATTESTATION_V1 -->).
Endpoints¶
GET /healthzGET /signPOST /auth/startGET /auth/callbackPOST /pin/completePOST /api/pin/status
Runtime Configuration¶
Vars¶
PUBLIC_BASE_URL(example:https://sign.qms.dearauditor.ch)WORKER_VERSION(automatically injected asYYYY-MM-DD-<short git hash>duringnpm run devandnpm run deploy)DEFAULT_OAUTH_PROVIDER(github)ALLOWED_OAUTH_PROVIDERS(github)REPO_ALIASES_JSON(optional JSON object for old-slug to current-slug mapping; example:{"AliakseiT/qms-lite":"AliakseiT/dearauditor-qms-baseline"})QMS_AUTOMATION_BOT_LOGINS(optional comma-, space-, or newline-separated extra GitHub App/bot logins trusted for signature request comments)GITHUB_API_BASE_URL(optional; defaulthttps://api.github.com)
Worker Secrets¶
GITHUB_OAUTH_CLIENT_IDGITHUB_OAUTH_CLIENT_SECRETQMS_BOT_APP_IDQMS_BOT_APP_PRIVATE_KEYQMS_BOT_APP_INSTALLATION_ID(optional; the worker can resolve the installation automatically when omitted)SIGNATURE_STATE_SECRETPIN_PEPPER(server-side pepper for PIN KDF)
KV Binding¶
wrangler.toml must include:
[[kv_namespaces]]binding = "PIN_KV"- valid
idandpreview_id - a valid
PUBLIC_BASE_URLunder[vars]
The committed wrangler.toml uses neutral placeholder values. Replace them before deploy, or let scripts/bootstrap_env.sh write the values from .env.local.
REPO_ALIASES_JSON is optional but useful after a repository rename. The worker includes a built-in compatibility alias from AliakseiT/qms-lite to AliakseiT/dearauditor-qms-baseline, and the JSON map lets you add future rename aliases without code changes.
QMS_AUTOMATION_BOT_LOGINS is optional. Use it when an adopter deploys the automation GitHub App under a different name than the built-in DearAuditor defaults. Each configured app slug also trusts its [bot] login form.
The Worker script name defaults to signature-worker, but adopters can override it with SIGNATURE_WORKER_NAME in .env.local, the bootstrap script's --worker-name flag, or the repository variable SIGNATURE_WORKER_NAME. This matters if you are temporarily exposing the service on workers.dev, because the public URL format is <worker-name>.<account-subdomain>.workers.dev.
GitHub OAuth App¶
Use a standard GitHub OAuth App (not a GitHub App installation flow). In adopter deployments, create this OAuth App under the adopting company's GitHub organization or account so signer identity verification stays inside the adopter's regulated trust boundary:
- Homepage URL:
https://sign.qms.dearauditor.ch - Authorization callback URL:
https://sign.qms.dearauditor.ch/auth/callback - OAuth scope requested by worker:
read:user - Signer full legal name is resolved from
matrices/signer_registry.json(no manual name entry in UI).
GitHub App Access¶
Repository reads and attestation-comment posting use a GitHub App installation, not a personal access token.
In adopter deployments, create this GitHub App under the adopting company's GitHub organization or account and install it only on adopter-controlled repositories that need QMS automation. Do not reuse the public upstream project's GitHub App credentials for an adopter's regulated QMS trust boundary.
Required GitHub App repository permissions:
- Issues:
Read and write - Pull requests:
Read and write - Contents:
Read and write - Workflows:
Read and write - Metadata:
Read-only
Required GitHub App organization permissions:
- Members:
Read-only
Pull requests: Read and write is needed because automation requests reviewers, updates PR metadata, and can merge approved PRs. Contents: Read and write is needed for merge operations and release/tag publication paths that write repository state. Workflows: Read and write is needed because the same GitHub App token is also used by repository automation to merge PRs, including PRs that may modify .github/workflows/. Members: Read-only lets installation tokens resolve collaborators and organization members when reviewer or signer eligibility is evaluated.
Local Development¶
cd services/signature-workercp .dev.vars.example .dev.varsand fill valuesnpm installnpm run dev
The worker UI and /healthz expose the active worker version. The default format is YYYY-MM-DD-<short git hash> in UTC, derived automatically from the checked-out repository state.
Deploy¶
- Manual:
npm run deploy - GitHub Actions manual run (
workflow_dispatch):.github/workflows/4.1_deploy_signature_worker.yml
Hosted Option¶
This repository includes everything needed to self-host the signing worker.
For adopters that prefer not to operate their own worker, the hosted endpoint https://sign.qms.dearauditor.ch may also be offered as a separate service for compatible DearAuditor Open QMS Baseline signing workflows. Any commercial terms, onboarding conditions, or support commitments for hosted use are separate from the open-source repository and are not defined by this README.
Bootstrap Helper¶
Use the bootstrap script to sync .env.local values to GitHub and Cloudflare:
./services/signature-worker/scripts/bootstrap_env.sh --deploy
What it does:
- Upserts repo variable
SIGNATURE_WORKER_NAMEso adopters can change the deployed Worker name without patching the baseline. - Upserts repo variables
SIGNATURE_UI_BASE_URL,PIN_KV_NAMESPACE_ID,PIN_KV_PREVIEW_NAMESPACE_ID,SIGNATURE_REPO_ALIASES_JSON, andQMS_AUTOMATION_BOT_LOGINSwhen values are present. - Sets repo secrets
QMS_BOT_APP_IDandQMS_BOT_APP_PRIVATE_KEY, plus Cloudflare deploy secrets when values are present. - Sets worker secrets for OAuth, GitHub App access, and signing state.
- Writes worker runtime values into
wrangler.tomland.dev.vars. - Writes
.dev.varsfor localwrangler dev. - Validates that KV namespace IDs in
wrangler.tomlare not placeholders before deploy.