Registrar

An optional module. With it switched on, Salt holds accounts at domain registrars and buys, renews and manages domain names through them. A billing system outside Salt only coordinates: it asks Salt to do things and never sees the registrar's user name or password. Without the module (SALT_DNS_REGISTRAR unset) nothing changes: no table is touched and nothing of it starts.

This page is for the operator. The module has the functions of SaltDns.Registrar, the first adapter (Openprovider), an HTTP API for a billing system (Registrar API), a background job and a console page.

What it does

  • Providers. A provider is an account at a registrar: a name, the adapter that speaks to that registrar, a user name and a password, and a mode (sandbox, the registrar's test system, or live). The password is encrypted with the vault key and never shown. A provider belongs to one organisation, or to none: then it is shared, the operator creates it and lists the organisations that may use it (see "Who may use which provider"). Test the connection after you create it.
  • Reading the registrar. Whether names are free and what they cost, price lists of extensions, the account's balance.
  • Contacts. The owner of a domain (the registrant) is a contact at the registrar. Salt sends the data to the registrar and keeps only the caller's reference, a version number and the registrar's handle. It does not store names, addresses, e-mail addresses or phone numbers. The admin, tech and billing contacts of every name are one company contact, the provider's company_handle, which you set once.
  • Domains. Register, transfer in, renew and restore; read a domain again (sync); change its name servers, transfer lock, automatic renewal and DNSSEC keys; read the transfer authorisation code.
  • Not included. Salt does not create a DNS zone when it registers a name. The registrar module only sets the name servers of the registered name.

Glue

A name server may be a plain host name, as before, or an entry with the addresses that go with it:

Registrar.register(provider, %{
  name: "trouweherverdeling.nl",
  years: 1,
  owner_contact: "owner-9",
  name_servers: [
    %{name: "ns1.trouweherverdeling.nl", ipv4: "65.109.158.98"},
    %{name: "ns2.trouweherverdeling.nl", ipv4: "65.108.4.21", ipv6: "2a01:7c8::21"}
  ]
}, organisation: org, reference: "order-17", max_cost_minor: 1500, currency: "EUR")

The same entries go to register, transfer and set_name_servers, and to the HTTP API (docs/integrations/registrar.md).

In bailiwick means the domain itself or a name under it. A name server that is in bailiwick (ns1.trouweherverdeling.nl for trouweherverdeling.nl) needs at least one address: the registry cannot find it without the glue. An in-bailiwick entry without an address is refused with :invalid and nothing is sent. An address on a name server outside the domain is not glue; a registry ignores or refuses it. Salt refuses that too, rather than dropping the address silently, so the request sent is always the request made.

The addresses are kept with the domain in domain.name_server_addresses, keyed by name server, and sync_domain keeps the ones the registrar reports. When set_name_servers is given the same name server again without an address, the stored address of each family is carried forward, so a later name-server change does not drop the glue. An address the caller gives replaces the stored one for that family.

A registration or transfer may leave the name servers out (or give []): Salt then uses its own name servers, as before. A change of name servers through set_name_servers must name at least one.

The Openprovider adapter sends the addresses as ip (IPv4) and ip6 (IPv6); the field names are the registrar's own, from its public API description (domainNameserver). The order of the list is the sequence (seq_nr is optional and is not sent). A read reports the same fields, and Salt keeps them.

The Domains page

The console page Registrar → Name servers (/orgs/:org_id/registrar/domains) is where an owner or admin changes the name servers a domain is delegated to. It lists every domain of the organisation with its stored name servers and the time it was last read, and opens a form per domain. The form is the same call as the HTTP API (set_name_servers, glue included), with the same rules: only owners and admins, and only through the organisation's own active registrar account. A domain held at another account is read-only here.

Preset. "Use Salt's name servers" fills the form with the names in SALT_DNS_NAMESERVERS (the edges, heaven and earth by default). The glue addresses are filled from the zone's own A and AAAA records when the zone is in Salt. A name server under the domain shows its IPv4 and IPv6 glue fields; a name outside the domain does not, and an address typed there is not sent.

Pre-flight check. "Check and continue" asks SaltDns.Registrar.Preflight before anything is sent. It reports five checks:

CheckWhat it asksA failure means
Salt holds the zonea zone of this organisation with this name is activethe new servers do not serve the name
The name servers answerevery name server about to be set resolves and answers the zone's SOAnothing would resolve after the move
The records matcha zone transfer from the current authority, or a question per record Salt holds when the transfer is refusedthe name would lose or change records
DNSSECthe DS record at the parent agrees with whether Salt's zone is signedvalidating resolvers would fail
Glue addressesa name server under the domain has an address, and the zone serves itthe registry cannot find the name server

The result is shown with the facts behind each check. A failed check keeps the confirmation button disabled. The operator can still proceed by ticking "I understand the risk", which is the only way past a failure; warnings do not block. The panel says plainly when a refused transfer means names that exist only at the current servers could not be seen.

Confirmation and audit. The change is sent only from the confirmation step, which names the old and the new set. set_name_servers/4 writes an event of kind domain.name_servers with the set before and after, the glue, the source (console or the token) and the acting organisation.

Propagation and undo. The registry publishes the new delegation at once; resolvers and caches follow as the old delegation's TTL runs out (minutes to a few hours). To undo, set the previous name servers on the same page; for a domain delegated to ns1/ns2.trouweherverdeling.nl, that is the previous set.

Managing a domain

Each row on the Domains page has a Manage button that opens the domain's own page (/orgs/:org_id/registrar/domains/:id); on the registrar page's Domains table the name itself and the Manage button lead there too. The domain page carries the expiry and the days left beside the status, and a Renew button that goes straight to the renewal panel. It shows the stored state — status, registered, expiry with the days left, the renewal date, automatic renewal, transfer lock, WHOIS privacy, DNSSEC at the registrar, the name servers and when the domain was last read — and the actions below. Read again at the registrar reads the domain at the provider; it is a read, not an order.

The page follows the same rules as the Domains page: owners and admins only, and only for a domain held at the organisation's own active registrar account. Everything else on the page is read-only.

Renewal

Renew asks for a period (1 to 10 years), reads the price the registrar gives for that domain, that operation and that period (Registrar.price/4, the adapter's price/4), and shows it. Only then does a confirmation appear: the amount, a ceiling in minor units (filled with the quoted price, editable) and a checkbox that names the domain, the period and the amount. Renew now is disabled until that box is ticked.

Salt has no billing of its own in this module: the registrar's account balance pays, so the page never renews on load and the command line and API have the same guard. renew/4 reads the price again immediately before buying and refuses above the ceiling (:price_above_ceiling); it also refuses a premium name it was not told to accept. The reference is derived from the domain, the period and the current expiry date, so a double click is the same request and buys nothing twice, while a later renewal (after the expiry moved) is a new one.

A renewal the registrar has not finished shows as pending; the page reads the domain again once, and the daily refresh keeps the stored expiry in step.

Settings

Three settings can be changed from the page, each behind a confirmation that names the consequence:

SettingOffOn
Automatic renewalthe registrar will let the name expirethe registrar renews it and charges the account
Transfer locka transfer can be started elsewherethe name cannot be transferred
WHOIS privacythe registrant details are public in WHOISthe registrar hides them (where the extension allows it)

Each calls set_autorenew/4, set_lock/4 or set_privacy/4 (adapter set_privacy/3), stores what the registrar accepted, and writes an event (domain.autorenew, domain.lock, domain.privacy). A registrar that refuses leaves the stored value as it was.

Authorisation (EPP) code

The code needed to move the name to another registrar is a secret: it is shown only after a confirmation, only once, and it stays visible only until it is hidden or the page is left. Salt never stores it and never logs it. auth_code/3 writes a domain.auth_code event with the fact that it was read, not the code.

Owner contact

Salt keeps the contact's reference, version and the registrar's handle; the name, address, e-mail and phone number live at the registrar and are not stored in Salt. The page shows the handle and the version, Check the verification reads the e-mail verification state of the contact, and Send newer contact data sends a complete contact with the next version (put_contact/6); an older version is refused.

DNSSEC

Salt signs the zone; the registrar publishes the DS at the parent. When the zone is signed, the page shows the DS records from Salt's own signing (with copy buttons) and offers Send the keys to the registrar, which calls set_dnssec/4 with the zone's CDNSKEY fields (Dnssec.registrar_keys/1) — nothing is typed in by hand. When the registrar believes DNSSEC is on, the page offers Turn DNSSEC off at the registrar; the page says plainly that the zone must stay signed until the parent no longer has the DS.

History

Below the actions is the domain's registrar history: Registrar.list_events/2, newest first — orders, renewals, name-server changes, reads, settings, the auth-code request and the expiry reminders.

Expiry reminders

While the registrar and mail delivery are on, a daily job mails the owners and admins of the organisation 60, 30 and 7 days before a domain expires (SaltDns.Registrar.Reminders). A domain with automatic renewal on is skipped (and so is an expired one: it is for the console). Each step is sent at most once: the send is recorded as a domain.expiry_reminder event with the step in detail.days, and an existing step is not sent again. A domain whose organisation has no owners or admins yet is not recorded, so it is tried again the next day. With mail_delivery off (no SALT_DNS_MAIL_URL, the default) nothing is sent and nothing is recorded; with a relay configured the mail leaves through it, Karta's SMTP among them (see configuration).

Which calls spend money

Spends moneyDoes not spend money
register, transfer, renew, restorecheck, prices, price, account, test_connection, put_contact and the contact verification calls, sync_domain, set_name_servers, set_lock, set_autorenew, set_privacy, set_dnssec, auth_code

Only the four calls on the left are charged to the registrar account. They have three guards, and a caller cannot turn them off.

  1. An operation reference. The caller gives every spending call a reference of its own (unique within the organisation). Salt writes a row for it in the operations ledger before it calls the registrar. The same reference with the same request returns the stored result and buys nothing, also when the first call is still running. The same reference with a different request (another name, years, owner contact, privacy, price ceiling, currency, or another name server or glue address) is refused as reference_reuse.
  2. A price ceiling. The caller says the most it accepts to pay (max_cost_minor and currency). Immediately before buying, Salt asks the registrar for the price again. If the price is higher, or in another currency, nothing is bought and the answer is price_above_ceiling with the current price.
  3. No premium names by accident. A premium name is refused unless the call says allow_premium: true. The premium price must still be within the ceiling.

When a call ends without a final answer (the registrar was not reached, it answered with a server error or a rate limit, the process stopped), the operation stays started and the caller retries with the same reference. Only a final refusal (no funds, a price above the ceiling, bad data, a name that cannot be had) is stored as failed and answered the same way every time. The next call with the same reference first looks the name up in the account at the registrar and finishes the operation from what it finds. Salt orders again only when the name is not there. A started operation that shows no error is left alone for ten minutes (stale_after, longer than the slowest execution can take), so a call that is still running is not doubled. A server error, a rate limit and wrong credentials do not end an operation: only a final refusal does. A 5xx that still carries the registrar's own error code is a refusal (the request was read and rejected, so nothing was ordered), and ends the operation as failed; one without a code stays server trouble and keeps it open. When a renewal cannot be shown either way (no expiry to compare), nothing is ordered and the operation stays open. An operator can give up an operation that is stuck (SaltDns.Registrar.abandon_operation/2): Salt first looks the name up, and abandons only when the registrar shows nothing was ordered, and never before the stale time has passed since the last attempt (after a timeout the registrar may still complete the order; a name that is found is completed at any age). While the registrar account's credentials are wrong or the provider is disabled, an open operation keeps holding its name, and abandon cannot free it until the registrar can be asked again. An operation that was left open by a refusal the registrar answered with its own error code (before that answer was read as final) is failed by Registrar.fail_refused_operation/2; it looks nothing up and orders nothing. When the registrar has accepted an order but not finished (a transfer takes days), the operation is pending; reading the domain again (sync_domain) resolves it.

Who may use which provider

A provider owned by an organisation serves that organisation and, through that organisation's provisioning token, its direct children (the customers).

A shared provider (no organisation) serves only the organisations the operator has allowed, and through a provisioning token their children. The operator sets the list from the command line, never from the console or the API:

bin/salt_dns eval 'IO.inspect(SaltDns.Release.registrar_allow(PROVIDER_ID, ORGANISATION_ID))'
bin/salt_dns eval 'IO.inspect(SaltDns.Release.registrar_disallow(PROVIDER_ID, ORGANISATION_ID))'

A call through a domain needs the caller's own account to be the domain's. Reading from the registrar, handing out the authorisation code, renewing, restoring, abandoning, changing the name servers or the lock, reading a contact's verification, all require that the active provider of the organisation of the API token (SaltDns.Registrar.active_provider/1) is the provider the domain is held at. The core functions take it as the option :via (the organisation of the token; by default the organisation itself, the strictest reading) and refuse otherwise. A customer organisation with a token of its own therefore reads its stored domain record, and gets no call on its parent's account and no authorisation code: it moves a name away only through the provider's own token.

An organisation that is not on the list has no provider through the shared one at every level, including reading the balance; the API answers 503 registrar_unavailable with the cause no_provider. The console offers a registrar level on a token only where the organisation has a provider it may use, and says why when it has none (a level asked for by a crafted event is refused too). An organisation sees a shared provider it is allowed to use as its name and its mode only, never its user name, company contact or connection state; one that is not allowed does not see it at all. A domain bought at a shared provider is no longer served to an organisation taken off the list.

The API and the token level

A billing system calls Salt under /api/v1/registrar; the guide is integrations/registrar.md. A token has a registrar level, set by an owner or admin when the token is created in the console (and changeable there), or with the registrar: option of SaltDns.Release.create_provisioning_token/4:

  • none (the default): no registrar call is allowed;
  • read: account, check, prices, reading domains and operations;
  • purchase: everything, including the four calls that spend money (register, transfer, renew, restore). purchase includes read.

Zone grants do not give this level and the level gives no zone rights. Every route answers 404 while SALT_DNS_REGISTRAR is off.

The background job

While the switch is on, one Oban job (SaltDns.Registrar.Worker) runs every five minutes and once a day:

  • operations that are pending are resolved by reading their domain again;
  • operations that have been started for longer than stale_after (a crash or a timeout in the middle) are looked up at the registrar and completed from what is found;
  • once a day, every registered domain that has not been read for 20 hours is read again (expiry, status, lock, name servers);
  • once a day, the expiry reminders that are due go out (see "Expiry reminders").

The job never places an order. For a stuck operation it can only ask whether the name is there: if it is, the operation is completed; if it is not, the operation is left open for the caller's next call with the same reference.

The console

The Registrar page of an organisation (owners and admins, only while the switch is on) lists the registrar accounts: add one, change it (a blank password keeps the old one), test the connection (the balance and currency are shown), turn it off and on, and set the company contact handle. The mode, sandbox or live, is shown on every account. Below are the domains and the operations, read only. Nothing on the page spends money. The token lists on the Credentials and Provisioning pages show the registrar level of each token.

Money

Every amount is a whole number of minor units (cents) and an ISO currency code, for example 1117 and USD. The registrar's decimals are read exactly and converted once, at the edge of the adapter. A price is rounded up, never down. Openprovider has no currency on the account itself; Salt takes the currency from its price answers.

What the amounts on an operation are. cost_quoted is the price Salt read from the registrar immediately before it ordered, checked against your ceiling and written on the row before the order goes. cost_charged is the same price, set once the order call itself succeeded; it is not an amount the registrar reported back after charging. When an operation was completed from a lookup (a repeat after a lost answer) it has a quote and no charge. For a period of several years the registrar's price is the total for the period (a promotion often applies to one year only), and the ceiling is checked against that total.

There is no overall spending cap. The only limit is the ceiling of each call. A caller that places many orders can spend as much as the registrar account holds; keep the balance at the registrar to what you accept to lose, and watch it.

Errors

KindMeaning
insufficient_fundsThe registrar account cannot pay.
name_unavailableThe name cannot be registered, or is already held (a domain that is pending, active or expired) or being ordered. A name that ended as deleted can be registered again.
price_above_ceilingThe price now is higher than the ceiling, or in another currency. The answer has the current price.
reference_reuseThe reference was used for a different request.
invalidThe request was refused as it is (bad data, a premium name without permission). It can carry field errors.
rate_limitedToo many calls; it can carry the seconds to wait.
registrar_unavailableThe registrar could not be reached or had a server error. Try again later.
not_foundNo such name or contact.
lockedThe name is locked, or in a state that forbids the change.
unauthorizedThe registrar did not accept the user name and password. Nothing was bought; the operation stays open, and the same reference works once the password is fixed.
providerAnything else.

Switching it on

Set SALT_DNS_REGISTRAR=on (see configuration.md). It needs no other setting. Then add a provider in sandbox mode, test the connection, and try a registration of a name you do not mind losing before you use live.

Adapters are registered by name, and each provider names the one it uses:

config :salt_dns, SaltDns.Registrar,
  adapters: %{"openprovider" => SaltDns.Registrar.Openprovider}

A registrar Salt does not ship is a module that implements SaltDns.Registrar.Adapter (the plug-in point) and is added to that map.

Openprovider

The adapter logs in with the user name and password (the token lives 48 hours; Salt keeps it in memory only, uses it for 40 hours, and logs in again once if the registrar answers 401). In sandbox mode it talks to api.cte.openprovider.eu, in live mode to api.openprovider.eu. Both addresses, and the API version prefixes, can be changed with config :salt_dns, SaltDns.Registrar.Openprovider (see the module documentation of SaltDns.Registrar.Openprovider.Client).

Salt never writes request or response bodies to the log: they hold personal data and authorisation codes. A log line has the call name, the HTTP status, the time taken and the registrar's own code.

Prices are the reseller prices (what you pay), not the list prices. The price list of an extension is cached for five minutes; a check can ask for fresh prices.

Calls that were checked against the live API: login, the account, the check, the price calls, extensions, creating and deleting contacts, and the "insufficient funds" answer. The others (transfer, renew, restore, reading and changing a domain, the authorisation code, contact verification, looking up a name) follow the registrar's public API description and have not run against it yet: try them in sandbox mode first.

Secrets and history

The registrar password is encrypted at rest with the vault key and is included in vault key rotation (SaltDns.Release.rotate_vault/0). Events (SaltDns.Registrar.Event) record what happened: names, amounts, currencies, error kinds. They never hold the password, an authorisation code or a contact's data.

How this is tested

The rules of the money path (the ceiling and premium guard, when an order counts as done, what a malformed answer from an adapter becomes) are in SaltDns.Registrar.Rules and are tested in the normal run. The context (SaltDns.Registrar: the operations ledger, claiming a reference, resuming, contacts, domains) needs a database, so its tests are tagged integration and run in the integration job against the development stack, with a fake adapter and no network. The quality job (mix coveralls) runs without a database, so lib/salt_dns/registrar.ex is on the coverage skip list, as the other context modules that need Postgres are; the Rules, the adapter, the client, the money and name modules are counted.

The contact verification states of Openprovider are not verified against the live API: Salt recognises a few words and reports anything else as unknown.