Rivet.Auth.Token.Access (rivet_ident v3.5.1)
View SourceSummary
Functions
Generate an auth JWT to our specification
Functions
@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")