From ab5ee5d1935aa1f719b37c629eb3a77b751208c5 Mon Sep 17 00:00:00 2001 From: epriestley Date: Thu, 18 Jul 2013 12:40:57 -0700 Subject: [PATCH] Survive mild misconfiguration of Realname Attributes in LDAP Summary: Currently, we'll fatal on array typehint issues if this is misconfigured. Instead, we should just reject the configuration. See some discussion in IRC. Test Plan: Used LDAP to log in. Reviewers: btrahan, totorico Reviewed By: btrahan CC: aran Differential Revision: https://secure.phabricator.com/D6489 --- .../auth/provider/PhabricatorAuthProviderLDAP.php | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/applications/auth/provider/PhabricatorAuthProviderLDAP.php b/src/applications/auth/provider/PhabricatorAuthProviderLDAP.php index fa8e295b78..deefb54bce 100644 --- a/src/applications/auth/provider/PhabricatorAuthProviderLDAP.php +++ b/src/applications/auth/provider/PhabricatorAuthProviderLDAP.php @@ -24,6 +24,12 @@ final class PhabricatorAuthProviderLDAP public function getAdapter() { if (!$this->adapter) { $conf = $this->getProviderConfig(); + + $realname_attributes = $conf->getProperty(self::KEY_REALNAME_ATTRIBUTES); + if (!is_array($realname_attributes)) { + $realname_attributes = array(); + } + $adapter = id(new PhutilAuthAdapterLDAP()) ->setHostname( $conf->getProperty(self::KEY_HOSTNAME)) @@ -35,8 +41,7 @@ final class PhabricatorAuthProviderLDAP $conf->getProperty(self::KEY_SEARCH_ATTRIBUTE)) ->setUsernameAttribute( $conf->getProperty(self::KEY_USERNAME_ATTRIBUTE)) - ->setRealNameAttributes( - $conf->getProperty(self::KEY_REALNAME_ATTRIBUTES, array())) + ->setRealNameAttributes($realname_attributes) ->setLDAPVersion( $conf->getProperty(self::KEY_VERSION)) ->setLDAPReferrals(