PlugAuth::Plugin::DBIAuth - DBI Authentication back end for PlugAuth
version 0.03
In your PlugAuth.conf file:
--- plugins: - PlugAuth::Plugin::DBIAuth: db: dsn: 'dbi:SQLite:dbname=/path/to/dbfile.sqlite' user: '' pass: '' sql: init: 'CREATE TABLE IF NOT EXISTS users (username VARCHAR UNIQUE, password VARCHAR)' check_credentials: 'SELECT password FROM users WHERE username = ?' all_users: 'SELECT username FROM users'
This plugin provides an authentication mechanism for PlugAuth using any database supported by DBI as a backend. It is configured as above, with two hashes, db and sql.
Specifies the encryption method to use. This is only used when creating new users, or changing their passwords. Existing passwords will remain in their existing formats and will be decrypted automatically in the correct format.
If provided, must be one of:
unix
Traditional UNIX crypt()
unix_md5
UNIX MD5
apache_md5 [ default ]
Apache MD5
The db hash provides the required parameters for the plugin needed to connect to the database.
The DNS passed into DBI. See the documentation for your database driver for the exact format (DBD::SQLite, DBD::Pg, DBD::mysql ... ).
The database user.
The database password.
The sql hash provides SQL statements which are executed for each operation. They are all optional. The examples shown here assumes a simple table with usernames and passwords:
CREATE TABLE IF NOT EXISTS users ( username VARCHAR UNIQUE, password VARCHAR );
Arbitrary SQL executed when the plugin is started.
The SQL statement used to fetch the encrypted password of a user. The username is the first bind value when executed. Example:
SELECT password FROM users WHERE username = ?
The SQL statement used to fetch the list of users. Example:
SELECT username FROM users
The SQL statement used to create a new user. Example:
INSERT INTO users (username, password) VALUES (?,?)
The SQL statement used to change the password of an existing user. Example:
UPDATE users SET password = ? WHERE username = ?
The SQL statement used to delete an existing user. Example:
DELETE FROM users WHERE username = ?
Returns the dbh handle used to query the database.
Given a new plain text password, return the encrypted version.
DBI, PlugAuth
Graham Ollis <gollis@sesda3.com>
This software is copyright (c) 2012 by NASA GSFC.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
To install PlugAuth::Plugin::DBIAuth, copy and paste the appropriate command in to your terminal.
cpanm
cpanm PlugAuth::Plugin::DBIAuth
CPAN shell
perl -MCPAN -e shell install PlugAuth::Plugin::DBIAuth
For more information on module installation, please visit the detailed CPAN module installation guide.