Revision: 1113
http://mrbs.svn.sourceforge.net/mrbs/?rev=1113&view=rev
Author: jberanek
Date: 2009-05-22 13:56:29 +0000 (Fri, 22 May 2009)
Log Message:
-----------
* Added a new authentication method, auth_smtp.inc. Utilises the
Net_SMTP Pear package.
Modified Paths:
--------------
mrbs/trunk/web/config.inc.php
Added Paths:
-----------
mrbs/trunk/web/auth_smtp.inc
Added: mrbs/trunk/web/auth_smtp.inc
===================================================================
--- mrbs/trunk/web/auth_smtp.inc (rev 0)
+++ mrbs/trunk/web/auth_smtp.inc 2009-05-22 13:56:29 UTC (rev 1113)
@@ -0,0 +1,104 @@
+<?php
+
+/* $Id$
+ *
+ * Authentication scheme that uses SMTP as the source for user
+ * authentication. Requires the Net_SMTP Pear package
+ *
+ * To use this authentication scheme set the following
+ * things in config.inc.php:
+ *
+ * $auth["realm"] = "MRBS"; // Or any other string
+ * $auth["type"] = "smtp";
+ * $auth['smtp']['server'] = 'myserver.example.org'; // Your SMTP server
+ *
+ * Then, you may configure admin users:
+ *
+ * $auth["admin"][] = "smtpuser1";
+ * $auth["admin"][] = "smtpuser2";
+ */
+
+/* ~~JFL 2003/11/12 By default, use the http session mechanism */
+if (!isset($auth['session']))
+{
+ $auth['session']='http';
+}
+
+/* authValidateUser($user, $pass)
+ *
+ * Checks if the specified username/password pair are valid
+ *
+ * $user - The user name
+ * $pass - The password
+ *
+ * Returns:
+ * 0 - The pair are invalid or do not exist
+ * non-zero - The pair are valid
+ */
+function authValidateUser($user, $pass)
+{
+ global $auth;
+
+ // Check if we do not have a username/password
+ if (!isset($user) || !isset($pass) || strlen($pass)==0)
+ {
+ return 0;
+ }
+
+ $ret = 0;
+
+ require 'Net/SMTP.php';
+
+ $smtp = new Net_SMTP($auth['smtp']['server']);
+
+ if ($smtp)
+ {
+ $e = $smtp->connect();
+ if (!PEAR::isError($e))
+ {
+ if (!PEAR::isError($smtp->auth($user, $pass)))
+ {
+ $ret = 1;
+ }
+
+ $smtp->disconnect();
+ }
+ }
+
+ // return status
+ return $ret;
+}
+
+/* authGetUserLevel($user)
+ *
+ * Determines the users access level
+ *
+ * $user - The user name
+ *
+ * Returns:
+ * The users access level
+ */
+function authGetUserLevel($user)
+{
+ global $auth;
+ $admins = $auth['admin'];
+ // User not logged in, user level '0'
+ if (!isset($user))
+ {
+ return 0;
+ }
+
+ // Check if the user is can modify
+ for ($i = 0; $admins[$i]; $i++)
+ {
+ if(strcasecmp($user, $admins[$i]) == 0)
+ {
+ return 2;
+ }
+ }
+
+ // Everybody else is access level '1'
+ return 1;
+}
+
+?>
Property changes on: mrbs/trunk/web/auth_smtp.inc
___________________________________________________________________
Added: svn:keywords
+ Id
Added: svn:eol-style
+ native
Modified: mrbs/trunk/web/config.inc.php
===================================================================
--- mrbs/trunk/web/config.inc.php 2009-05-19 17:54:39 UTC (rev 1112)
+++ mrbs/trunk/web/config.inc.php 2009-05-22 13:56:29 UTC (rev 1113)
@@ -489,7 +489,10 @@
// The POP3 server port
$pop3_port = "110";
+// 'auth_smtp' configuration settings
+$auth['smtp']['server'] = 'myserver.example.org';
+
/**********************************************
* Email settings
**********************************************/
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
------------------------------------------------------------------------------
Register Now for Creativity and Technology (CaT), June 3rd, NYC. CaT
is a gathering of tech-side developers & brand creativity professionals. Meet
the minds behind Google Creative Lab, Visual Complexity, Processing, &
iPhoneDevCamp asthey present alongside digital heavyweights like Barbarian
Group, R/GA, & Big Spaceship. http://www.creativitycat.com
_______________________________________________
Mrbs-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mrbs-commits