CouchDB.Environment (couchdb_auth v0.2.4)

View Source

Runtime configuration helpers for the CouchDB adapter.

The module reads values either from the application environment (config/*.exs) or from operating system variables prefixed with COUCHDB_. Environment variables take precedence, which allows the library to be configured without recompilation.

Summary

Types

Authentication type configured for the adapter.

Username and password for basic authentication.

CouchDB connection credentials.

HTTP headers are modeled as name/value pairs.

User information map.

CouchDB user role is a simple string; a list of strings represents user roles.

Functions

Returns admin path depending on whether a cluster is configured.

Returns the base URL for admin or cluster-aware endpoints.

Returns the configured authentication type.

Returns the base URL for the CouchDB backend (node management) interface.

Returns the base URL for the primary CouchDB interface.

Returns the configured bearer (JWT) token, if present.

Returns the configured database properties.

Returns the configured OAuth credentials.

Returns proxy authentication configuration.

Returns configured server admin credentials.

Types

auth_type()

@type auth_type() :: :admin_party | :basic | :cookie | :oauth | :bearer | :proxy

Authentication type configured for the adapter.

basic_auth()

@type basic_auth() :: %{user: String.t() | nil, password: String.t() | nil}

Username and password for basic authentication.

conn()

@type conn() :: %{
  protocol: String.t(),
  hostname: String.t(),
  database: String.t(),
  port: String.t() | nil,
  user: String.t() | nil,
  password: String.t() | nil
}

CouchDB connection credentials.

headers()

@type headers() :: [{String.t(), String.t()}]

HTTP headers are modeled as name/value pairs.

user_info()

@type user_info() :: %{user: String.t() | nil, password: String.t() | nil}

User information map.

user_roles()

@type user_roles() :: [String.t()]

CouchDB user role is a simple string; a list of strings represents user roles.

Functions

admin_path()

@spec admin_path() :: String.t()

Returns admin path depending on whether a cluster is configured.

admin_url()

@spec admin_url() :: String.t()

Returns the base URL for admin or cluster-aware endpoints.

auth_type()

@spec auth_type() :: auth_type()

Returns the configured authentication type.

backend_url()

@spec backend_url() :: String.t()

Returns the base URL for the CouchDB backend (node management) interface.

base_url()

@spec base_url() :: String.t()

Returns the base URL for the primary CouchDB interface.

bearer_token()

@spec bearer_token() :: String.t() | nil

Returns the configured bearer (JWT) token, if present.

dbprops()

@spec dbprops() :: %{
  protocol: String.t() | nil,
  hostname: String.t() | nil,
  port: String.t() | nil,
  backend_port: String.t() | nil,
  database: String.t() | nil,
  cluster: boolean(),
  node_name: String.t() | nil
}

Returns the configured database properties.

oauth_creds()

@spec oauth_creds() :: %{
  optional(:consumer_key) => String.t() | nil,
  optional(:consumer_secret) => String.t() | nil,
  optional(:token) => String.t() | nil,
  optional(:token_secret) => String.t() | nil
}

Returns the configured OAuth credentials.

proxy_config()

@spec proxy_config() :: %{
  user: String.t() | nil,
  roles: user_roles(),
  secret: String.t() | nil,
  token: String.t() | nil
}

Returns proxy authentication configuration.

server_admin()

@spec server_admin() :: basic_auth()

Returns configured server admin credentials.