SaltDns.Ownership (Salt v1.0.0)

Zone ownership (decision D15): a new zone is pending and becomes active only when its holder shows control of the name, by delegation (read from the parent zone's servers, SaltDns.Resolver.Delegation) or by a TXT challenge (SaltDns.Ownership.Check). This module asks the resolver (SaltDns.Resolver), applies the outcome and writes the audit rows; it changes status only, nothing else about how a zone is served.

Configuration:

config :salt_dns, :nameservers, ["ns1.salt.example", "ns2.salt.example"]
config :salt_dns, SaltDns.Ownership, verification_days: 7, grace_days: 30

Life of a zone

  • Created: pending, with a random token. An Oban job (SaltDns.Ownership.Worker) checks after 1 minute, then 5, 15, 60 minutes, then hourly, for verification_days (7). After that the zone stays pending with the reason verification_expired; verify/3 still works whenever someone asks.
  • Verified (verify/3 finds proof): pending -> active, method and time recorded, audit action ownership_verified. If another organisation already has the name active (checked first, and enforced by the database's unique index when two verify at once) the zone stays pending with the reason claimed_elsewhere.
  • Re-verified every day (reverify/2): proof that is missing starts a clock; after grace_days (30) without any proof the zone becomes disabled with the reason ownership_lost and an audit row (source reconciler, action ownership_lost). Proof that returns clears the clock. A resolver that cannot answer is inconclusive and changes nothing. verify/3 also re-activates a zone that was disabled for lost ownership; a zone disabled by hand stays disabled.

Every status change writes an audit row. Failed checks only update last_checked_at, verification_reason and verification_detail.

Summary

Functions

Asks whether the zone is delegated to Salt DNS (the referral its parent publishes, SaltDns.Resolver.Delegation, so a zone that is not served yet can be proven) or carries its challenge (through the recursive resolver). Returns {outcome, method_or_nil, detail}; detail is a map of strings for the audit and the API. Nothing is written.

Days without proof before an active zone is disabled (default 30).

What the holder of a zone has to publish: the TXT record and the nameservers of the two methods.

Salt DNS's own nameservers, as configured.

The daily check of an active zone. Proof present: the clock is cleared. Proof missing: the clock starts, and after grace_days the zone is disabled (ownership_lost, audit source reconciler). A resolver that cannot answer changes nothing, and the time it could not answer does not count towards the grace period. Returns the outcome and the zone.

Queues the first automatic check of a new pending zone (a minute from now).

Days an automatic first verification keeps trying (default 7).

Checks the zone now and applies the result. Returns {:ok, %{zone: zone, outcome: outcome, method: method}}, or {:error, :disabled} for a zone that was disabled other than by lost ownership. Options: :now.

Types

outcome()

@type outcome() :: :verified | :not_verified | :inconclusive | :claimed_elsewhere

result()

@type result() :: %{
  zone: SaltDns.Zones.Zone.t(),
  outcome: outcome(),
  method: atom() | nil
}

Functions

check(zone)

@spec check(SaltDns.Zones.Zone.t()) ::
  {:verified | :not_verified | :inconclusive, atom() | nil, map()}

Asks whether the zone is delegated to Salt DNS (the referral its parent publishes, SaltDns.Resolver.Delegation, so a zone that is not served yet can be proven) or carries its challenge (through the recursive resolver). Returns {outcome, method_or_nil, detail}; detail is a map of strings for the audit and the API. Nothing is written.

grace_days()

@spec grace_days() :: pos_integer()

Days without proof before an active zone is disabled (default 30).

instructions(zone)

@spec instructions(SaltDns.Zones.Zone.t()) :: map()

What the holder of a zone has to publish: the TXT record and the nameservers of the two methods.

nameservers()

@spec nameservers() :: [String.t()]

Salt DNS's own nameservers, as configured.

reverify(zone, opts \\ [])

@spec reverify(SaltDns.Zones.Zone.t(), keyword()) :: result()

The daily check of an active zone. Proof present: the clock is cleared. Proof missing: the clock starts, and after grace_days the zone is disabled (ownership_lost, audit source reconciler). A resolver that cannot answer changes nothing, and the time it could not answer does not count towards the grace period. Returns the outcome and the zone.

schedule_first_check(zone)

@spec schedule_first_check(SaltDns.Zones.Zone.t()) ::
  {:ok, Oban.Job.t() | :not_needed} | {:error, term()}

Queues the first automatic check of a new pending zone (a minute from now).

verification_days()

@spec verification_days() :: pos_integer()

Days an automatic first verification keeps trying (default 7).

verify(zone, actor, opts \\ [])

@spec verify(SaltDns.Zones.Zone.t(), SaltDns.Zones.Actor.t(), keyword()) ::
  {:ok, result()} | {:error, :disabled}

Checks the zone now and applies the result. Returns {:ok, %{zone: zone, outcome: outcome, method: method}}, or {:error, :disabled} for a zone that was disabled other than by lost ownership. Options: :now.

Outcomes: :verified (the zone is active), :not_verified, :inconclusive (the resolver could not answer), :claimed_elsewhere.