Auctoritas v0.9.1 Auctoritas.Config View Source

Link to this section Summary

Functions

Create new config for Auctoritas

Link to this section Types

Link to this type

t() View Source
t() :: %Auctoritas.Config{
  data_storage: module(),
  expiration: expiration(),
  name: String.t(),
  refresh_token_expiration: expiration(),
  token_manager: module(),
  token_type: :static | :sliding | :refresh_token
}

Link to this section Functions

Link to this function

new(options \\ []) View Source
new([]) :: %Auctoritas.Config{
  data_storage: term(),
  expiration: term(),
  name: term(),
  refresh_token_expiration: term(),
  token_manager: term(),
  token_type: term()
}

Create new config for Auctoritas

Arguments:

  • secret_key: Secret key to use when generating authentication tokens.
  • data_storage: Data storage module to save data and manage authentication tokens. (DEFAULT value exists)
  • token_manager: Token manager module to generate and read tokens. (DEFAULT value exists)

Examples

iex> Auctoritas.Config.new()
%Auctoritas.Config{
  name: "auctoritas_default",
  data_storage: Auctoritas.AuthenticationManager.CachexDataStorage,
  token_manager: Auctoritas.AuthenticationManager.DefaultTokenManager,
  token_type: :sliding,
  expiration: 60 * 60 * 24, # 1 day
  refresh_token_expiration: 60 * 60 * 24 * 3 # 3 days
}

iex> Auctoritas.Config.new(name: "custom_name")
%Auctoritas.Config{
  name: "custom_name",
  data_storage: Auctoritas.AuthenticationManager.CachexDataStorage,
  token_manager: Auctoritas.AuthenticationManager.DefaultTokenManager,
  token_type: :sliding,
  expiration: 60 * 60 * 24, # 1 day
  refresh_token_expiration: 60 * 60 * 24 * 3 # 3 days
}
Link to this function

read() View Source
read() :: %Auctoritas.Config{
  data_storage: term(),
  expiration: term(),
  name: term(),
  refresh_token_expiration: term(),
  token_manager: term(),
  token_type: term()
}