View Source Assent.Strategy behaviour (Assent v0.2.0)
Used for creating strategies.
usage
Usage
Set up my_strategy.ex
the following way:
defmodule MyStrategy do
@behaviour Assent.Strategy
alias Assent.Strategy, as: Helpers
def authorize_url(config) do
# Generate redirect URL
{:ok, %{url: url, ...}}
end
def callback(config, params) do
# Fetch user data
user = Helpers.normalize_userinfo(userinfo)
{:ok, %{user: user, ...}}
end
end
Link to this section Summary
Functions
Decode a JSON response to a map
Decodes a request response.
Normalize API user request response into standard claims
Recursively prunes map for nil values.
Makes a HTTP request.
Signs a JWT
Generates a URL
Verifies a JWT
Link to this section Callbacks
Specs
authorize_url(Assent.Config.t()) :: {:ok, %{:url => binary(), optional(atom()) => any()}} | {:error, term()}
Specs
Link to this section Functions
Specs
decode_json(binary(), Assent.Config.t()) :: {:ok, map()} | {:error, term()}
Decode a JSON response to a map
Specs
decode_response( {:ok, Assent.HTTPResponse.t()} | {:error, Assent.HTTPResponse.t()} | {:error.term()}, Assent.Config.t() ) :: {:ok, Assent.HTTPResponse.t()} | {:error, Assent.HTTPResponse.t()} | {:error, term()}
Decodes a request response.
Specs
Normalize API user request response into standard claims
Based on https://openid.net/specs/openid-connect-core-1_0.html#rfc.section.5.1
Specs
Recursively prunes map for nil values.
Specs
request(atom(), binary(), binary() | nil, list(), Assent.Config.t()) :: {:ok, Assent.HTTPResponse.t()} | {:error, Assent.HTTPResponse.t()} | {:error, term()}
Makes a HTTP request.
Specs
Signs a JWT
Specs
Generates a URL
Specs
Verifies a JWT