View Source Lightning.AuthProviders.Handler (Lightning v2.10.4)

Module which wraps Oauth configuration and a WellKnown document into a convenient struct that can be used to authenticate users against any OIDC compliant provider.

Summary

Functions

Returns a Handler from a given AuthConfig

Create a new Provider struct, expects a name and opts

Types

@type opts() :: [
  client_id: String.t(),
  client_secret: String.t(),
  redirect_uri: String.t(),
  wellknown: Lightning.AuthProviders.WellKnown.t()
]
@type t() :: %Lightning.AuthProviders.Handler{
  client: OAuth2.Client.t(),
  name: String.t(),
  wellknown: Lightning.AuthProviders.WellKnown.t()
}

Functions

@spec authorize_url(handler :: t()) :: String.t()
@spec from_model(model :: nil | Lightning.AuthProviders.AuthConfig.t()) ::
  {:ok, t()} | {:error, term()}

Returns a Handler from a given AuthConfig

Link to this function

get_token(handler, code)

View Source
@spec get_token(handler :: t(), code :: String.t()) ::
  {:ok, OAuth2.AccessToken.t()} | {:error, map()}
Link to this function

get_userinfo(handler, token)

View Source
@spec get_userinfo(handler :: t(), token :: OAuth2.AccessToken.t()) :: map()
@spec new(name :: String.t(), opts :: opts()) :: {:ok, t()} | {:error, term()}

Create a new Provider struct, expects a name and opts:

  • :client_id - The providers issued id
  • :client_secret - Secret for the client
  • :redirect_uri - The URI for redirecting after authentication, usually the callback url in the router.
  • :wellknown - A AuthProviders.WellKnown struct with the providers .well-known/openid-configuration.