A database's security object: who its admins and members are, by user name and by role.
If the only tool you have is CouchDB, then everything looks like
{:ok, :relax}
See https://docs.couchdb.org/en/stable/api/database/security.html. An
empty object means every server admin is an admin and everyone else,
including anonymous users, is a member. CouchDB 3 creates databases
admin-only instead, with the _admin role on both grants, unless its
default_security setting says otherwise. Users and roles are those of
Sofa.User documents in _users.
Read and write it with Sofa.DB.security/1 and Sofa.DB.set_security/2.
Examples
Sofa.Security.new()
|> Sofa.Security.admin("jan")
|> Sofa.Security.member(role: "users")
|> then(&Sofa.DB.set_security(db, &1))
iex> Sofa.Security.new() |> Sofa.Security.member("jan") |> Sofa.Security.member(role: "users") |> Sofa.Security.to_map()
%{"admins" => %{"names" => [], "roles" => []}, "members" => %{"names" => ["jan"], "roles" => ["users"]}}
Summary
Functions
Grants admin access to a user name, or with role: to a role.
Whether the object grants nothing, which leaves the database open to all.
From the JSON object CouchDB returns. Missing parts are empty.
Grants member access to a user name, or with role: to a role.
An empty security object, as a new database has.
To the JSON object CouchDB expects.
Types
Functions
Grants admin access to a user name, or with role: to a role.
Whether the object grants nothing, which leaves the database open to all.
From the JSON object CouchDB returns. Missing parts are empty.
Grants member access to a user name, or with role: to a role.
@spec new() :: t()
An empty security object, as a new database has.
To the JSON object CouchDB expects.