ueberauth_token v0.1.1 UeberauthToken.Config

Helper functions for ueberauth_token configuration.

Cachex may be used for the storage of tokens temporarily by setting the option :use_cache to true. Cached tokens increase speed of token payload lookup but with the tradeoff that token invalidation may be delayed. This can optionally be mitigated somewhat by also using the background token worker inconjunction with the cached token.

Example configuration

config :ueberauth_token, UeberauthToken.Config,
  providers: {:system, :list, "TEST_TOKEN_PROVIDER", [UeberauthToken.TestProvider]}

config :ueberauth_token, UeberauthToken.TestProvider,
  use_cache: {:system, :boolean, "TEST_USE_CACHE", false},
  cache_name: {:system, :atom, "TEST_CACHE_NAME", :ueberauth_token},
  background_checks: {:system, :boolean, "TEST_BACKGROUND_CHECKS", false},
  background_frequency: {:system, :integer, "TEST_BACKGROUND_FREQUENCY", 120},
  background_worker_log_level: {:system, :integer, "TEST_BACKGROUND_WORKER_LOG_LEVEL", :warn}

Configuration options

* `:use_cache` - boolean
Whether or not the cache should be used at all. If set to
true, the Cachex worker will be started in the supervision tree
and the token will be cached.

* `:background_checks` - boolean
Whether or not to perform background checks on the tokens in the cache.
If set to true, the [`UeberauthToken.Worker`](UeberauthToken.Worker.html) is started in the supervision
tree. If unset, defaults to `false`

* `:background_frequency` - seconds as an integer
The frequency with which each token in the cache will be checked. The
checks are not applied all at once, but staggered out across the
`background_frequency` value in 30 evenly graduated phasese
to avoid a burst of requests for the token verification. Defaults to
`300` (5 minutes).

* `:background_worker_log_level` - `:debug`, `:info`, `:warn` or `:error`
The log level at which the background worker will log unexpected timeout
and terminate events. Defaults to `:warn`

* `:cache_name` - an atom
The ets table name for the cache

* `:provider` - a module
a required provider module which implements the callbacks defined in [`UeberauthToken.Strategy`](UeberauthToken.Strategy.html).
See [`UeberauthToken.Strategy`](UeberauthToken.Strategy.html)

Link to this section Summary

Functions

Whether the background checks on the token will be performed or not

The average frequency with which background checks should be performed

The log level at which the background worker will log unexpected timeout and terminate events

Get the name for the cache

Get the configuration for a given provider

Get the list of configured providers

Whether the cache is to be started and used or not

Validates a provider as one which has been specified in the configuration

Validates a provider as one which has been specified in the configuration

Link to this section Functions

Link to this function background_checks?(provider)
background_checks?(provider :: module()) :: boolean()

Whether the background checks on the token will be performed or not.

Defaults to false

Link to this function background_frequency(provider)
background_frequency(provider :: module()) :: boolean()

The average frequency with which background checks should be performed.

Defaults to 300 seconds.

Link to this function background_worker_log_level(provider)
background_worker_log_level(provider :: module()) :: boolean()

The log level at which the background worker will log unexpected timeout and terminate events.

Defaults to :warn

Link to this function cache_name(provider)
cache_name(provider :: module()) :: atom()

Get the name for the cache.

Defaults to underscored provider name concatenated with ueberauth_token.

Link to this function provider_config(provider)
provider_config(provider :: module()) :: Keyword.t()

Get the configuration for a given provider.

Link to this function providers()
providers() :: Keyword.t()

Get the list of configured providers.

Link to this function use_cache?(provider)
use_cache?(provider :: module()) :: boolean()

Whether the cache is to be started and used or not.

Defaults to true if not set

Link to this function validate_provider(provider)
validate_provider(provider :: module()) :: {:ok, :valid} | {:error, :invalid}

Validates a provider as one which has been specified in the configuration

Link to this function validate_provider!(provider)
validate_provider!(provider :: module()) :: :ok | no_return()

Validates a provider as one which has been specified in the configuration.

Raises and error if the provider is not configured.