Sovite.SASL.Dovecot (sovite v0.2.0)

Copy Markdown View Source

Hands SASL authentication to a Dovecot auth server, over its client protocol (version 1.2), like Postfix's smtpd_sasl_type = dovecot.

Dovecot runs the mechanism and checks the credentials against whatever it is set up with; Sovite only relays the exchange. Each exchange uses its own connection, opened by start/3 and closed when it ends.

Options

  • :socket - path of Dovecot's auth client socket, for example /run/dovecot/auth-client, or {host, port} for TCP. Required.
  • :service - the service name Dovecot sees. Defaults to "smtp".
  • :timeout - milliseconds to wait for Dovecot. Defaults to 30 seconds.
  • :client - about the SMTP client, passed on for Dovecot's policies and logs: :remote_ip, :remote_port, :local_ip, :local_port, and :secured (the connection is encrypted).

Errors

As for Sovite.SASL.Server: :invalid_credentials, :temporary (Dovecot is down or said temp), or :malformed.

Summary

Functions

Abandons an exchange and closes its connection.

Asks Dovecot which mechanisms it offers.

Starts an exchange. initial is as for Sovite.SASL.Server.start/3.

Sends the client's response to Dovecot's last challenge.

Types

result()

@type result() ::
  {:ok, identity :: String.t()}
  | {:challenge, binary(), t()}
  | {:error, Sovite.SASL.Server.error(), username :: String.t() | nil}

t()

@opaque t()

Functions

abort(dovecot)

@spec abort(t()) :: :ok

Abandons an exchange and closes its connection.

mechanisms(opts)

@spec mechanisms(keyword()) :: {:ok, [String.t()]} | {:error, term()}

Asks Dovecot which mechanisms it offers.

start(mechanism, initial, opts)

@spec start(String.t(), binary() | nil, keyword()) :: result()

Starts an exchange. initial is as for Sovite.SASL.Server.start/3.

step(conn, response)

@spec step(t(), binary()) :: result()

Sends the client's response to Dovecot's last challenge.