Managoat.OAuth.Config (managoat_oauth v0.1.1)

Copy Markdown View Source

What one instance of Managoat.OAuth runs with, read from the host's own otp_app under the instance module's key:

config :my_app, MyApp.OAuth,
  repo: MyApp.Repo,
  clients: [%{id: "spa", name: "SPA", redirect_uris: ["https://spa.example/"]}],
  prefix: nil

repo has no default: a consumer that forgets it gets an error naming the key, not a query against nothing. host comes from the use line and is checked here too, so a nil in either place is the same error. clients defaults to none and is normalised on every read (atom or string keys, name falling back to id), so a JSON registry decodes straight into it. prefix is the Postgres schema the two tables live in, nil for the default; it is passed to every repo call and matches the prefix: given to Managoat.OAuth.Migration.up/1. nil counts as unset for all three.

Summary

Functions

The instance's config, or a raise naming what is missing. Read on every call rather than cached: the client list is runtime configuration that a host may set from its environment after compile.

The options every repo call takes: the prefix when there is one.

Types

t()

@type t() :: %Managoat.OAuth.Config{
  clients: [Managoat.OAuth.Clients.client()],
  host: module(),
  prefix: String.t() | nil,
  repo: module()
}

Functions

load!(otp_app, instance, host)

@spec load!(atom(), module(), module() | nil) :: t()

The instance's config, or a raise naming what is missing. Read on every call rather than cached: the client list is runtime configuration that a host may set from its environment after compile.

repo_opts(config)

@spec repo_opts(t()) :: keyword()

The options every repo call takes: the prefix when there is one.