Sigra.OAuth.Strategies (Sigra v0.2.5)

Copy Markdown View Source

Resolves provider atoms to their corresponding strategy wrapper modules.

Named strategies (Google, GitHub, Apple, Facebook) have dedicated wrappers that normalize Assent responses to a consistent map shape. Unknown providers with a :strategy key in their config are handled by the Generic fallback.

Examples

iex> Sigra.OAuth.Strategies.resolve(:google, [])
Sigra.OAuth.Strategies.Google

iex> Sigra.OAuth.Strategies.resolve(:discord, [strategy: Assent.Strategy.Discord])
Sigra.OAuth.Strategies.Generic

iex> Sigra.OAuth.Strategies.resolve(:discord, [])
{:error, :unknown_provider}

Summary

Functions

Returns the map of known provider atoms to their strategy wrapper modules.

Resolves a provider atom and its config to the appropriate strategy module.

Functions

named_strategies()

(since 0.1.0)
@spec named_strategies() :: map()

Returns the map of known provider atoms to their strategy wrapper modules.

resolve(provider, provider_config)

(since 0.1.0)
@spec resolve(
  atom(),
  keyword()
) :: module() | {:error, :unknown_provider}

Resolves a provider atom and its config to the appropriate strategy module.

Returns the named wrapper module for known providers, Sigra.OAuth.Strategies.Generic for unknown providers that include a :strategy key, or {:error, :unknown_provider} if neither applies.