I tend to prefer using a library or module to handle CGI logic like this
and then drop out to the main script if the logon has been successful. The
important thing is to make sure that the workflow is separated into a
separate module. In mod_perl, you may have the option of having a mod_perl
handler put up a CGI page or redirect (internally not externally) to a CGI
script if the auth succeeded-- but I am not sure.

I tend to code my stuff for the general public on CGI first even if I have
mod_perl in mind.

Originally in Perl 4 style, I wrote a CGI based authentication library 4
years ago which provides a concrete example of how to do this... it is
loosely documented at

http://www.extropia.com/books/instant_web_scripts/chap09.html from the
Instant Web Scripts book 3 years ago.

The quality of conversion from word document to HTML is pretty poor
because we had some problems with IDG providing us the final PDFs. :(

For a Perl 5 example of doing the same thing (and it is mod_perl
compatible as well as tested with PerlEx) can be found at
http://www.extropia.com/ExtropiaObjects/. Rather than one monolithic Perl
4 library, we decided to break auth loosely into three tiers (AuthManager,
Auth, and Auth::Cache). The relevant plug in library you may wish to look
at is

Extropia::AuthManager::CGI. This is a CGI forms based way of logging on
and registering. It plugs in relatively transparently into CGI scripts and
may be replaced with Extropia::AuthManager::RemoteUser,
Extropia::AuthManager::None, or even Extropia::AuthManager::Certificate
(Client side SSL digital certs) seamlessly depending on what sort of
authentication your application ends up growing into.

Warning: I have not finished writing documentation for this new set of
modules. However, I written about the workflow and design parts in great
detail and would be willing to email you this privately if you like. I
will make the documentation for this public in another week or so.

However, these are real libraries that are working in real situations. So
you could use them if you wanted to.

Later,
   Gunther

B&T wrote:

> I've generally created a cgi script per page.  Is that a mistake?
> (I embed the perl in my html so I can edit pages with an html editor)
>
> I need a better technique for invoking traversals to other pages.
> Right now all I can do is a redirect (internal or external).
> How do you organize things so that from within a script you can either
> display the associated page or invoke any other page/script instead?
>
>     - just do redirects?
>     - put all page generation in subroutines in one big .pm?
>     - something else (I hope)?
>
> Example:  My main "home" page has links to "login" and "register"
> scripts/pages, both of which eventually lead to a "user" page.
> With no parameters the login script displays an empty login form.
> Called with get/post parameters it processes the form data;
> on failure it redisplays the login form with a warning,
> on success it should take you to the "user" page (my problem).
> How would YOU organize this?
>
> There are lots of tutorials on the net, but I haven't seen anything
> about organization between multiple pages.
>
> (sorry, this is a clarified repost)

Reply via email to