Dancer::Plugin::Authorize::Credentials::MySQL - Dancer::Plugin::Authorize authentication via MySQL!
version 1.110720
# in your app code my $auth = auth($login, $password); if ($auth) { # login successful } # use your own encryption (if the user account password is encrypted) my $auth = auth($login, encrypt($password)); if ($auth) { # login successful }
Dancer::Plugin::Authorize::Credentials::MySQL uses your MySQL database connection as the application's user management system.
The authorize method (found in every authentication class) validates a user against the defined datastore using the supplied arguments and configuration file options.
plugins: Database: driver: 'mysql' database: 'test' username: 'root' password: '****' Authorize: credentials: class: MySQL
Sometime you might define multiple connections for the Database plugin, make sure you tell the Authorize plugin about it... e.g.
plugins: Database: foo: driver: 'sqlite' database: 'example1.db' bar: driver: 'mysql' database: 'test' username: 'root' password: '****' Authorize: credentials: class: MySQL options: handle: bar
Please see Dancer::Plugin::Database for a list of all available connection options and arguments.
# users table (feel free to add more columns as you see fit) CREATE TABLE `users` ( `id` int(11) NOT NULL AUTO_INCREMENT, `name` varchar(255) DEFAULT NULL, `login` varchar(255) NOT NULL, `password` mediumtext NOT NULL, `roles` mediumtext, PRIMARY KEY (`id`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 # create an initial adminstrative user (should probably encrypt the password) # Note! this module is not responsible for creating user accounts, it simply # provides a consistant authentication framework INSERT INTO `users` (name, login, password, roles) VALUES ('Administrator', 'admin', '*****', 'guest, user, admin');
Al Newkirk <awncorp@cpan.org>
This software is copyright (c) 2010 by awncorp.
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 Dancer::Plugin::Authorize, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Dancer::Plugin::Authorize
CPAN shell
perl -MCPAN -e shell install Dancer::Plugin::Authorize
For more information on module installation, please visit the detailed CPAN module installation guide.