[cgiapp] Q: Authz, but only when user is Authenticated...

Graham TerMarsch cgi-application at howlingfrog.com
Mon Mar 17 17:14:42 EDT 2008


On Monday 17 March 2008 1:25 pm, Lee Carmichael wrote:
> I just ran into this same problem last week. I was just crafting an email
> about it but found it hard to explain. You did a great job :)
[.....snip.....]

> Overall, I think CA should handle this a bit better, but I'm not sure how
> since that call_hook code is really well separated and has a clean design.
> It seems wrong to 'mess' it up for this one case.
>
> Maybe it would be good to have the callback throw an exception that would
> tell CA to stop processing other callbacks? But I could envision situations
> where the app may want other callbacks to still be called anyway like mine
> above :) Today the callback code will just die if it sees an exception.
> Maybe 'prerun_mode' could only be set once inside the prerun callbacks,
> first one to set it gets it.

Oooh, now THAT'S an idea...

If "prerun_mode()" gets called multiple times, only the -FIRST- guy to set it 
gets to actually change the value.

Would probably be a simple change to make too, but at the same time I'm pretty 
sure that it'd break someones existing code.

That said, what if we allow this behaviour to be controlled via some sort of 
option, which could be set either via a parameter when calling "new()" or 
during initial app setup (e.g. before "prerun").  Default would be to stick 
with the existing behaviour, but by setting some sort of "prerun_first_only" 
flag/thingy we could force "prerun_mode()" to only keep the first value.

Seemed quick enough to do, so for fun I've whipped up the following UNTESTED 
patch to CGI::Application to add a new "prerun_mode_first_only()" method.

I haven't tested this patch at all, bit it might be suitable for discussion 
purposes; it keeps the existing CGI::App behaviour but adds a new option to 
help control it for those times when we want to do it backwards.

-- 
Graham TerMarsch
Howling Frog Internet Development, Inc.


More information about the cgiapp mailing list