Sovite.SASL.Backend.Static (sovite v0.2.0)

Copy Markdown View Source

A Sovite.SASL.Backend that reads users from a file, one per line:

# user:password-hash[:anything else]
alice@example.com:{SCRAM-SHA-256}4096,...
bob@example.com:$6$rounds=5000$...

The format is compatible with Dovecot's passwd-file: fields after the second are ignored. Blank lines and lines starting with # are skipped. User names are matched case-insensitively. Hashes are in a format Sovite.SASL.Password knows; sovitectl hash-password makes them.

The file is read on first use and again whenever it changes, so users can be added without a restart. If a changed file cannot be read, the previous contents stay in use.

Options

  • :file - path to the users file. Required.

Summary

Types

Why a users file was refused: the line number and the problem.

Functions

Reads and checks a users file. Returns the users, keyed by lower-cased name, or the first problem.

Parses the contents of a users file, see load/1.

Types

parse_error()

@type parse_error() :: {:line, pos_integer(), :syntax | :unsupported_hash}

Why a users file was refused: the line number and the problem.

Functions

load(path)

@spec load(Path.t()) ::
  {:ok, %{required(String.t()) => String.t()}}
  | {:error, File.posix() | parse_error()}

Reads and checks a users file. Returns the users, keyed by lower-cased name, or the first problem.

parse(contents)

@spec parse(String.t()) ::
  {:ok, %{required(String.t()) => String.t()}} | {:error, parse_error()}

Parses the contents of a users file, see load/1.