Castis edge API
This API is not built yet: this page specifies the Castis edge API that coreapi must add so hotel sites can be approved, check in and renew their license.
coreapi must be updated for this. The setup wizard in this repo (
setup-agent/cloud.py) already calls the endpoints below, but they don't exist yet. They are to be added to coreapi (Castis side, in its own repo).Until coreapi ships them and
IBC_CLOUD_URLis set (setup-agent/defaults.env), a real install stops at the wizard's "Approval by Castis" step. For testing,setup-agent/dev/mock_edge_api.pyimplements the same contract with fake credentials.
Endpoints at a glance (6)
| GET | / | Called while the owner types the address. |
| POST | /v1/edge/registrations | Sent once, when the owner presses Install. |
| GET | /v1/edge/registrations/{id} | The wizard polls this every 15 s while the registration is pending, and at once after an approval token is accepted. |
| POST | / | The only way a registration is approved. |
| POST | /v1/edge/registrations/{id}/ready | Sent once the site is up. |
| POST | /v1/edge/sites/{registrationId}/checkin | Requires the bearer installSecret. |
coreapi to-do list (summary)¶
Everything coreapi needs for on-prem hotels, in one place. Details are in the sections below; nothing here is implemented yet.
Must have, before a real hotel can be installed
- [ ] Products per hotel (modules): the approval token takes modules (names from setup-agent/modules.txt: today playout, tellyboard, later spatio and any mix; default: the legacy products playout + tellyboard; the real Console should make staff choose explicitly), copies it to the registration, and signs it into the license as a modules claim. Staff can change it later (new license version; the check-in agent applies it). A license without the claim means the legacy products only, never "all known". Unknown names are rejected when a token is created and ignored by old sites. Contract in setup-agent/dev/mock_edge_api.py, behaviour in modules.md. The license must be signed with a key the site does not hold (the key-only bundle); otherwise a site could re-sign its own modules. authapi/coreapi must refuse an unlicensed product
- [ ] Edge mode on hotels: turn off platform features (self-signup, platform email). coreapi must start and run with the COREAPI_PLATFORM_EMAIL_* settings absent. It does today (sending returns an error; welcome/deleted emails only log it), but keep it that way, and make the verification endpoint answer "not available on this installation"
- [ ] Subdomain check: GET /v1/edge/subdomains/{name}
- [ ] Registration: POST /v1/edge/registrations, storing only the hash of installSecret
- [ ] Approval tokens, the only way a site is approved: staff create a token in the Console with no customer details (24 h, 3 uses by default) and send it to the installer, who enters it at the wizard's waiting step. There's no approve button for registrations. Site endpoint POST /v1/edge/registrations/{id}/approval-token; staff side under Castis side: approval tokens
- [ ] Registrations in the Console: list them, with the token that approved each; reject one with a reason if needed
- [ ] On approval:
- create the acme-dns account, and the _acme-challenge CNAME in Cloudflare (with coreapi's own token)
- issue the license bundle (key + key pair, ideally a key pair per hotel)
- [ ] Status polling: GET /v1/edge/registrations/{id}, returning the acme-dns account + license when approved
- [ ] Ready + access email: POST /v1/edge/registrations/{id}/ready, which sends the owner the URL and sign-in instructions
After install: check-in, renewal, backups
- [ ] Check-in endpoint: POST /v1/edge/sites/{id}/checkin. Store last seen, channel, commit, app health, license expiry and last backup; answer with anything newer (license, acme-dns account, backup target)
- [ ] Secrets and their audit trail (proposal): the hotel's own scripts/change-password.sh / scripts/audit-log.sh keep a local record. For many hotels coreapi should hold each hotel's generated secrets as versioned values in its encrypted store and deliver a newer version through the check-in answer, the way the backup target is (ibc-agent applies it and restarts what uses it), and record each change centrally: who asked for it, why, which hotel, and the result the agent reports back. Keep the hotel's secret names (IBC_*) as the contract so that a later move to a secret manager such as OpenBao only changes where coreapi reads them from (see Planned: central secret manager). Ship the local audit lines (/var/log/ibc/audit.log) to the central log too
- [ ] License renewal:
- a renewal: auto | manual setting per hotel
- a renewal window, 15 days before expiry by default
- renewal requests in the Console for manual hotels
- [ ] Backup target per hotel: create a bucket/prefix plus credentials limited to it; generate and keep the restic password; deliver them through the check-in; show "restore details" in the Console for restore.sh
- [ ] Alerts:
- license expiring (30 / 15 / 7 / 1 days)
- no check-in for ~6 h
- last successful backup older than ~2 days
- [ ] Fleet view in the Console: every hotel's last seen, health, version, license expiry, last backup
- [ ] Revoke / remove a hotel: stop renewals, answer revoked, delete its CNAME and acme-dns account, free the subdomain
Infrastructure coreapi needs (Castis side): an acme-dns server: zone acme-dns.castis.io delegated to it, API at https://acme.castis.io, /register reachable only from inside the cluster (built in playtelly-iac/acme-dns/); S3-compatible backup storage; the Cloudflare token in coreapi's secret store only.
Decisions to make with other teams
- [ ] authapi: a grace period after license expiry, since hotels can be offline for days
- [ ] The login app: whether to force a password change on first sign-in (Zitadel's PASSWORDCHANGEREQUIRED is false today)
Later, optional - [ ] Install codes for a one-command install (Planned: install codes, at the end of this document) - [ ] Enrollment token required on registration
One backend, two duties¶
Everything in this document is one API in coreapi, at one base URL (IBC_CLOUD_URL), with one per-hotel identity (the bearer installSecret, and the registration id). On the hotel, two components call it at different times:
| Duty | Endpoints | Caller on the hotel | When |
|---|---|---|---|
| Registration + approval | subdomains/{name}, registrations, registrations/{id}, registrations/{id}/approval-token, registrations/{id}/ready |
Setup wizard (setup-agent/cloud.py) |
Once, during install |
| Check-in: health, license renewal, acme-dns rotation, backup target | sites/{id}/checkin |
The ibc-agent CronJob (gitops/components/ibc-agent/agent.py) |
Every hour, after install |
coreapi keeps one record per hotel. Registration creates it, approval fills it (acme-dns account, license), and each check-in updates it (last seen, health, versions) and reads from it (renewed license, backup target). The {id} in registrations/{id} and sites/{id} is the same registration id.
Where this lives in coreapi (proposal, not implemented)¶
coreapi already runs in two places: the Castis cloud, and every hotel (as one of the apps Argo CD deploys). One codebase, with a mode setting:
| Cloud mode (Castis) | Edge mode (each hotel) | |
|---|---|---|
Edge API (/v1/edge/*, this document) |
Serves it | Off |
| Console | Approval tokens, registrations, renewal requests, fleet view (last seen, health, license expiry, last backup) | — |
| Platform features (self-signup, platform email) | On | Off, so the on-prem build needs no platform email settings |
| Data | One record per hotel: registration, license bundle, acme-dns account, backup target, check-ins | Its own hotel only |
Decision: the hotel side of the check-in stays in ibc-agent, its own small
component next to coreapi, so coreapi stays simple. The setup wizard
(setup-agent/) does the one-time registration and approval; ibc-agent does
the hourly check-in and applies what it receives; coreapi on the hotel has no
part in either. Merging ibc-agent into coreapi later stays possible if a real
need appears.
Why a separate agent:
| Reason | |
|---|---|
| It keeps reporting when coreapi or the database is down | Castis learns why a hotel is unhealthy instead of seeing silence |
| It reports the health of all apps (Argo CD Applications), not only coreapi's | Castis sees which component is broken |
Only it needs Kubernetes permissions (named resources, gitops/components/ibc-agent/rbac.yaml) |
coreapi is web-facing (APISIX routes to it); it holds no permissions a breach could misuse |
It applies renewals the only way that works: update Secret argocd/ibc-site (and cert-manager/acme-dns-account), restart argocd-repo-server, hard-refresh the Applications |
Only the render plugin turns new values into manifests; the config-hash stamp then restarts what changed |
Castis: coreapi (cloud mode) ─ one system: /v1/edge/* · Console · DB of hotels
▲ HTTPS: registration, approval ▲ HTTPS: hourly check-in
Hotel: setup wizard (install only) ibc-agent CronJob
Why this API exists¶
Each site needs a publicly trusted wildcard certificate for the subdomain its owner picks in the wizard (e.g. ariyana.castis.io), without ever holding a Cloudflare token.
So the Cloudflare token lives only in coreapi. When a site is approved (the installer enters an approval token from Castis), coreapi:
1. creates an acme-dns account for that site
2. creates the _acme-challenge CNAME in Castis's DNS
3. returns only the acme-dns account to the site
That account can update exactly one TXT record, so a leaked site can't touch castis.io or any other site.
Site wizard ──HTTPS──► coreapi: register "ariyana.castis.io" (site starts every call)
Site wizard ──HTTPS──► coreapi: approval token "<APPROVAL_TOKEN>" (from Castis staff)
coreapi ─► acme-dns POST /register → account
coreapi ─► Cloudflare (coreapi's token)
_acme-challenge.ariyana.castis.io CNAME <account>.acme-dns.castis.io
Site wizard ──HTTPS──► coreapi: status? → approved + acme-dns account + license bundle
Site cert-manager ──► acme-dns /update (TXT) ─► Let's Encrypt validates ─► wildcard cert
Direction rule: sites only make outbound HTTPS calls to a public URL. The Headscale tailnet is for Castis → site support only and is not used here.
Site-facing endpoints¶
Base URL: IBC_CLOUD_URL, e.g. https://api.playtelly.com. All bodies are JSON. Errors are {"error": "<message>"} with a 4xx/5xx status; the wizard shows the message to the installer.
Authentication¶
- Registering: the site generates a random
installSecret(≥ 32 bytes, URL-safe) and sends it once, in the registration body. coreapi stores only its hash. - Every later call for that registration sends
Authorization: Bearer <installSecret>. coreapi must refuse a registration id unless its bearer matches, so one site can never read another site's account. - Optional enrollment token: if the installer was given an enrollment token,
POST /v1/edge/registrationscarriesAuthorization: Bearer <IBC_ENROLLMENT_TOKEN>. coreapi may require it, to accept registrations only from installs Castis issued. That's recommended, because this endpoint is public.
GET /v1/edge/subdomains/{name}?parent=<parent domain>¶
Called while the owner types the address. Unauthenticated, so rate-limit it.
A name is not available when:
- another registration that isn't rejected already uses it, or
- the name is reserved (www, api, admin, …), or
- it already has public DNS records in the parent zone.
The wizard checks the format itself (^[a-z0-9]([a-z0-9-]{0,30}[a-z0-9])?$), but coreapi must validate it again.
POST /v1/edge/registrations¶
Sent once, when the owner presses Install.
{
"installSecret": "<INSTALL_SECRET>", // store the hash only
"orgName": "Ariyana Resort & Spa",
"ownerEmail": "owner@example.com",
"domain": "ariyana.castis.io",
"parentDomain": "castis.io",
"gitRevision": "stable" // branch the site follows (for support)
}
coreapi must:
- re-check that the subdomain is available
- reject a domain that isn't <valid name>.<parentDomain>
- reject a parentDomain it doesn't manage
GET /v1/edge/registrations/{id}¶
The wizard polls this every 15 s while the registration is pending, and at once after an approval token is accepted. Requires the bearer installSecret.
200 {"id": "reg_8f2a…", "status": "pending"}
200 {"id": "reg_8f2a…", "status": "rejected", "reason": "Subdomain reserved"}
200 {"id": "reg_8f2a…", "status": "revoked"} // revoked before setup finished: the wizard treats it like rejected
200 {
"id": "reg_8f2a…",
"status": "approved",
"approvedBy": "approval token …<LAST_4>", // shown in the wizard
"license": { // required: the site has no other license
"key": "<LICENSE_KEY>", // AUTHAPI_LICENSE_KEY
"publicKey": "<LICENSE_PUBLIC_KEY>", // AUTHAPI_LICENSE_PUBLIC_KEY
"privateKey": "<LICENSE_PRIVATE_KEY>" // AUTHAPI_LICENSE_PRIVATE_KEY
},
"acmeDnsAccount": { // exactly what acme-dns /register returned
"username": "<ACME_DNS_USERNAME>",
"password": "<ACME_DNS_PASSWORD>",
"fulldomain": "<ACME_DNS_SUBDOMAIN>.acme-dns.castis.io",
"subdomain": "<ACME_DNS_SUBDOMAIN>",
"allowfrom": []
}
}
acmeDnsAccountis required when approved. Return the same account on every poll, because the wizard may ask again after a reboot or retry.- Optional
licenseVersionandacmeDnsVersion(integers, default 1): the starting versions for the check-in below. - After a rejection the installer can press Retry, which creates a new registration.
licenseis required when approved. The repo holds no license any more; the three values go into authapi'sAUTHAPI_LICENSE_*settings. Return the same bundle on every poll.license.keyuses the existing format<base64url(json payload)>.<signature>, withcompany_codeandexpires_atin the payload. The site readscompany_codefrom it.- Recommended: a separate key pair per site. authapi receives the private key, so a site can sign licenses with it. If every site shares one key pair, one site could create licenses accepted anywhere. With one pair per site, it can only affect itself.
POST /v1/edge/registrations/{id}/approval-token¶
The only way a registration is approved. The installer enters an approval token that Castis staff created and sent them (by chat is fine), in the wizard's "Waiting for approval" box. coreapi checks it and approves the registration on the spot (see Castis side: what coreapi does on approval). Requires the bearer installSecret.
200 {"id": "reg_8f2a…", "status": "approved"}
403 {"error": "This approval token is expired. Ask Castis for a new one."} // or: not valid, used up, revoked
409 {"error": "This registration is already approved"} // only a pending one can be approved
502 {"error": "Approval failed on the Castis side: …"} // acme-dns or Cloudflare failed
- Normalize before comparing: ignore case, spaces and dashes, and read
Oas0andI/Las1. People copy tokens out of chats. - The
errortext is shown to the installer as it is, so keep it plain. Say which problem it is (not valid, expired, used up, revoked) and nothing more. - A use counts only when approval succeeds. If creating the acme-dns account or the CNAME fails (
502), give the use back. - Hold the use while approving, so two sites can't both take the last use of a token.
- Wait about 1 s before answering a refused token, and rate-limit per registration, to slow down guessing.
- Record the token on the registration:
approvedBy("approval token …<LAST_4>", shown in the wizard) and the token id, for the audit log. - After a
200the wizard pollsGET /v1/edge/registrations/{id}right away, so that must already return the account and license.
POST /v1/edge/registrations/{id}/ready¶
Sent once the site is up. Requires the bearer installSecret.
This is where coreapi sends the owner's access email: the URL, the user ID (the owner email), and instructions. The wizard also shows the details on screen. A failure here is only logged by the wizard; it doesn't fail the install.
Check-in and renewal¶
After install, each site's ibc-agent (a CronJob in its cluster, gitops/components/ibc-agent/) checks in every hour, over outbound HTTPS like everything else. It's how coreapi knows each site is alive, and how a renewed license or a replaced acme-dns account reaches the site. The site never decides anything; coreapi does.
POST /v1/edge/sites/{registrationId}/checkin¶
Requires the bearer installSecret.
{
"agentVersion": "1",
"domain": "ariyana.castis.io",
"gitRevision": "stable", // channel the site follows
"syncedCommit": "3f5e71e…", // what Argo CD has applied
"apps": {"total": 20, "synced": 20, "healthy": 20},
"licenseVersion": 1,
"licenseExpiresAt": "2027-10-01T00:00:00Z",
"acmeDnsVersion": 1,
"backupVersion": 1, // 0 = no backup target yet
"backup": {"lastSuccess": "2026-09-28T02:31:40Z", // the backup CronJob's last runs
"lastScheduled": "2026-09-28T02:30:00Z"}
}
200 {
"status": "active", // or "revoked" / "suspended": recorded by the site, shown to Castis
"licenseVersion": 2, // coreapi's current version for this site
"license": {"key": "…", "publicKey": "…", "privateKey": "…"}, // only when newer than the site's
"acmeDnsVersion": 1,
"acmeDnsAccount": {…}, // only when newer; same fields as in the approval response
"backupVersion": 1,
"backup": {"repository": "s3:https://…/ariyana", "accessKeyId": "…",
"secretAccessKey": "…", "password": "…"} // only when newer
}
backup.lastSuccessis the nightly backup's last successful run (empty = never). Alert when it's older than ~2 days. Not while the backup is switched off (devops-handover.md2.6): every site then reports it empty.- Include
license/acmeDnsAccount/backuponly when your version is higher than the one the site reported. The site applies them, restarts only what changed (e.g. authapi), and reports the new version at its next check-in. - Store every check-in (last seen, channel, commit, health, license expiry) for the fleet view in the Console. A site that hasn't checked in for, say, 6 hours is worth an alert.
- On the site, the result is visible with:
Backup target (coreapi)¶
Each site backs up nightly with restic to the repository coreapi gives it (gitops/components/backup/). The backup is switched off on sites for now, until Castis decides where hotel backups are stored (devops-handover.md 2.6). coreapi should, per site:
- Create the storage: a bucket or prefix per site in Castis's S3-compatible storage, e.g. s3:https://s3.castis.io/ibc-backups/<site>.
- Create credentials that can only reach that prefix. A leaked site then can't read other hotels' backups.
- Generate the restic password (the encryption key) and keep it. Castis needs it to restore the site on a new machine; the site's own copy is lost with the machine.
- Send all four in the check-in answer as backup + backupVersion (the first check-in happens within an hour of install). Bump the version to rotate them.
- Restores: give DevOps the four values for a site (Console → site → "Restore details"), used by restore.sh. Later this can become a single restore code.
License renewal policy (coreapi)¶
day -30 day -15 day 0 (expires) day +grace
───────────────────────────────────────────────────────────────────────────►
check-ins run every hour, always ───────────────────────────────────────────
alert Castis renewal window opens license expires authapi stops,
├─ AUTO: issue v2 if the if not renewed
│ contract is active
└─ MANUAL: "Renewal request"
in the Console → approve → v2
the site picks up v2 at its next check-in (≤ 1 h), authapi restarts with it
| Setting (per site, in coreapi) | Meaning |
|---|---|
renewal: auto |
At the window, coreapi issues the new license by itself if the contract is active. Castis is only notified |
renewal: manual |
At the window, a renewal request appears in the Console. Castis approves it (optionally with a new expiry) or lets it lapse |
| Renewal window | Default 15 days before expiry |
| Alerts | To Castis at 30 / 15 / 7 / 1 days before expiry, and when a site stops checking in |
A renewal keeps the site's key pair and re-signs only the license key, with the new expiry. Replace the key pair only on purpose (e.g. after a leak), as a new license version.
Decide with the app team: does authapi stop right at expiry, or allow a grace period (e.g. 14–30 days)? On-prem sites can be offline for days, and a hotel shouldn't stop working because its internet was down on renewal day.
Revoking a site (contract ended): answer "status": "revoked" and stop renewing. The site records it; the license then simply expires. Nothing is deleted remotely.
Castis side: what coreapi does on approval¶
Triggered only by a valid approval token (POST /v1/edge/registrations/{id}/approval-token). Only authenticated Castis staff can create tokens, so approval still comes from Castis, just without anyone watching for the registration.
- Create the acme-dns account:
POST <acme-dns>/register, and keep the response. - Create the challenge CNAME with coreapi's Cloudflare token:
- Update it if it already exists.
- Fail if non-CNAME records already sit on that name, because a CNAME can't coexist with them.
- Never create an A record for the site. Its address resolves only on the site's own network (split DNS, via the site's CoreDNS).
- Store the account encrypted and mark the registration
approved, recording which token approved it (and the staff member who created that token) and when. - Issue the site's license bundle: its license key (company code, expiry) and, ideally, a new key pair for this site only. Store it encrypted, and return it with the approval.
On reject: set status: rejected with a reason, and free the subdomain.
Removing a site later:
- delete the _acme-challenge.<domain> CNAME and the stored account
- mark the registration revoked
- free the subdomain after a grace period
Certificate renewals then stop within about 60 days.
Castis side: approval tokens¶
Staff create a token in the Console without any customer details and send it to whoever installs the site. It's the only way to approve a site: there's no approve button. One token can approve a few registrations, so a reinstall after a failed attempt doesn't need a new one.
| Field | Note |
|---|---|
id |
e.g. tok_1df96c6b, for the Console and the audit log |
hash |
Store only the hash of the token, like installSecret |
hint |
The last 4 characters, so staff can tell tokens apart |
expiresAt |
Default 24 h after creation |
maxUses / uses |
Default 3. Each successful approval is one use |
status |
active or revoked. Show expired / used up when those apply |
usedBy |
[{registration, domain, at}] for each approval |
createdBy |
The staff member |
Token format: 16 characters from Crockford base32 (0-9 A-Z without I L O U), in 4 groups of 4: XXXX-XXXX-XXXX-XXXX. That's about 80 bits, easy to read out, and with no letters that look like digits.
Console / admin endpoints (staff auth only; the mock has them under /admin/… with no auth):
POST /v1/admin/approval-tokens {"ttlHours": 24, "maxUses": 3} // both optional
→ 201 {"token": "<APPROVAL_TOKEN>", "id": "tok_…", "hint": "…<LAST_4>",
"status": "active", "expiresAt": "…", "maxUses": 3, "usesLeft": 3, "usedBy": []}
// the token is in this answer only: show it once, with a Copy button
GET /v1/admin/approval-tokens → [{"id", "hint", "status", "expiresAt", "maxUses", "usesLeft", "usedBy"}]
POST /v1/admin/approval-tokens/{id}/revoke
- Revoking a token stops new approvals. Sites it already approved stay approved; revoke those registrations separately if needed.
- A token knows nothing about the customer, so it approves any subdomain the installer picks. Only give tokens to installers Castis trusts, and check
usedByin the Console afterwards.
Castis side: infrastructure coreapi needs¶
| Item | Detail |
|---|---|
| acme-dns server | Runs on the Droplet cluster: playtelly-iac/acme-dns/ (setup steps in its README). Public DNS on port 53 for Let's Encrypt (worker-node-a), plus its API at https://acme.castis.io. The sites call /update, so that is public |
| Lock down acme-dns registration | /register isn't routed publicly: coreapi calls it inside the cluster (http://acme-dns.acme-dns.svc.cluster.local:8080/register). Sites only need /update, which acme-dns authenticates per account |
| Delegated zone | In Cloudflare: acme-dns.castis.io NS ns-acme.castis.io and ns-acme.castis.io A <worker-node-a>, plus acme.castis.io A <APISIX> for the API. The API URL must match IBC_ACMEDNS_HOST in setup-agent/defaults.env (default https://acme.castis.io) |
| Cloudflare token (coreapi only) | Zone:Read + DNS:Edit on the parent zone (castis.io). Kept in coreapi's secret store, never in this repo or on a site |
Security checklist for coreapi¶
- HTTPS only, with rate limits on all public endpoints.
- Store only hashes of install secrets and approval tokens, and encrypt the acme-dns accounts at rest.
- Approval tokens are short-lived and limited (24 h, 3 uses by default), revocable, and slowed down when wrong.
- A registration is readable only with its own install secret. Never list registrations to sites.
- Audit-log registrations, approvals, rejections and removals.
- Rotate the old Cloudflare token, and stop trusting the old license key pair. Both were committed to this repo before this change, so they're still in the git history.
Site-side code in this repo¶
| File | Role |
|---|---|
setup-agent/cloud.py |
HTTP client for the endpoints above |
setup-agent/agent.py |
step_register: registers, polls, and writes the account and license to /etc/ibc/site.env (IBC_ACMEDNS_ACCOUNT_B64, IBC_LICENSE_*). /api/approval-token passes the installer's approval token on and wakes the poll at once |
setup-agent/index.html |
The Approval token box under "Waiting for approval" in the waiting step |
gitops/components/ibc-agent/ |
The hourly check-in: applies a newer license, acme-dns account or backup target to Secret argocd/ibc-site |
gitops/components/backup/, restore.sh |
Use the check-in's backup target: the nightly backup, and rebuilding a hotel from it |
prerequisite.sh Step 7.1 |
Creates the acme-dns-account Secret for cert-manager |
cert-manager/02-clusterissuer.yaml |
The acmeDNS solver |
setup-agent/defaults.env |
IBC_CLOUD_URL, IBC_ACMEDNS_HOST, IBC_PARENT_DOMAIN |
setup-agent/dev/mock_edge_api.py |
Mock of this API for testing, approval tokens included: build coreapi to behave the same. Its accounts are fake unless started with --acmedns-register-url |
Planned: central secret manager (OpenBao), the next step for secrets¶
Status: a decision, not built. It depends on this edge API, which does not exist yet. Until then scripts/change-password.sh and scripts/audit-log.sh cover a hotel on its own. Build it when there are about ten or more hotels, or when staff changes or an auditor need one central place for secrets and their audit trail.
Choice: OpenBao. The open-source fork of HashiCorp Vault: the same design, API and tools, with an open licence (MPL). Vault itself works the same way if you prefer it.
How it fits
- One central service (Castis side): 3 nodes with built-in (Raft) storage, HTTPS, auto-unseal (a KMS or transit key, so no person is needed after a restart), and regular snapshots that are tested by restoring.
- A secrets area per hotel (hotels/<name>/..., KV v2, versioned) and a policy that lets a hotel read only its own area.
- A login per hotel (AppRole): created at registration by this edge API and delivered once, wrapped and single-use, like the approval flow. It is the only secret a hotel keeps by itself (root only, like /etc/ibc/site.env today).
- On the hotel: an External Secrets Operator reads that hotel's area and writes the local Kubernetes Secrets, which the services read as today. The alternative is to extend ibc-agent (its hourly check-in already applies a newer licence or backup target). A small tool (Reloader, or the agent) restarts the workloads that use a changed Secret.
- Audit: the manager's audit device records every read and write (who, which path, when); Vector ships it to the central log store.
How a change arrives. The hotel always pulls (Castis cannot reach into a hotel behind a router): the operator checks every N minutes (or the agent at its hourly check-in), overwrites the local Secret when the version changed, the workload restarts, and the hotel reports "applied version N". An emergency rotation is limited by that interval, or can be forced over the tailnet.
- Values that must change together (Valkey and coreapi, VerneMQ and the apps) are one versioned bundle, applied and restarted in one round, as change-password.sh does today.
- Passwords stored inside a database (Postgres) need a job that runs ALTER USER before the Secret changes, which is why those are locked today.
- A hotel that is offline keeps running on its local copy and catches up later.
Roll-out
1. Stand up the service; import one lab hotel's secrets from its site.env.
2. Run the operator beside the current setup on a lab box and compare.
3. Switch one service at a time per hotel, then remove the old values from site.env.
4. Roll out by branch (main, canary, stable), with change-password.sh as the fallback.
What carries over, and what changes
- Carries over: the IBC_* names as the contract, the audit line format, and the scripts writing values in one place.
- Changes: change-password.sh calls the manager (through coreapi) instead of editing site.env; show-secrets.sh can show the local copy or be switched off; the manifests switch from the render plugin's inline values to Secrets the operator creates.
- Stays local: the Argo CD login and parts of the certificate setup may never move. Root on the hotel can still read the local working copy: the manager removes the master copy and the audit trail from the box, not the local copy.
Decisions needed first: where the service runs and who owns its uptime; the KMS or transit key for auto-unseal; whether hotels reach it over the internet or only over VPN; the operator or ibc-agent.
Planned: install codes (optional, for a one-command install)¶
Not needed for the current flow. It makes installs simpler (end-to-end.md Part H).
| Endpoint | Caller | Purpose |
|---|---|---|
POST /v1/edge/install-codes |
Castis staff (Console) | Create a single-use code for a known customer: {orgName, subdomain, ownerEmail, expiresIn} → {code} |
POST /v1/edge/enroll |
The site's bootstrap script | {code} → {gitToken or bundleUrl, headscaleKey, enrollmentToken, prefill: {orgName, subdomain, ownerEmail}}. It marks the code used; coreapi creates the Headscale key through the Headscale API at this moment |
A registration that arrives with that enrollment token could then be approved automatically, because Castis already vouched for it when creating the code. That would be the one planned exception to "approval tokens are the only way". The approval response stays exactly as above.