Forum Moderators: phranque
I would like to setup a customised Perl login page (as a corporate front end) to provide Apache authentication for several virtual hosts.
I have setup the following in /etc/apache2/sites-available/default, but I keep getting a popup login dialog instead of my custom page? Any ideas on what I might be doing wrong?
Many Thanks,
Tom
AddExternalAuth test "/usr/lib/cgi-bin/test.pl"
SetExternalAuthMethod test pipe
<Directory "/var/www/test1">
AllowOverride AuthConfig
AuthType basic
AuthName "Intranet Authentication"
AuthExternal test
require valid-user
AuthUserFile /dev/null
</Directory>
I don't think you can work with http auth if a custom login page is required. you could go for a session based authentication, though.
Say you're setting a PerlTransHandler that checks wether a cookie is provided and wether the session is valid. If so, he does nothing else and let's the usual response handler do it's work.
if the session is not valid or no session has been sent by the client, the handler set's a build_login_form()-sub routine as the PerlResponseHandler / PerlHandler and sets the Response-phase-handler to perl-script, thus overwriting the original response handler that'd jump on the request.
just be cautious _not_ to use CGI.pm with just calling ->new(), because it will read POST-data in your transport handler and you won't get any in the response-phase and wonder why.
practically speaking, this is what typically happens.
- the user agent requests a resource
- from rfc2617:
If a server receives a request for an access-protected object, and an acceptable Authorization header is not sent, the server responds with a "401 Unauthorized" status code, and a WWW-Authenticate header