NAME
Dancer2::Plugin::Auth::YARBAC::Provider::Database - Yet Another Role Based Access Control Framework
VERSION
version 0.007
SYNOPSIS
Configure the plugin to use the Database provider class:
plugins:
Auth::YARBAC:
# Set redirect page after user logs out
after_logout: '/login'
# Set default redirect page after user logs in
after_login: '/'
# Set default redirect page if user fails login attempt
login_denied: '/login'
# Specify URL's that do not require authentication
no_login_required: '^/login|/denied|/css|/images|/generate_hash'
# Set your realms, one realm is required but you can have many
realms:
# Realm name
test:
# Our backend provider
provider: 'Database'
# Set the users table name (required by Database, default: users)
users_table: 'users'
# Set the users id column name (required by Database, default: id)
users_id_column: 'id'
# Set the users username column name (Database, default: username)
users_username_column: 'username'
# Set the users username column name (Database, default: password)
users_password_column: 'password'
# Password strength options optionally allows a check password strength
password_strength:
# Set the required minimum password score
required_score: 25
# Set minimum password length
min_length: 6
# Set maximum password length (good idea to avoid DDOS attacks)
max_length: 32
# If true, password must contain special characters
special_characters: 1
# If true, password must contain control characters
control_characters: 1
# If true, password must not be a repeating character
no_repeating: 1
# If true, password must contain a uppercase character
upper_case: 1
# If true, password must contain a lowercase character
lower_case: 1
# If true, password must contain a number
numbers: 1
Next, setup your database tables.
This backend provider requires that your app is configured to use Dancer2::Plugin::Database. This provider is flexible with the naming convention of your users table. In your apps config settings you can set your users table name with the 'users_table' option but the default expected is 'users'. You can set your user 'id' column name with the 'users_id_column' option but the default expected is 'id'. You can set your user 'username' column name with the 'users_username_column' config option but the default expected is 'username'. You can set your 'password' column name with the 'users_password_column' config option but the default expected is 'password'. However this provider inists on the other table names to be named as displayed in this documentation. All static table names are prefixed with 'yarbac_' in order to stay out of your way.
- SQLITE EXAMPLE SCHEMA
-
CREATE TABLE users ( id INTEGER PRIMARY KEY, username VARCHAR(32) NOT NULL UNIQUE, password TEXT NOT NULL ); CREATE TABLE yarbac_roles ( id INTEGER PRIMARY KEY, role_name VARCHAR(32) NOT NULL UNIQUE, description TEXT NULL ); CREATE TABLE yarbac_groups ( id INTEGER PRIMARY KEY, group_name VARCHAR(32) NOT NULL UNIQUE, description TEXT NULL ); CREATE TABLE yarbac_permissions ( id INTEGER PRIMARY KEY, permission_name VARCHAR(32) NOT NULL UNIQUE, description TEXT NULL ); CREATE TABLE yarbac_user_roles ( user_id INTEGER NOT NULL, role_id INTEGER NOT NULL ); CREATE UNIQUE INDEX user_role on yarbac_user_roles (user_id, role_id); CREATE TABLE yarbac_role_groups ( role_id INTEGER NOT NULL, group_id INTEGER NOT NULL ); CREATE UNIQUE INDEX group_role on yarbac_role_groups (role_id, group_id); CREATE TABLE yarbac_group_permissions ( group_id INTEGER NOT NULL, permission_id INTEGER NOT NULL ); CREATE UNIQUE INDEX group_permissions on yarbac_group_permissions (group_id, permission_id);
- MYSQL EXAMPLE SCHEMA
-
CREATE TABLE users ( id INTEGER AUTO_INCREMENT PRIMARY KEY, username VARCHAR(32) NOT NULL UNIQUE KEY, password TEXT NOT NULL ); CREATE TABLE yarbac_roles ( id INTEGER AUTO_INCREMENT PRIMARY KEY, role_name VARCHAR(32) NOT NULL UNIQUE KEY, description TEXT NULL ); CREATE TABLE yarbac_groups ( id INTEGER AUTO_INCREMENT PRIMARY KEY, group_name VARCHAR(32) NOT NULL UNIQUE KEY, description TEXT NULL ); CREATE TABLE yarbac_permissions ( id INTEGER AUTO_INCREMENT PRIMARY KEY, permission_name VARCHAR(32) NOT NULL UNIQUE KEY, description TEXT NULL ); CREATE TABLE yarbac_user_roles ( user_id INTEGER NOT NULL, role_id INTEGER NOT NULL, UNIQUE KEY user_role (user_id, role_id) ); CREATE TABLE yarbac_role_groups ( role_id INTEGER NOT NULL, group_id INTEGER NOT NULL, UNIQUE KEY group_role (role_id, group_id) ); CREATE TABLE yarbac_group_permissions ( group_id INTEGER NOT NULL, permission_id INTEGER NOT NULL, UNIQUE KEY group_permissions (group_id, permission_id) );
DESCRIPTION
This module is the base provier for the YARBAC framework. See Dancer2::Plugin::Auth::YARBAC for full documentation showing the usage of this backend provider.
AUTHOR
Sarah Fuller <sarah@averna.id.au>
COPYRIGHT AND LICENSE
This software is copyright (c) 2014 by Sarah Fuller.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.