Registrar API, background job and console #85

Merged
calvin merged 4 commits from registrar-api into master 2026-11-15 09:15:43 +00:00
Owner

Second part of the registrar module (the core is pull request 83): the HTTP API an outside billing system calls, the permission level on tokens, a background job, and console pages. Everything stays off unless SALT_DNS_REGISTRAR=on; every registrar route answers 404 while it is off.

What is in it

  • Credential level. A column registrar on API credentials (none, read, purchase; default none), set on the Credentials and Provisioning pages and with registrar: on SaltDns.Release.create_provisioning_token/4. Nothing can buy until someone sets it.
  • Routes under /api/v1/registrar, three pipelines (the level and the header rule per group):
    • read, X-Salt-Organisation optional: GET /account, POST /check, GET /prices
    • read, header required: GET /domains, GET /domains/{fqdn}, GET /operations/{reference}
    • purchase, header required: PUT /contacts/{ref}, POST /contacts/{ref}/verification, PUT /domains/{fqdn}, POST /domains/{fqdn}/renew, POST /domains/{fqdn}/restore, POST /domains/{fqdn}/auth-code, POST /operations/{reference}/abandon
  • Answers. Money is {minor, currency} everywhere. Prices and each check entry take a period and return the registrar's totals for that period (never a multiplied one-year price), renew_yearly, the promotion with its end date, period limits, privacy, and both quarantine figures as the registrar reports them. Operations show cost_ceiling, cost_quoted, cost_charged and cost_confirmed. Every error carries final (true: the reference is burned; false: retry with the same reference); 503 and 429 carry cause.
  • Abandon. POST /operations/{reference}/abandon answers nothing_ordered or registered; it refuses as too_early (409, Retry-After) until the stale time has passed since the last order attempt.
  • Background job (Oban, scheduled only while the switch is on): resolves pending operations, looks stuck ones up at the registrar, refreshes domains daily. It never places an order: the only adapter call it can make for an operation is the lookup; a test with a recording adapter checks that.
  • Console. Registrar accounts (create, edit, test connection, disable, company contact, mode) and read-only lists of domains and operations. No button spends money.
  • Two notes from the review of the core are included: a failed lookup during abandon no longer restarts the waiting time, and {"total": 5, "results": []} from the registrar is treated as malformed, not as "not held". The two stale arities in registrar.ex are corrected.
  • docs/integrations/registrar.md (the API, retrying and references, which calls spend money), docs/registrar.md, OpenAPI (additions only: 2385 added, 1 removed with git diff --diff-algorithm=patience), CHANGELOG.

Tested

  • On this exact tree (the commit is the verified one moved onto master; the diff between them is empty): mix precommit passes, 1546 passed with integration excluded as usual, and mix docs --warnings-as-errors builds without warnings.
  • By the building agent's account: coverage total 90.4% with no new entry in the coverage skip list; 955 integration-tagged tests passed against a throwaway Postgres before the last small change, and 127 registrar ones after it.
  • Request bodies of contacts and the auth code answer are filtered from the logs, with a test.

Not verified

  • Written from Openprovider's public description only, never run against the registrar: transfer, renew, restore, domain read and update, auth code, contact update and verification, and the lookup by name used by resume and abandon. Confirmed by hand against the live API on 2026-11-15, read-only: login, account, check, prices with a period, contact create and delete, and the refusal for lack of funds.
  • The switch should not be turned on in production before those calls are tried against Openprovider's sandbox.

🤖 Generated with Claude Code

https://claude.ai/code/session_01DnYzaT298iLkLpMNy36NVG

Second part of the registrar module (the core is pull request 83): the HTTP API an outside billing system calls, the permission level on tokens, a background job, and console pages. Everything stays off unless `SALT_DNS_REGISTRAR=on`; every registrar route answers 404 while it is off. ## What is in it - **Credential level.** A column `registrar` on API credentials (`none`, `read`, `purchase`; default `none`), set on the Credentials and Provisioning pages and with `registrar:` on `SaltDns.Release.create_provisioning_token/4`. Nothing can buy until someone sets it. - **Routes** under `/api/v1/registrar`, three pipelines (the level and the header rule per group): - read, `X-Salt-Organisation` optional: `GET /account`, `POST /check`, `GET /prices` - read, header required: `GET /domains`, `GET /domains/{fqdn}`, `GET /operations/{reference}` - purchase, header required: `PUT /contacts/{ref}`, `POST /contacts/{ref}/verification`, `PUT /domains/{fqdn}`, `POST /domains/{fqdn}/renew`, `POST /domains/{fqdn}/restore`, `POST /domains/{fqdn}/auth-code`, `POST /operations/{reference}/abandon` - **Answers.** Money is `{minor, currency}` everywhere. Prices and each check entry take a `period` and return the registrar's totals for that period (never a multiplied one-year price), `renew_yearly`, the promotion with its end date, period limits, privacy, and both quarantine figures as the registrar reports them. Operations show `cost_ceiling`, `cost_quoted`, `cost_charged` and `cost_confirmed`. Every error carries `final` (true: the reference is burned; false: retry with the same reference); 503 and 429 carry `cause`. - **Abandon.** `POST /operations/{reference}/abandon` answers `nothing_ordered` or `registered`; it refuses as `too_early` (409, `Retry-After`) until the stale time has passed since the last order attempt. - **Background job** (Oban, scheduled only while the switch is on): resolves pending operations, looks stuck ones up at the registrar, refreshes domains daily. It never places an order: the only adapter call it can make for an operation is the lookup; a test with a recording adapter checks that. - **Console.** Registrar accounts (create, edit, test connection, disable, company contact, mode) and read-only lists of domains and operations. No button spends money. - **Two notes from the review of the core** are included: a failed lookup during abandon no longer restarts the waiting time, and `{"total": 5, "results": []}` from the registrar is treated as malformed, not as "not held". The two stale arities in `registrar.ex` are corrected. - `docs/integrations/registrar.md` (the API, retrying and references, which calls spend money), `docs/registrar.md`, OpenAPI (additions only: 2385 added, 1 removed with `git diff --diff-algorithm=patience`), CHANGELOG. ## Tested - On this exact tree (the commit is the verified one moved onto master; the diff between them is empty): `mix precommit` passes, 1546 passed with integration excluded as usual, and `mix docs --warnings-as-errors` builds without warnings. - By the building agent's account: coverage total 90.4% with no new entry in the coverage skip list; 955 integration-tagged tests passed against a throwaway Postgres before the last small change, and 127 registrar ones after it. - Request bodies of contacts and the auth code answer are filtered from the logs, with a test. ## Not verified - Written from Openprovider's public description only, never run against the registrar: transfer, renew, restore, domain read and update, auth code, contact update and verification, and the lookup by name used by resume and abandon. Confirmed by hand against the live API on 2026-11-15, read-only: login, account, check, prices with a period, contact create and delete, and the refusal for lack of funds. - The switch should not be turned on in production before those calls are tried against Openprovider's sandbox. 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01DnYzaT298iLkLpMNy36NVG
Registrar API, background job and console
All checks were successful
ci/woodpecker/pr/image Pipeline was successful
ci/woodpecker/pr/quality Pipeline was successful
ci/woodpecker/pr/integration Pipeline was successful
8495cd70e9
/api/v1/registrar for a billing system: account, check, prices (per period),
contacts (with verification), register and transfer (PUT domain), renew,
restore, read domains and operations, give up a stuck operation, and the
transfer authorisation code. A new registrar level on API tokens (none, read,
purchase) decides who may call; a provisioning token may leave out
X-Salt-Organisation on account, check and prices only. Every route is 404
while SALT_DNS_REGISTRAR is off and is in the OpenAPI document. Errors are
problem documents that say whether they are final and, for a 503 or 429, why.
Money has one shape. A currency other than the registrar account's is refused.
Contact data and authorisation codes are kept out of the logs.

An Oban job, scheduled only while the module is on, resolves pending
operations, finishes operations cut short by looking the name up (it never
places an order) and reads every domain again once a day. The console has a
Registrar page (accounts with test connection, mode, company contact handle;
domains and operations, read only) and shows the registrar level of tokens.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DnYzaT298iLkLpMNy36NVG
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
A shared registrar account is used only by the organisations the operator has
listed from the command line, at every level; the console offers registrar
access on a token only where the organisation has a provider it may use and
shows a shared provider by name and mode only. A body that is not a JSON
object is a 422. The background sweep leaves an operation it cannot complete
exactly as it was. Spending calls, contact changes, authorisation-code reads
and abandons keep the id of the token that asked. Reads of a domain, of a
name's availability and of a contact's verification are bounded. With the
module off a valid token gets 404 after authentication, as on /proxy.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DnYzaT298iLkLpMNy36NVG
Merge origin/master into registrar-api
Some checks failed
ci/woodpecker/pr/image Pipeline was successful
ci/woodpecker/pr/quality Pipeline was successful
ci/woodpecker/pr/integration Pipeline was canceled
2fd6423927
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DnYzaT298iLkLpMNy36NVG
Registrar API: calls through a domain's provider follow the spending rule
All checks were successful
ci/woodpecker/pr/image Pipeline was successful
ci/woodpecker/pr/quality Pipeline was successful
ci/woodpecker/pr/integration Pipeline was successful
dd628bfe98
A call that reaches the registrar through a domain, or hands out a secret,
needs the caller's own registrar account (the active provider of the API
token's organisation) to be the one the domain is held at. A customer
organisation with a token of its own, with or without an account of its own,
reads only the stored record of its domain: no sync, no verification state, no
authorisation code, no renewal, no abandon, no contact calls on its parent's
account. The core enforces it (option :via, the organisation of the token), so
no caller can forget it; the controller checks first so that no call is made
at all.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DnYzaT298iLkLpMNy36NVG
calvin merged commit 96ce27fba0 into master 2026-11-15 09:15:43 +00:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
external/salt-dns!85
No description provided.