Registrar module, core: registrars as a plug-in point, Openprovider first #83

Merged
calvin merged 5 commits from registrar into master 2026-11-15 08:27:59 +00:00
Owner

Adds an optional registrar module to Salt: Salt holds the account at a domain registrar and carries out registrations, so that an outside billing system never sees the registrar's login. Off unless SALT_DNS_REGISTRAR=on; with the switch off nothing of it starts. This is the core only: no HTTP API, no console page (they follow in a second pull request).

What is in it

  • SaltDns.Registrar.Adapter: the plug-in point for registrars, in the style of SaltDns.Certificates.Issuer. Adapters are registered by name in configuration and chosen per provider row.
  • SaltDns.Registrar.Openprovider: the first adapter (login with a token kept in memory only, account, check, prices, contacts, register, transfer, renew, restore, name servers, lock, auto-renew, DNSSEC keys, auth code).
  • SaltDns.Registrar.Provider: the account row; the password is an encrypted field, left out of inspect/1, and added to SaltDns.Encrypted.Registry so key rotation covers it.
  • Tables registrar_providers, registrar_contacts (reference, version and the registrar's handle; no personal data), registrar_operations (the ledger), registrar_domains, registrar_events.
  • Three guards on every call that spends money (register, transfer, renew, restore):
    1. the caller's reference is written to the ledger before the registrar is called; the same reference with the same request returns the stored result and buys nothing; with another request it is reference_reuse; an operation left without a final answer is looked up at the registrar before anything is ordered again;
    2. a cost ceiling: the price is read again just before ordering and the order is refused when it is higher or in another currency;
    3. premium names are refused unless the order allows them.
  • docs/registrar.md (which calls spend money and which do not), configuration docs, CHANGELOG.

Tested

  • mix precommit passes on this branch (1512 passed, integration tests excluded as usual); mix coveralls total 90.2%.
  • The context tests (test/salt_dns/registrar_test.exs, tagged integration) passed against a throwaway Postgres.
  • Every HTTP call in tests goes to a stub. The shapes for login, account, check, prices, contact create/delete and the refusal for lack of funds (HTTP 500, code 920) were confirmed against the live API by hand on 2026-11-15; no purchase was made.

Not verified

  • Transfer, renew, restore, domain read and update, auth code, lookup by name, contact update and contact verification are written from the public API description only.
  • lib/salt_dns/registrar.ex is in the coverage skip list, as certificates.ex is, because its tests are the integration ones.
  • An operation that dies half-way is only resumed by the next call with its reference; a background worker for that comes with the API part.

🤖 Generated with Claude Code

https://claude.ai/code/session_01DnYzaT298iLkLpMNy36NVG

Adds an optional registrar module to Salt: Salt holds the account at a domain registrar and carries out registrations, so that an outside billing system never sees the registrar's login. Off unless `SALT_DNS_REGISTRAR=on`; with the switch off nothing of it starts. This is the core only: no HTTP API, no console page (they follow in a second pull request). ## What is in it - `SaltDns.Registrar.Adapter`: the plug-in point for registrars, in the style of `SaltDns.Certificates.Issuer`. Adapters are registered by name in configuration and chosen per provider row. - `SaltDns.Registrar.Openprovider`: the first adapter (login with a token kept in memory only, account, check, prices, contacts, register, transfer, renew, restore, name servers, lock, auto-renew, DNSSEC keys, auth code). - `SaltDns.Registrar.Provider`: the account row; the password is an encrypted field, left out of `inspect/1`, and added to `SaltDns.Encrypted.Registry` so key rotation covers it. - Tables `registrar_providers`, `registrar_contacts` (reference, version and the registrar's handle; no personal data), `registrar_operations` (the ledger), `registrar_domains`, `registrar_events`. - Three guards on every call that spends money (register, transfer, renew, restore): 1. the caller's reference is written to the ledger before the registrar is called; the same reference with the same request returns the stored result and buys nothing; with another request it is `reference_reuse`; an operation left without a final answer is looked up at the registrar before anything is ordered again; 2. a cost ceiling: the price is read again just before ordering and the order is refused when it is higher or in another currency; 3. premium names are refused unless the order allows them. - `docs/registrar.md` (which calls spend money and which do not), configuration docs, CHANGELOG. ## Tested - `mix precommit` passes on this branch (1512 passed, integration tests excluded as usual); `mix coveralls` total 90.2%. - The context tests (`test/salt_dns/registrar_test.exs`, tagged integration) passed against a throwaway Postgres. - Every HTTP call in tests goes to a stub. The shapes for login, account, check, prices, contact create/delete and the refusal for lack of funds (HTTP 500, code 920) were confirmed against the live API by hand on 2026-11-15; no purchase was made. ## Not verified - Transfer, renew, restore, domain read and update, auth code, lookup by name, contact update and contact verification are written from the public API description only. - `lib/salt_dns/registrar.ex` is in the coverage skip list, as `certificates.ex` is, because its tests are the integration ones. - An operation that dies half-way is only resumed by the next call with its reference; a background worker for that comes with the API part. 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01DnYzaT298iLkLpMNy36NVG
Salt holds accounts at domain registrars and registers, transfers, renews
and restores names through an adapter (SaltDns.Registrar.Adapter, the
plug-in point; Openprovider ships). Off unless SALT_DNS_REGISTRAR=on.

Spending calls take an operation reference that never buys twice (a ledger
row is inserted before the registrar is called, unique per organisation, with
a fingerprint of the request), a price ceiling checked against the registrar
immediately before buying, and refuse premium names unless allowed. An
operation with no final answer looks the name up at the registrar before it
orders again. Money is integer minor units with a currency code. Contacts are
kept as reference, version and handle only. The registrar password is
encrypted and part of vault key rotation. No web pages and no API yet.

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>
Claude-Session: https://claude.ai/code/session_01DnYzaT298iLkLpMNy36NVG
Registrar: keep the reference open on non-final failures; held names come from the domain row
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
7a2155060c
A failure before anything is ordered (a network error, a server error, a rate
limit while reading the price or ordering) no longer fails the operation for
good: it stays started with the error recorded and the same reference
resumes it (lookup first, then order). Only final refusals are stored as
failed; rate_limited is no longer one of them and keeps its retry_after.

The partial unique index on registrar_operations now covers operations in
flight only. A name is held when its registrar_domains row is pending,
active, expired or unknown; a row that ended as deleted is reused when the
name is registered again.

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>
Claude-Session: https://claude.ai/code/session_01DnYzaT298iLkLpMNy36NVG
Registrar: fixes from the review of the core
Some checks failed
ci/woodpecker/pr/image Pipeline failed
ci/woodpecker/pr/quality Pipeline failed
ci/woodpecker/pr/integration unknown status
e8c0807e24
A name registered again by another organisation after it was deleted now
resets the row (organisation, provider, cost, flags). The rules of the money
path moved into SaltDns.Registrar.Rules (pure, tested in the normal run): the
price guard, when an order counts as done, and the normalising of adapter
answers so that a malformed one leaves the operation open instead of
crashing. A renewal that cannot be shown either way is left open; the expiry
at claim time is kept on the operation. Wrong credentials are not final.
The operation's clock restarts just before the order and the stale time is
longer than the slowest execution. Domain functions take the organisation and
refuse another's domain. abandon_operation looks the name up before it gives
an operation up. The password is redacted in changesets, the ETS tables are
protected, a ceiling above what the database holds is invalid, and the
contact verification words that are not known are :unknown. Code 320 is
:not_found. Docs: what cost_charged_minor is, no overall cap, how it is tested.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DnYzaT298iLkLpMNy36NVG
Registrar: fixes from the second review
Some checks failed
ci/woodpecker/pr/image Pipeline failed
ci/woodpecker/pr/quality Pipeline failed
ci/woodpecker/pr/integration unknown status
175a7792b0
A deleted name registered again by another organisation detaches the earlier
organisation's operations and events from the reused row; get_operation and
list_events never return another organisation's data. Abandon concludes
"nothing was ordered" only once the stale time has passed since the last
attempt. A lookup answer without a registrar id is not a completion, and the
Openprovider lookup says "not held" only for a total of 0 or an empty list.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DnYzaT298iLkLpMNy36NVG
Registrar: correct a stale function reference in the operation docs
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
2f9e4c9bf0
The image job builds the docs with --warnings-as-errors; sync_domain takes
the organisation since the first review, so the reference was sync_domain/2.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DnYzaT298iLkLpMNy36NVG
calvin merged commit bff2af8efc into master 2026-11-15 08:27:59 +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!83
No description provided.