Phauxth.Config (Phauxth v2.5.1) View Source

This module provides an abstraction layer for configuration.

The following are valid configuration items.

nametypedefault
user_contextmoduleN/A
crypto_modulemoduleN/A
token_modulemoduleN/A
log_levelatom:info
user_messagesmodulePhauxth.UserMessages
drop_user_keyslist of atoms[]

Examples

Add a phauxth entry to the config.exs file in your project, as in the following example:

config :phauxth,
  user_context: MyApp.Users,
  crypto_module: Argon2,
  token_module: MyAppWeb.Auth.Token

Link to this section Summary

Functions

The module used to verify passwords.

The keys that are removed from the user struct before it is passed on to another function.

Generates a random salt for use with token authentication.

The log level for Phauxth logs.

The module used to sign and verify tokens.

The users module to be used when querying the database.

Module to be used to display messages to users.

Link to this section Functions

The module used to verify passwords.

This is used by the Phauxth.Login module.

The keys that are removed from the user struct before it is passed on to another function.

This should be a list of atoms.

By default, :password_hash, :encrypted_password, :password and :otp_secret are removed, and this option allows you to add to this list.

Link to this function

gen_token_salt(length \\ 8)

View Source

Generates a random salt for use with token authentication.

If you are using tokens in your app, and the token implementation uses salts, you can use this function to generate random salts.

The log level for Phauxth logs.

This can be false, :debug, :info, :warn or :error.

The default is :info, which means that :info, :warn and :error logs will be returned.

You can turn off the Phauxth logs by setting this value to false.

The module used to sign and verify tokens.

This module must implement the Phauxth.Token behaviour. See the documentation for Phauxth.Token for more information.

The users module to be used when querying the database.

This module needs to have a get_by(attrs) function defined, which is used to fetch the relevant data.

Module to be used to display messages to users.

The default is Phauxth.UserMessages. See the documentation for Phauxth.UserMessages.Base for details about customizing / translating these messages.