[cgiapp] authentication and authorization callbacks

B. Estrade estrabd at gmail.com
Wed Nov 7 16:11:44 EST 2012


On Tue, Nov 06, 2012 at 09:37:21PM -0500, Mark Stosberg wrote:
> >> Brett, I think this existing functionality would provide what you want:
> >>
> >>   PSGI::Application->new_hook('authorization');
> >>   PSGI::Application->add_callback('authorization', \&callback);
> >
> > Kind of, but what it doesn't allow me to do is affect the order in
> > which the lifecycle hooks are executed.  I think that I would also
> > have to make a ->call_hook('authorization'), when what I really want
> > to do is not only create the 'authorization' hook, but add it as a
> > bona-fide lifecycle event like 'init', 'prerun', etc and choose at
> > what point after 'init' is executed.
> 
> I see the difference. You still want the ability to decide where within
> "run" the hook point is fired from.
> 
> > So, maybe something like this:
> >
> >   PSGI::Application->new_hook('authorization','before','prerun');
> >   PSGI::Application->add_callback('authorization', \&callback);
> 
> Then you need one more piece:
> 
>    before 'prerun' => sub {
>        my ($self, at args) = @_;
>        $self->call_hook('authorization', @args);
>    }
> 
> "before" is a method modifier provided by Moose and Mouse. Since
> PSGI::Application uses Any::Moose, it will always be available for use.
> 
> The pieces can be wrapped up in an Authorization plugin for those who
> want to use it.
> 
> Once that's done, there's no more calling "call_hook()" explicitly, just
> use the authorization plugin.

A win for the MOP it seems :)...and a nice feeling idiom to boot.
Thank you,

Brett

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

-- 


More information about the cgiapp mailing list