authex v0.1.0 Authex
Link to this section Summary
Functions
Turns a token into a usable resource using a serializer module
Turns a resource into a compact token using a serializer module
Signs an Authex.Token struct, creating a compact token
Creates a new Authex.Token struct from the given claims and options
Verifies a compact token
Link to this section Functions
Link to this function
deserialize(token)
Turns a token into a usable resource using a serializer module.
Parameters
- token: An Authex.Token struct.
Link to this function
serialize(resource)
Turns a resource into a compact token using a serializer module.
Parameters
- resource: Any usable resource.
Link to this function
sign(token, options \\ [])
Signs an Authex.Token struct, creating a compact token.
Parameters
- token: An Authex.Token struct.
- options: A keyword list of options.
Options
:secret- the secret key to sign the token with.:alg- the algorithm to sign the token with.
Link to this function
token(claims \\ [], options \\ [])
Creates a new Authex.Token struct from the given claims and options
Parameters
- claims: A keyword list of JWT claims.
- options: A keyword list of options.
Options
:time- the base time (timestamp format) in which to use.:ttl- the TTL for the token.
Examples
iex> Authex.token([sub: 1, jti: "test"], [time: 1500000000, ttl: 10])
%Authex.Token{
aud: nil, exp: 1500000010, iat: 1500000000, iss: nil,
jti: "test", nbf: 1499999999,
scopes: [], sub: 1}
Link to this function
verify(compact_token, options \\ [])
Verifies a compact token.
Parameters
- token: An Authex.Token struct.
- options: A keyword list of options.
Options
:secret- the secret key to verify the token with.:alg- the algorithm to verify the token with.