Karta.Credentials.Credential (Karta v1.0.0)

A server's credential: an API key (kind: :api) or an SMTP login (kind: :smtp).

  • An API key reads karta_<prefix>_<secret>. The row keeps the 8-character prefix, to find it, and an Argon2id hash of the secret (secret_hash). scopes say what the key may do.
  • An SMTP credential logs in with the user name prefix and a generated password. The row keeps only SCRAM-SHA-256 keys (scram_salt, scram_iterations, scram_stored_key, scram_server_key; Karta.SASL.SCRAM), which check PLAIN, LOGIN and SCRAM-SHA-256 alike.
  • An IP range credential (kind: :ip) names a cidr range of client addresses that may send through the server without AUTH (Karta.SMTP.Relay.Range). It has no secret and no prefix; tls_required says whether a client in the range must connect over TLS first.

A Kantoor key (kantoor: true, optional, see Karta.Kantoor) is an API key that is accepted on /kantoor/v1 only, and on no other API. allowed_domains and allowed_mailboxes (nil: no restriction) limit what it may touch there (Karta.Kantoor.Restrictions). They are set only through kantoor_changeset/2, never by the changeset the APIs use.

reference is the calling system's name for a credential made through the provisioning API (Karta.Provisioning.Access); it is unique among a server's active credentials and never set by input.

rate_limit_per_minute caps what the credential may do per minute (nil: the default). A revoked credential (revoked_at) never authenticates.

Summary

Functions

What input may set: the name, the rate limit and, for API keys, the scopes; for an IP range, the range and its TLS requirement. Kind, server, secrets and dates are set by the context.

The changeset of a Kantoor key (Karta.Credentials.create_kantoor_key/2): as for any API key, plus the restrictions, which must be valid patterns (Karta.Kantoor.Restrictions).

Every scope an API key can have.

Types

t()

@type t() :: %Karta.Credentials.Credential{
  __meta__: term(),
  allowed_domains: term(),
  allowed_mailboxes: term(),
  cidr: term(),
  id: term(),
  inserted_at: term(),
  kantoor: term(),
  kind: term(),
  last_used_at: term(),
  name: term(),
  prefix: term(),
  rate_limit_per_minute: term(),
  reference: term(),
  revoked_at: term(),
  scopes: term(),
  scram_iterations: term(),
  scram_salt: term(),
  scram_server_key: term(),
  scram_stored_key: term(),
  secret_hash: term(),
  server: term(),
  server_id: term(),
  tls_required: term(),
  updated_at: term()
}

Functions

changeset(credential, attrs)

What input may set: the name, the rate limit and, for API keys, the scopes; for an IP range, the range and its TLS requirement. Kind, server, secrets and dates are set by the context.

kantoor_changeset(credential, attrs)

The changeset of a Kantoor key (Karta.Credentials.create_kantoor_key/2): as for any API key, plus the restrictions, which must be valid patterns (Karta.Kantoor.Restrictions).

scopes()

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

Every scope an API key can have.