From f600fa3b1a3a4c81f6573d05dbcf286e2834a389 Mon Sep 17 00:00:00 2001 From: Craig Andrews Date: Wed, 11 Nov 2009 12:16:58 -0500 Subject: [PATCH 1/2] Rename the plugins, as I'm separating out Authn, Authz, and user information into separate plugins --- .../AuthenticationPlugin.php} | 14 +++++++------- .../LdapAuthenticationPlugin.php} | 4 ++-- plugins/{Ldap => LdapAuthentication}/README | 10 +++++----- 3 files changed, 14 insertions(+), 14 deletions(-) rename plugins/{Auth/AuthPlugin.php => Authentication/AuthenticationPlugin.php} (94%) rename plugins/{Ldap/LdapPlugin.php => LdapAuthentication/LdapAuthenticationPlugin.php} (97%) rename plugins/{Ldap => LdapAuthentication}/README (82%) diff --git a/plugins/Auth/AuthPlugin.php b/plugins/Authentication/AuthenticationPlugin.php similarity index 94% rename from plugins/Auth/AuthPlugin.php rename to plugins/Authentication/AuthenticationPlugin.php index cb52730f67..ef78c7ce40 100644 --- a/plugins/Auth/AuthPlugin.php +++ b/plugins/Authentication/AuthenticationPlugin.php @@ -40,10 +40,10 @@ if (!defined('STATUSNET') && !defined('LACONICA')) { * @link http://status.net/ */ -abstract class AuthPlugin extends Plugin +abstract class AuthenticationPlugin extends Plugin { //is this plugin authoritative for authentication? - public $authn_authoritative = false; + public $authoritative = false; //should accounts be automatically created after a successful login attempt? public $autoregistration = false; @@ -119,13 +119,13 @@ abstract class AuthPlugin extends Plugin } return false; }else{ - if($this->authn_authoritative){ + if($this->authoritative){ return false; } } //we're not authoritative, so let other handlers try }else{ - if($this->authn_authoritative){ + if($this->authoritative){ //since we're authoritative, no other plugin could do this throw new Exception(_('Password changing is not allowed')); } @@ -145,7 +145,7 @@ abstract class AuthPlugin extends Plugin throw new Exception(_('Password changing failed')); } }else{ - if($this->authn_authoritative){ + if($this->authoritative){ //since we're authoritative, no other plugin could do this throw new Exception(_('Password changing failed')); }else{ @@ -154,7 +154,7 @@ abstract class AuthPlugin extends Plugin } } }else{ - if($this->authn_authoritative){ + if($this->authoritative){ //since we're authoritative, no other plugin could do this throw new Exception(_('Password changing is not allowed')); } @@ -163,7 +163,7 @@ abstract class AuthPlugin extends Plugin function onStartAccountSettingsPasswordMenuItem($widget) { - if($this->authn_authoritative && !$this->password_changeable){ + if($this->authoritative && !$this->password_changeable){ //since we're authoritative, no other plugin could change passwords, so do render the menu item return false; } diff --git a/plugins/Ldap/LdapPlugin.php b/plugins/LdapAuthentication/LdapAuthenticationPlugin.php similarity index 97% rename from plugins/Ldap/LdapPlugin.php rename to plugins/LdapAuthentication/LdapAuthenticationPlugin.php index 88ca92b372..f14080b2d6 100644 --- a/plugins/Ldap/LdapPlugin.php +++ b/plugins/LdapAuthentication/LdapAuthenticationPlugin.php @@ -31,10 +31,10 @@ if (!defined('STATUSNET') && !defined('LACONICA')) { exit(1); } -require_once INSTALLDIR.'/plugins/Auth/AuthPlugin.php'; +require_once INSTALLDIR.'/plugins/Authentication/AuthenticationPlugin.php'; require_once 'Net/LDAP2.php'; -class LdapPlugin extends AuthPlugin +class LdapAuthenticatonPlugin extends AuthenticationPlugin { public $host=null; public $port=null; diff --git a/plugins/Ldap/README b/plugins/LdapAuthentication/README similarity index 82% rename from plugins/Ldap/README rename to plugins/LdapAuthentication/README index 063286cef5..03647e7c75 100644 --- a/plugins/Ldap/README +++ b/plugins/LdapAuthentication/README @@ -1,12 +1,12 @@ -The LDAP plugin allows for StatusNet to handle authentication, authorization, and user information through LDAP. +The LDAP Authentication plugin allows for StatusNet to handle authentication through LDAP. Installation ============ -add "addPlugin('ldap', array('setting'=>'value', 'setting2'=>'value2', ...);" to the bottom of your config.php +add "addPlugin('ldapAuthentication', array('setting'=>'value', 'setting2'=>'value2', ...);" to the bottom of your config.php Settings ======== -authn_authoritative (false): Set to true if LDAP's responses are authoritative (meaning if LDAP fails, do check the any other plugins or the internal password database). +authoritative (false): Set to true if LDAP's responses are authoritative (meaning if LDAP fails, do check the any other plugins or the internal password database). autoregistration (false): Set to true if users should be automatically created when they attempt to login. email_changeable (true): Are users allowed to change their email address? (true or false) password_changeable (true): Are users allowed to change their passwords? (true or false) @@ -36,8 +36,8 @@ Example ======= Here's an example of an LDAP plugin configuration that connects to Microsoft Active Directory. -addPlugin('ldap', array( - 'authn_authoritative'=>true, +addPlugin('ldapAuthentication', array( + 'authoritative'=>true, 'autoregistration'=>true, 'binddn'=>'username', 'bindpw'=>'password', From 7f8dbb8e457d1e5534ebb569988d84ee3adaeef7 Mon Sep 17 00:00:00 2001 From: Brion Vibber Date: Wed, 11 Nov 2009 10:38:11 -0800 Subject: [PATCH 2/2] Fix bug 1963: Web UI throws warnings during previously open login session after user account is deleted common_logged_in() returned bogus results because it checks against null specifically, but common_current_user() was sticking 'false' into $_cur because that's what User::staticGet() returned from a failed lookup. Now we skip over a failed lookup here, so we keep null and all is well. --- lib/util.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/lib/util.php b/lib/util.php index 81160d052c..7aca4af8d6 100644 --- a/lib/util.php +++ b/lib/util.php @@ -350,8 +350,11 @@ function common_current_user() common_ensure_session(); $id = isset($_SESSION['userid']) ? $_SESSION['userid'] : false; if ($id) { - $_cur = User::staticGet($id); - return $_cur; + $user = User::staticGet($id); + if ($user) { + $_cur = $user; + return $_cur; + } } }