Packages

MongoDB driver for Elixir

Retired package: Deprecated - Use mongodb_driver instead, see https://github.com/elixir-mongo/mongodb_ecto/tree/1cc91b087#migrating-to-20 for migration advice

Current section

Files

Jump to
mongodb lib mongo auth plain.ex
Raw

lib/mongo/auth/plain.ex

defmodule Mongo.Auth.Plain do
@moduledoc false
import Mongo.Protocol.Utils
def auth({username, password}, s) do
encoded_auth = Base.encode64("\x00#{username}\x00#{password}")
result =
command(-1, [saslStart: 1, mechanism: "PLAIN", payload: encoded_auth, autoAuthorize: 1], s)
case result do
{:ok, _res} -> :ok
error -> error
end
end
end