Openmaize v0.11.0 Openmaize.Config

This module provides an abstraction layer for configuration.

The following are valid configuration items.

nametypedefault
user_modelmoduleN/A
repomoduleN/A
unique_idstring“name”
crypto_modatom:bcrypt
token_algatom:sha512
keyrotate_daysint28
redirect_pagesmap%{“admin” => “/admin”, nil => “/“, “login” => “/login”}

The values for user_model and repo should be module names. If, for example, your app is called Coolapp and your user model is called User, then user_model should be Coolapp.User and repo should be Coolapp.Repo.

Examples

The simplest way to change the default values would be to add the following to the config.exs file in your project.

config :openmaize,
  user_model: Coolapp.User,
  repo: Coolapp.Repo,
  unique_id: "email",
  crypto_mod: :pbkdf2,
  token_alg: :sha256,
  keyrotate_days: 7,
  redirect_pages: %{"admin" => "/admin", "user" => "/users", nil => "/"},

Summary

Functions

The password hashing and checking algorithm. You can choose between bcrypt and pbkdf2_sha512. Bcrypt is the default

The algorithm used to sign the token

The number of days after which the keys will be rotated

The pages users should be redirected to after logging in. This is a map where the key is the role of the user and the value is the page to be redirected to

The repo name

The unique identifier for the user model

The user model name

Functions

get_crypto_mod()

The password hashing and checking algorithm. You can choose between bcrypt and pbkdf2_sha512. Bcrypt is the default.

For more information about these two algorithms, see the documentation for Comeonin.

get_token_alg()

The algorithm used to sign the token.

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

keyrotate_days()

The number of days after which the keys will be rotated.

redirect_pages()

The pages users should be redirected to after logging in. This is a map where the key is the role of the user and the value is the page to be redirected to.

If there is no role, the user will be redirected to the home page.

repo()

The repo name.

unique_id()

The unique identifier for the user model.

This is the unique identifier in your user model. The default is “name”.

user_model()

The user model name.