It seems that you are asking for the best way to implement access control in CGI::Application paradigm. The first question is what do you want to control, all methods, or just all run modes?
If you want to control all methods, then the conventional way is to implement a proxy. See the following references. This is the proxy pattern for the pattern aficianados.
http://www.perl.com/pub/a/2003/08/15/design3.html?page=2 http://wiki.slowass.net/?ProxyPattern
If you want to control just the run modes, then use cgiapp_prerun(). My understanding is that this is typically where access control for run modes are implemented. That's what I do. I an authorization check method here, and catch any exception. The exception (an instance of Exception::Class) is then saved in $self->param and redirect to a run mode that displays exception messages.
In additon, the author has very wisely passed in the value of the run mode as the argument to cgiapp_prerun, so you get this for free w/o calling get_current_runmode().
Pete ---- Joel Gwynn wrote:
OK. I think I figured out what I really need to know.
I basically want my setup function to be my permissions manager. Inside of setup, I'm looking up the user based on the session id, and storing the user's permissions in a hash. The permissions refer to subroutines, not run-modes. I really want to be able to have a fine-grained control ove which users can run which subs.
How do I find out which subroutine is being requested? ie, if my run-modes are as follows: $self->run_modes( login => \&login, authenticate => \&authenticate, list_projects => \&list_projects, add_project => \&list_projects, edit_project => \&list_projects ... } > I want to find out if my user has permission to run &list_projects. If I know that the run-mode is called 'add_project', how do I determine what sub is going to be called.
Sorry if I'm being too dense about this.
Joel Gwynn Variable Data Spire 617 832-1957
--------------------------------------------------------------------- Web Archive: http://www.mail-archive.com/[EMAIL PROTECTED]/ http://marc.theaimsgroup.com/?l=cgiapp&r=1&w=2 To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
--------------------------------------------------------------------- Web Archive: http://www.mail-archive.com/[EMAIL PROTECTED]/ http://marc.theaimsgroup.com/?l=cgiapp&r=1&w=2 To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
