WAS: A better way to handle multiple client authentication? AND ALSO:Dynamically setting PerlVars in
am 03.12.2009 13:12:46 von Tosh CooeySorry for the long subject but I solved the questions I posted about and
thought I would share my $solution.
The initial problem was:
Right now I have an application set up for multiple clients: clientA,
clientB, clientC.
Each client has their own users.
The way I have it setup is clientA goes to http://www.site.com/clientA
and is presented with a login screen which is triggered by an .htaccess
file in a directory called /clientA. The .htaccess file directs Apache
to perform DBI-based authentication using Apache2::AuthCookieDBI.
PerlSetVar AuthDBI_DSN DBI:mysql:clientA
This works great, but I am aware of the limitations and I would like to
set up some rules in the Apache config that accomplish this all without
..htaccess files in every directory for every client (gonna get tricky
around 100,000 clients for sure!)
William T. had an interesting suggestion to use the 'pwd_whereclause'
but that wasn't exactly what I needed. So my first go at it resulted in
my second question, about setting PerlSetVar on the fly, per-request and
do authentication that way.
Adam Prime (a Great Canadian) replied with a big hint that lead to my
solution, he suggested just subclassing Apache2::AuthCookieDBI
And voila! So in case anyone else ever needs to do this hopefully they
can save some time, here is my $solution;
myAUTH.pm:
package myAUTH;
use base qw(Apache2::AuthCookieDBI);
#$CONFIG_DEFAULT is initialized in the parent (use base ...)
$CONFIG_DEFAULT{myAuthDBI_DSN} = "DBI:mysql:database=&client";
sub client {
... do stuff to determine your client ID...
}
1;
Anything else you need to change WRT the DBI can be done with the
$CONFIG_DEFAULT variable. Use your new myAUTH module in the "AuthType
myAUTH" section. If you want to get more fancy you can explore into
dir_config.
Anyway, I hope that helps somebody.
Tosh
--
McIntosh Cooey - Twelve Hundred Group LLC - http://www.1200group.com/