[dev] Using Preauthenticate Hook to Mangle Username
Brandon W. Uhlman
brandon.uhlman at ssrlibrary.ca
Sun Dec 10 20:20:34 PST 2006
Hi, all.
I'm trying to use the _horde_hook_preauthenticate to rewrite usernames
at login time based on the domain at which they're visiting Horde. To
clarify, an example.
webmail.foo.bar.com and webmail.quux.bar.com both point at the same
Horde/IMP install. User 'bob' visits both addresses, and logs into
both. Bill gets authenticated as foo.bill or quux.bill depending on
which URI I use.
I think that _horde_hook_preauthenticate is the right tool to use.
Currently, I have
function _horde_hook_preauthenticate($userId, $credential, $realm)
{
if($_SERVER['HTTP_HOST'] == "webmail.foo.bar.com")
$userId = "foo." . $userId;
else
$userId = "quux." . $userId;
$_SESSION['imp']['user'] = $userId;
// $_SESSION['imp']['uniquser'] = $userId;
return true;
}
in the hooks.php file, and I have $conf['hooks']['preauthenticate']
(or whatever it's actually called) set to true in
~/horde/config/conf.php. I am able to authenticate successfully now,
but Horde doesn't bother using the prefix for other things, like
loading prefs from horde_prefs.
I think this is because it's trying to use
$_SESSION['imp']['uniquser'] to access the prefs container, and
uniquser doesn't get rewritten. If I try to rewrite uniquser in the
hook, I get thrown into an infinite loop where it loads an infinite
number of Horde menu bars along the left hand side of my screen.
Is my code in _preauthenticate buggy, or am I missing a piece of the
puzzle here? Should I clean up uniquser using postauthenticate maybe?
If I can get this working using just preauthenticate, maybe it should
be included in hooks.php.dist, because the only example for
preauthenticate right now is a pretty trivial one that doesn't
actually use any variables or show how to set them.
I'm using Horde 3.1.3 and Imp 4.1.3.
Thanks,
Brandon
Brandon W. Uhlman
Burnaby, BC
E-mail: brandon at branflakes.net
More information about the dev
mailing list