View Source Rivet.Auth.Token.Access (rivet_ident v3.0.2)

Summary

Functions

Generate an auth JWT to our specification

Functions

Link to this function

jwt(factor, hostname, exp \\ 0)

View Source
@spec jwt(
  target :: Rivet.Ident.Factor.t(),
  hostname :: String.t(),
  testing_only_expiration_offset :: nil | integer()
) :: {:ok, token :: String.t(), claims :: map()}

Generate an auth JWT to our specification

iex> alias Rivet.Ident.Factor iex> {:ok, token, claims} = jwt(%Factor{id: "AB", details: %{type: "acc"}}, "example.com", 5*60) iex> claims.aud "caa1:acc:example.com" iex> claims.sub "cas1:AB" iex> String.slice(token, 0..1) "ey"

iex> {:ok, token, claims} = jwt("narf", "example.com", 5*60) iex> claims.aud "caa1:acc:example.com" iex> claims.sub "cas1:narf" iex> String.slice(token, 0..1) "ey"

iex> {:ok, "ey" <> _rest, %{sub: "cas1:userid"}} = jwt("userid", "hostname")