class IMP_Hooks
{
/**
+ * AUTHENTICATION HOOK: pre-authentication actions.
+ *
+ * See horde/config/hooks.php.dist for more information.
+ *
+ * IMP uses the following credentials:
+ * 'password' - (string) The password for mail server authentication.
+ * 'server' - (string) [optional] Use this server key (see
+ * config/servers.php).
+ * 'transparent' - (boolean) If $credentials['authMethod'] is
+ * 'transparent', and you would like IMP to use
+ * the userId/credentials generated in the
+ * preauthentication hook, this must be true. If false,
+ * IMP will try to authenticate using hordeauth.
+ */
+// function preauthenticate($userId, $credentials)
+// {
+// return true;
+// }
+
+
+ /**
+ * AUTHENTICATION HOOK: post-authentication actions.
+ *
+ * See horde/config/hooks.php.dist for more information.
+ */
+ function postauthenticate($userId, $credentials)
+// {
+// return true;
+// }
+
+
+ /**
* PREFERENCE HOOK: Dynamically set the signature preference.
*
* @param string $username The username.
/**
* Perform transparent authentication.
*
+ * @param Horde_Auth_Application $auth_ob The authentication object.
+ *
* @return boolean Whether transparent login is supported.
* @throws Horde_Auth_Exception
*/
- static public function transparent()
+ static public function transparent($auth_ob)
{
+ /* It is possible that preauthenticate() set the credentials.
+ * If so, use that information instead of hordeauth. */
+ if ($auth_ob->getCredential('transparent')) {
+ $credentials = $auth_ob->getCredential();
+ if (!isset($credentials['server'])) {
+ $credentials['server'] = self::getAutoLoginServer();
+ }
+ self::_createSession($auth_ob->getCredential());
+ return true;
+ }
+
+ /* Attempt hordeauth authentication. */
$credentials = self::_canAutoLogin();
if ($credentials === false) {
return false;