Openmaize v0.10.2 Openmaize.Config
This module provides an abstraction layer for configuration. The following are valid configuration items.
name | type | default |
---|---|---|
user_model | module | N/A |
repo | module | N/A |
unique_id | string | “name” |
crypto_mod | atom | :bcrypt |
token_alg | atom | :sha512 |
keyrotate_days | int | 28 |
login_dir | string | “/admin” |
redirect_pages | map | %{“admin” => “/admin”, nil => “/“} |
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,
login_dir: "admin",
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 login directory. For example, the default value of “/admin” means that the login page is “/admin/login”
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
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.
The algorithm used to sign the token.
The default value is :sha512, and :sha256 is also supported.
The login directory. For example, the default value of “/admin” means that the login page is “/admin/login”.
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.
The unique identifier for the user model.
This is the unique identifier in your user model. The default is “name”.