plug_password v0.3.3 PlugPassword.Block
Plug used to add simple authentication.
Options should be provided with at least passwords field.
Possible options:
:passwords
- list of passwords that should allow users to pass authentication. Example: [“hello”, “world”]:template
- module which implement PlugPassword.Template.Behaviour. Example: MyApp.PlugPassword.Template:path_whitelist
- regex which will be used to check if path is whitelisted. Example: ~r/users/:ip_whitelist
- list of IPs that should be whitelisted. Example: [“127.0.0.1”]:custom_rule
- function which is run withconn
so you can implement custom rules. Example:f(conn) -> conn.port == 80 end
or
&ExampleApplication.Authentication.check_user_agent/1
Example
plug PlugPassword.Block, passwords: ["hello", world],
template: Authentication,
path_whitelist: ~r/users/,
ip_whitelist: ["86.123.112.78"],
custom_rule: &Authentication.custom_rule/1
Link to this section Summary
Link to this section Functions
Link to this function
call(conn, options)
Checks if password is matching.
If password will match or any of additional checks will return true, user will be authenticated. Otherwise it will render form.
Link to this function
init(options)