On Fri, Mar 6, 2009 at 3:30 AM, Terrence Brannon <
[email protected]> 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

#####  CGI::Application community mailing list  ################
##                                                            ##
##  To unsubscribe, or change your message delivery options,  ##
##  visit:  http://www.erlbaum.net/mailman/listinfo/cgiapp    ##
##                                                            ##
##  Web archive:   http://www.erlbaum.net/pipermail/cgiapp/   ##
##  Wiki:          http://cgiapp.erlbaum.net/                 ##
##                                                            ##
################################################################

Reply via email to