in reply to Structuring multiple CGI::Application modules

The cgiapp_prerun() method is the natural place to do authentication (teardown is for cleanup e.g. closing database connections).
The following is from CGI::Application's documentation (see prerun_mode()):
# In WebApp.pm: package WebApp; use base 'CGI::Application'; sub cgiapp_prerun { my $self = shift; # Get the web user name, if any my $q = $self->query(); my $user = $q->remote_user(); # Redirect to login, if necessary unless ($user) { $self->prerun_mode('login'); } }
Once you've done something like the above in your MyAuth module, your other modules can subclass MyAuth to reuse the authentication code.
Some useful nodes: Re: Re: Re: Why CGI::Application?, Re: Breaking up Large Modules..

Replies are listed 'Best First'.
Re^2: Structuring multiple CGI::Application modules
by valdez (Monsignor) on Jun 25, 2004 at 21:57 UTC

    Your example is wrong: if you are going to use remote_user information from CGI.pm, then you will never reach that prerun mode without a valid user and the code unless ($user) ... is useless.

    Ciao, Valerio