[cgiapp] Multiple Authentications?
Jerry Kaidor
jerry at tr2.com
Wed Jun 16 17:10:24 EDT 2010
Hi Nicholas,
>
> Jerry,
> I think the way to make your code future version safe would be as follows:
*** OK, I'm working on it.
> 1.) Derive a driver class from
> CGI::Application::Plugin::Authentication::Driver::DBI
*** I created a file inside the same directory as DBI called MULTI_DBI.pm.
At the top it says:
--- snip ----
package CGI::Application::Plugin::Authentication::Driver::MULTI_DBI;
use strict;
use warnings;
use base qw(CGI::Application::Plugin::Authentication::Driver::DBI);
--- endsnip ---
> 2.) You will need to add an extra config parameter to represent the
> label of the driver.
---- snip ----
=head1 SYNOPSIS
use base qw(CGI::Application);
use CGI::Application::Plugin::Authentication;
__PACKAGE__->authen->config(
DRIVER => [ 'MULTI_DBI',
DBHS => [
'DBH_JOE' => $self->global_dbh,
'DBH_BOB' => $self->dbh1,
'DBH_BILL' => $self->dbh2,
#( etc for all DBHs )
]
TABLE => 'user',
CONSTRAINTS => {
'user.name' => '__CREDENTIAL_1__',
'MD5:user.password' => '__CREDENTIAL_2__'
},
],
);
---- endsnip ----
> 3.) Override the "verify_credentials" method obviously letting
> SUPER::verify_credentials do its stuff .
*** I iterate through my anonymous hash of names and dbh's. For each
one, I stuff the dbh into %options{ DBH } and call
__SUPER__->verify_credentials.
> You need to capture the output of the SUPER call. On failure just pass
> back failure. On success stash the driver label
> using perhaps CGI::Application::param or perhaps
> CGI::Application::Plugin::MessageStack .
*** How about I just stuff the matched label back into the options hash?
It's accessible from both the driver and the application. And it wouldn't
affect your code at all.
- Jerry Kaidor
More information about the cgiapp
mailing list