View Source Assent.Strategy behaviour (Assent v0.3.0)
Used for creating strategies.
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
Summary
Functions
Decode a JSON string.
Makes a HTTP request.
Normalize API user request response into standard claims.
Signs a JSON Web Token.
Generates a URL.
Verifies a JSON Web Token.
Callbacks
Functions
Decode a JSON string.
Options
:json_library
- The JSON library to use, seeAssent.json_library/1
Makes a HTTP request.
Normalize API user request response into standard claims.
The function will cast values to adhere to the following types:
%{
"address" => %{
"country" => :binary,
"formatted" => :binary,
"locality" => :binary,
"postal_code" => :binary,
"region" => :binary,
"street_address" => :binary
},
"birthdate" => :binary,
"email" => :binary,
"email_verified" => :boolean,
"family_name" => :binary,
"gender" => :binary,
"given_name" => :binary,
"locale" => :binary,
"middle_name" => :binary,
"name" => :binary,
"nickname" => :binary,
"phone_number" => :binary,
"phone_number_verified" => :boolean,
"picture" => :binary,
"preferred_username" => :binary,
"profile" => :binary,
"sub" => :binary,
"updated_at" => :integer,
"website" => :binary,
"zoneinfo" => :binary
}
Returns an Assent.CastClaimsError
if any of the above types can't be casted.
Based on https://openid.net/specs/openid-connect-core-1_0.html#rfc.section.5.1
Signs a JSON Web Token.
See Assent.JWTAdapter.sign/3
for options.
Generates a URL.
Verifies a JSON Web Token.
See Assent.JWTAdapter.verify/3
for options.