OpenmaizeJWT v1.0.0 OpenmaizeJWT.Config

This module provides an abstraction layer for configuration.

The following are valid configuration items.

nametypedefault
signing_keystringN/A
token_algatom:sha512
token_validityint120 (minutes)
token_datalist%{}

signing_key must be set before using OpenmaizeJWT.

Examples

The simplest way to change the default values would be to add an openmaize_jwt entry to the config.exs file in your project, like the following example.

config :openmaize_jwt,
  signing_key: "some random string"
  token_alg: :sha256,
  token_validity: 60,
  token_data: %{iss: "www.example.com"},

Summary

Functions

The algorithm used to sign the token

The key used to sign the JSON Web Token

Additional information to be added to the token

The length of time after which a JSON Web Token expires

Functions

get_token_alg()

The algorithm used to sign the token.

The default value is :sha512, and :sha256 is also supported.

signing_key()

The key used to sign the JSON Web Token.

This can be generated by the OpenmaizeJWT.Tools.gen_key/1 function.

token_data()

Additional information to be added to the token.

This is a map with atoms as keys. The default is an empty map.

Warning

Do not include any sensitive data in the JSON Web Token.

token_validity()

The length of time after which a JSON Web Token expires.

The default length of time is 120 minutes (2 hours).