[Svn] r2308 - in branches/devel-api/plugins: . http_authentication

trac at roundcube.net trac at roundcube.net
Sun Feb 22 18:04:12 CET 2009


Author: thomasb
Date: 2009-02-22 11:04:12 -0600 (Sun, 22 Feb 2009)
New Revision: 2308

Added:
   branches/devel-api/plugins/http_authentication/
   branches/devel-api/plugins/http_authentication/http_authentication.php
Log:
Add plugin that re-uses http authentication for logins

Added: branches/devel-api/plugins/http_authentication/http_authentication.php
===================================================================
--- branches/devel-api/plugins/http_authentication/http_authentication.php	                        (rev 0)
+++ branches/devel-api/plugins/http_authentication/http_authentication.php	2009-02-22 17:04:12 UTC (rev 2308)
@@ -0,0 +1,41 @@
+<?php
+
+/**
+ * HTTP Basic Authentication
+ *
+ * Make use of an existing HTTP authentication and perform login with the existing user credentials
+ *
+ * @version 1.0
+ * @author Thomas Bruederli
+ */
+class http_authentication extends rcube_plugin
+{
+
+  function init()
+  {
+    $this->add_hook('startup', array($this, 'startup'));
+    $this->add_hook('authenticate', array($this, 'authenticate'));
+  }
+
+  function startup($args)
+  {
+    // change action to login
+    if ($args['task'] == 'mail' && empty($args['action']) && empty($_SESSION['user_id'])
+        && !empty($_SERVER['PHP_AUTH_USER']) && !empty($_SERVER['PHP_AUTH_PW']))
+      $args['action'] = 'login';
+
+    return $args;
+  }
+
+  function authenticate($args)
+  {
+    if (!empty($_SERVER['PHP_AUTH_USER']) && !empty($_SERVER['PHP_AUTH_PW'])) {
+      $args['user'] = $_SERVER['PHP_AUTH_USER'];
+      $args['pass'] = $_SERVER['PHP_AUTH_PW'];
+    }
+  
+    return $args;
+  }
+
+}
+

_______________________________________________
http://lists.roundcube.net/mailman/listinfo/svn



More information about the Svn mailing list