[cgiapp] CGI::Application::Plugin::Authentication - how to get at
the CGI::Application object instance?
Cees Hek
ceeshek at gmail.com
Fri Mar 6 15:56:47 EST 2009
On Fri, Mar 6, 2009 at 3:30 AM, Terrence Brannon <
tbrannon at insuranceagents.com> wrote:
> Is there any way to access the CGI::Application object from a closure being
> used with the Generic driver?
>
> Because you configure the call to the closure at package-level, it is not
> obvious how to supply it to the closure:
>
> __PACKAGE__->authen->config(
> DRIVER => [ 'Generic', \&check_password ],
> );
>
It looks like I didn't allow for that when I put together the Generic
driver. The method you provide is only given the credentials and not the
authentication object, so you are kind of out of luck with that.
You have a couple of options:
1. Configure the app at run time in a prerun or something like that:
__PACKAGE__->add_callback('prerun', sub {
my $self = shift;
$self->authen->config(
DRIVER => [ 'Generic', sub { check_password($self, @_ ) } ],
);
});
2. Create your own Driver plugin that does things your way. It is actually
easier then you might think. Just copy the Generic driver class and change
the 'verify_credentials' method to suit your needs.
Cheers,
Cees
More information about the cgiapp
mailing list