Catalyst::Plugin::Authentication::CDBI - CDBI Authentication for Catalyst
use Catalyst 'Authentication::CDBI'; __PACKAGE__->config->{authentication} = { user_class => 'PetStore::Model::CDBI::Customer', user_field => 'email', role_class => 'PetStore::Model::CDBI::Role', user_role_class => 'PetStore::Model::CDBI::CustomerRole', user_role_user_field => 'customer' }; $c->login( $user, $password ); $c->logout; $c->session_login( $user, $password ); $c->session_logout; $c->roles(qw/customer admin/); CREATE TABLE customer ( id INTEGER PRIMARY KEY, email TEXT, password TEXT ); CREATE TABLE role ( id INTEGER PRIMARY KEY, name TEXT ); CREATE TABLE customer_role ( id INTEGER PRIMARY KEY, customer INTEGER REFERENCES customer, role INTEGER REFERENCES role );
This plugin allows you to authenticate your web users using database tables accessed through Class::DBI classes.
Class::DBI
Note that this plugin requires a session plugin such as Catalyst::Plugin::Session::FastMmap.
Catalyst::Plugin::Session::FastMmap
This module is now well past the teatime of it's lifespan, and no new features will be added. For new applications, you probably want to look at Catalyst::Plugin::Authentication and friends instead
This plugin is configured by passing an "authentication" hash reference to your application's config method. The following keys are supported:
the name of the class that represents a user object (no default)
the name of the column holding the user identifier (defaults to "user")
user
the name of the column holding the user's password (defaults to "password")
password
specifies the hashing method for password values; one of: SHA or MD5 (the values are not case-sensitive and the default is empty, i.e. no hashing).
SHA
MD5
the name of the role class
name of the role field
(defaults to "uer")
uer
(defaults to "role")
role
Attempt to authenticate a user. Takes username/password as arguments,
$c->login( $user, $password );
The user remains authenticated until end of request. See session_login for persistent login.
session_login
Log out the user. will not clear the session, so user will still remain logged in at next request unless session_logout is called.
check for permissions. used by the 'roles' function.
Check permissions for roles and return true or false.
$c->roles(qw/foo bar/);
Returns an arrayref containing the verified roles.
my @roles = @{ $c->roles };
Persistently login the user. The user will remain logged in until he clears the session himself, or session_logout is called.
$c->session_login( $user, $password );
Session logout. will delete the user object from the session.
sets $c->request->{user} from session.
sets up $c->config->{authentication}.
Takes an arrayref of roles and checks if user has the supplied roles. Returns 1/0.
Catalyst, Catalyst::Plugin::Session::FastMmap
Sebastian Riedel <sri@cpan.org>, Marcus Ramberg <mramberg@cpan.org>, Andrew Ford <a.ford@ford-mason.co.uk>
This program is free software, you can redistribute it and/or modify it under the same terms as Perl itself.
To install Catalyst::Plugin::Authentication::CDBI, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Catalyst::Plugin::Authentication::CDBI
CPAN shell
perl -MCPAN -e shell install Catalyst::Plugin::Authentication::CDBI
For more information on module installation, please visit the detailed CPAN module installation guide.