Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

CGI Application Authentication using multiple drivers

by Prat824 (Acolyte)
on Jun 25, 2010 at 16:02 UTC ( [id://846548]=perlquestion: print w/replies, xml ) Need Help??

Prat824 has asked for the wisdom of the Perl Monks concerning the following question:

Hi
I have been trying to authenticate my CGI application through 2 drivers, one that uses username/password stored in the database and other using ldap active directory.

following is the code

$self->authen->config( DRIVER => [ 'DBI', DBH => $self->dbh, TABLE => 'user', CONSTRAINTS => { 'user.username' => '__CREDENTIAL_1__', 'MD5:user.password' => '__CREDENTIAL_2__' }, ], DRIVER => [ 'Authen::Simple::LDAP', host => 'ldapad.company.com', basedn => 'OU=XXX,OU=XX,DC=XXX,DC=XXX', binddn => 'CN=usename,OU=Users,OU=XXX,OU=AD,DC=XXX,DC=xxx', bindpw => 'secret', filter => '(cn=%s)', ], CREDENTIALS => [ 'authen_username', 'authen_password' ], STORE => 'Session', LOGOUT_RUNMODE => 'logout', LOGIN_RUNMODE => 'login', POST_LOGIN_RUNMODE => 'okay', RENDER_LOGIN => \&my_login_form, );

How do I make the application check the other driver if not authenticated with one.
Right now, as expected, its the driver listed at the bottom that works and they both do, depending on which was assigned last.

Replies are listed 'Best First'.
Re: CGI Application Authentication using multiple drivers
by Corion (Patriarch) on Jun 25, 2010 at 17:31 UTC

    If I assume that you're talking about CGI::Application::Plugin::Authentication, it does not seem to support multiple drivers. So you'll have to write your own "multi" driver that tries all drivers until it finds one that accepts.

      This is where I got the idea that I could do it
      http://search.cpan.org/~silasmonk/CGI-Application-Plugin-Authentication-0.18/lib/CGI/Application/Plugin/Authentication.pm#config

      "You can provide multiple drivers which will be used, in order, to check the credentials until a valid response is received."

        Ah - I hadn't seen that. Why are you doing it differently than the documentation suggests?

Re: CGI Application Authentication using multiple drivers
by Herkum (Parson) on Jun 26, 2010 at 00:49 UTC

    I tried to use this module, and I had never encountered a plug-in that was so finicky and hard to work with. I would get it to work, and then it would break, I would get to work, without understand what I fixed and then it would break... I finally just gave up and stripped it out and use something homegrown, but simple. The one thing I can say is, it didn't break anymore.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://846548]
Front-paged by Arunbear
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others having a coffee break in the Monastery: (3)
As of 2024-04-26 00:07 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found