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: 30Life 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, forverification_days(7). After that the zone stays pending with the reasonverification_expired;verify/3still works whenever someone asks. - Verified (
verify/3finds proof):pending -> active, method and time recorded, audit actionownership_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 reasonclaimed_elsewhere. - Re-verified every day (
reverify/2): proof that is missing starts a clock; aftergrace_days(30) without any proof the zone becomesdisabledwith the reasonownership_lostand an audit row (sourcereconciler, actionownership_lost). Proof that returns clears the clock. A resolver that cannot answer is inconclusive and changes nothing.verify/3also 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
@type outcome() :: :verified | :not_verified | :inconclusive | :claimed_elsewhere
@type result() :: %{ zone: SaltDns.Zones.Zone.t(), outcome: outcome(), method: atom() | nil }
Functions
@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.
@spec grace_days() :: pos_integer()
Days without proof before an active zone is disabled (default 30).
@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.
@spec nameservers() :: [String.t()]
Salt DNS's own nameservers, as configured.
@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.
@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).
@spec verification_days() :: pos_integer()
Days an automatic first verification keeps trying (default 7).
@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.