Joken Signer Config v0.1.0 Joken.Signer.Config View Source

Joken Signer Config is used to derive an appropriate %Joken.Signer from a jwt token based on the criteria of one or many %Joken.Signer.Configs within a list

How it works

Given a list of %Joken.Signer.Configs that look like this

[
  %Joken.Signer.Config{
    claims: %{ iss: "some_issuer" }
    headers: %{ alg: hs256 },
    signer: &Joken.h256/1
  },
  #...more Signer Configs
]

and a jwt token with contents like this

Link to this section Summary

Functions

Combines &peek/1 and &peek_header/1 to give a map that includes both headers and claims from the token

Link to this section Types

Link to this type claims() View Source
claims() :: %{}
Link to this type headers() View Source
headers() :: %{}
Link to this type t() View Source
t() :: %Joken.Signer.Config{
  claims: claims(),
  headers: headers(),
  signer: (... -> Joken.Signer.t())
}

Link to this section Functions

Link to this function find_config_by(config, jwt) View Source
Link to this function get_value(value1, value2) View Source
Link to this function peek_headers_and_claims(raw_jwt) View Source
peek_headers_and_claims(binary()) :: map()
peek_headers_and_claims(token()) :: map()

Combines &peek/1 and &peek_header/1 to give a map that includes both headers and claims from the token

Examples

iex> my_token = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJuYW1lIjoiSm9obiBEb2UifQ.DjwRE2jZhren2Wt37t5hlVru6Myq4AhpGLiiefF69u8"
iex> import Joken.Signer.Config
iex> peek_headers_and_claims(my_token)
%{
  claims: %{"name" => "John Doe"},
  headers: %{"alg" => "HS256", "typ" => "JWT"}
}