SaltDns.Access (Salt v1.0.0)

The single authorisation boundary. The API, the UI and the RFC 2136 listener call authorize/5 before they touch data; SaltDns.Zones is an internal, unauthorised layer and must not be called from a request path without going through here first.

The actor is {:user, %SaltDns.Accounts.Scope{}} (a signed-in user) or {:credential, %SaltDns.Credentials.Credential{}} (an authenticated API token or TSIG key; authenticate it just before, a stale struct is trusted for its revoked_at and expires_at).

case Access.authorize(actor, :update, zone, "www.example.com", "A") do
  :ok -> Zones.put_rrset(zone, attrs, audit_actor)
  {:error, :forbidden} -> ...
end

The rules are in SaltDns.Access.Policy: organisation isolation first, then the user's role or the credential's grants. Organisations are never revealed: every refusal is the same {:error, :forbidden}.

Summary

Functions

Authorises action on the RRset (name, type) of zone.

Authorises READ of a zone of a customer (child) organisation of parent: the actor must be owner or admin of parent and the zone's organisation must be a child of parent. This is the only access a provider's user gets to a child's zones; authorize/5 still refuses every write there, because the user has no role in the child. Customers of customers are not seen: only direct children count.

Authorises an action on the zone itself (its settings, deletion): the apex SOA, which is how grants express :manage.

True when the actor may use the certificate module in the organisation (for one zone, or for the organisation with nil). level is :read or :manage; see SaltDns.Access.Policy.certificates?/5. Needs the :certificates grant for credentials: DNS grants never give it.

True when the actor may create a zone called name in the organisation: owners and admins, and credentials with a grant of zone :any and action :manage that covers the new zone's apex (see Policy.creates_zones?/4).

True for users who are owner or admin of the organisation. Credentials never.

True when the actor may create, change and delete the organisation's secondaries: owners and admins, and credentials with a grant of zone :any and action :manage.

True when the actor may use routing (proxy groups, backends, routes, nodes) in the organisation; see SaltDns.Access.Policy.proxy?/4. Credentials need the :proxy grant of zone :any.

True when the actor is owner or admin of parent, the provider of customer organisations (see SaltDns.Provisioning). Users only; credentials never.

Types

action()

@type action() :: SaltDns.Access.Policy.action()

actor()

@type actor() ::
  {:user, SaltDns.Accounts.Scope.t()}
  | {:credential, SaltDns.Credentials.Credential.t()}

Functions

allowed?(actor, action, zone, name, type)

@spec allowed?(actor(), action(), SaltDns.Zones.Zone.t(), String.t(), String.t()) ::
  boolean()

Like authorize/5 but returns a boolean.

authorize(actor, action, zone, name, type)

@spec authorize(actor(), action(), SaltDns.Zones.Zone.t(), String.t(), String.t()) ::
  :ok | {:error, :forbidden}

Authorises action on the RRset (name, type) of zone.

authorize_customer_zone(actor, parent, zone)

@spec authorize_customer_zone(
  actor(),
  SaltDns.Accounts.Organisation.t(),
  SaltDns.Zones.Zone.t()
) ::
  :ok | {:error, :forbidden}

Authorises READ of a zone of a customer (child) organisation of parent: the actor must be owner or admin of parent and the zone's organisation must be a child of parent. This is the only access a provider's user gets to a child's zones; authorize/5 still refuses every write there, because the user has no role in the child. Customers of customers are not seen: only direct children count.

authorize_zone(actor, action, zone)

@spec authorize_zone(actor(), action(), SaltDns.Zones.Zone.t()) ::
  :ok | {:error, :forbidden}

Authorises an action on the zone itself (its settings, deletion): the apex SOA, which is how grants express :manage.

can_certificates?(actor, organisation, level, zone_name \\ nil)

@spec can_certificates?(
  actor(),
  SaltDns.Accounts.Organisation.t(),
  :read | :manage,
  String.t() | nil
) ::
  boolean()

True when the actor may use the certificate module in the organisation (for one zone, or for the organisation with nil). level is :read or :manage; see SaltDns.Access.Policy.certificates?/5. Needs the :certificates grant for credentials: DNS grants never give it.

can_create_zone?(actor, organisation, name)

@spec can_create_zone?(actor(), SaltDns.Accounts.Organisation.t(), String.t()) ::
  boolean()

True when the actor may create a zone called name in the organisation: owners and admins, and credentials with a grant of zone :any and action :manage that covers the new zone's apex (see Policy.creates_zones?/4).

can_manage_credentials?(actor, organisation)

@spec can_manage_credentials?(actor(), SaltDns.Accounts.Organisation.t()) :: boolean()

True for users who are owner or admin of the organisation. Credentials never.

can_manage_secondaries?(actor, organisation)

@spec can_manage_secondaries?(actor(), SaltDns.Accounts.Organisation.t()) :: boolean()

True when the actor may create, change and delete the organisation's secondaries: owners and admins, and credentials with a grant of zone :any and action :manage.

can_proxy?(actor, organisation, level)

@spec can_proxy?(actor(), SaltDns.Accounts.Organisation.t(), :read | :manage) ::
  boolean()

True when the actor may use routing (proxy groups, backends, routes, nodes) in the organisation; see SaltDns.Access.Policy.proxy?/4. Credentials need the :proxy grant of zone :any.

can_read_customers?(actor, parent)

@spec can_read_customers?(actor(), SaltDns.Accounts.Organisation.t()) :: boolean()

True when the actor is owner or admin of parent, the provider of customer organisations (see SaltDns.Provisioning). Users only; credentials never.