[Catalyst] Login as another user ...

Rodrigo rodrigolive at gmail.com
Wed Jan 27 10:43:22 GMT 2010

> > >
> > >What's the best way to achieve this? I tried $c->authenticate without a
> > >password, but this doesn't seem to work.
> > >
> > >--
> >

I use 2 different authentication realms, "ldap" (normal login) and "none"
(single-signon, surrogate) and my login controller decides which one to use,
so that root can surrogate as some other user.

if( $single_signon_user || $surrogate_ok ) {
    $c->authenticate({ id=3D>$id }, 'none');
} else {  # normal signon
     $c->authenticate({ id=3D>$id, password=3D>$password }, 'ldap');

And I havethe follwoing in myapp.conf:
default_realm ldap
                class password
                password_field password
                password_type none
                class null
              . . .
     . . .

The bad part is that you can't rely on $c->user for your user data. The user
object will have different data/methods depending on the realm used. So I
use a MyAppUser class that abstracts that, providing the user data
independent from the realm used.

You can also inherit from the Authentication classes and do your own thing
in there, such as ignore the need for a password. But I found the realm
strategy easy and independent. Besides I often use 4 or 5 auth different
realms simultaneously...

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.scsys.co.uk/pipermail/catalyst/attachments/20100127/1cbcd=

More information about the Catalyst mailing list