Catalyst::Authentication::Store::Proxy - Delegates authentication logic to the user object
version 0.0.1
package MyApp::User; use Moose; extends 'Catalyst::Authentication::User'; sub from_session { my ($self, $c, $id) = @_; } sub for_session { my ($self, $c) = @_; } sub find_user { my ($self, $authinfo, $c) = @_; } ... MyApp->config( 'Plugin::Authentication' => { default => { credential => { class => 'Password', password_type => 'none', }, store => { class => 'Proxy' } } } );
This module makes it much easier to implement a custom authenication store. It delegates all the necessary method for user retrieval and session storage to a custom user class.
Methods are delegated to this user class. It defaults to MyApp::User, where MyApp is the name of you application. The follwing methods have to be implemented in that class additionally to those mentioned in Catalyst::Authentication::User:
MyApp::User
MyApp
find_user ($c, $authinfo)
The second argument $authinfo is whatever was passed to $c->authenticate. If the user can be authenticated using $authinfo it has to return a new object of type MyApp::User or undef.
$authinfo
$c->authenticate
undef
from_session ($c, $id)
Given a session id, this method returns an instance of the matching MyApp::User.
id
for_session ($c)
This has to return a unique identifier of the user object which will be used as second parameter to "from_session".
MyApp->config( 'Plugin::Authentication' => { default => { credential => { ... }, store => { class => 'Proxy', handles => { find_user => 'find', }, } } } );
Change the name of the authentication methods to something else.
Moritz Onken
This software is Copyright (c) 2011 by Moritz Onken.
This is free software, licensed under:
The (three-clause) BSD License
To install Catalyst::Authentication::Store::Proxy, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Catalyst::Authentication::Store::Proxy
CPAN shell
perl -MCPAN -e shell install Catalyst::Authentication::Store::Proxy
For more information on module installation, please visit the detailed CPAN module installation guide.