UeberauthToken.Config (ueberauth_token v0.2.0-dev)
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
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
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` 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`.
See `UeberauthToken.Strategy`
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
background_checks?(provider)
Whether the background checks on the token will be performed or not.
Defaults to false
background_frequency(provider)
The average frequency with which background checks should be performed.
Defaults to 300 seconds.
background_worker_log_level(provider)
The log level at which the background worker will log unexpected timeout and terminate events.
Defaults to :warn
cache_name(provider)
Get the name for the cache.
Defaults to underscored provider name concatenated with ueberauth_token
.
provider_config(provider)
Get the configuration for a given provider.
providers()
@spec providers() :: Keyword.t()
Get the list of configured providers.
use_cache?(provider)
Whether the cache is to be started and used or not.
Defaults to true
if not set
validate_provider!(provider)
Validates a provider as one which has been specified in the configuration.
Raises and error if the provider is not configured.
validate_provider(provider)
@spec validate_provider(provider :: module()) :: {:ok, :valid} | {:error, :invalid}
Validates a provider as one which has been specified in the configuration