diff options
| author | lsces <lester@lsces.co.uk> | 2026-04-19 19:07:28 +0100 |
|---|---|---|
| committer | lsces <lester@lsces.co.uk> | 2026-04-19 19:07:28 +0100 |
| commit | 0ff850a8cc9d6c6256257c4750377eab9f3aa5ae (patch) | |
| tree | 670eec8a65dc99b14de70e1f754b5220d45c3d8b /auth | |
| parent | e0020d728d54bd97ced9df34a38ef9c39e05ff48 (diff) | |
| download | users-0ff850a8cc9d6c6256257c4750377eab9f3aa5ae.tar.gz users-0ff850a8cc9d6c6256257c4750377eab9f3aa5ae.tar.bz2 users-0ff850a8cc9d6c6256257c4750377eab9f3aa5ae.zip | |
Pull alternate Auth libraries into Bitweaver\Users namespace not functionally tested, just getting admin pages running cleaner
Diffstat (limited to 'auth')
| -rwxr-xr-x[-rw-r--r--] | auth/imap/auth.php | 9 | ||||
| -rwxr-xr-x[-rw-r--r--] | auth/ldap/auth.php | 301 | ||||
| -rwxr-xr-x[-rw-r--r--] | auth/locate/auth.php | 3 | ||||
| -rwxr-xr-x[-rw-r--r--] | auth/multisites/auth.php | 3 |
4 files changed, 163 insertions, 153 deletions
diff --git a/auth/imap/auth.php b/auth/imap/auth.php index 75c8f84..a8fb8b3 100644..100755 --- a/auth/imap/auth.php +++ b/auth/imap/auth.php @@ -11,6 +11,9 @@ * @package users * @subpackage auth */ +namespace Bitweaver\Users; +use Bitweaver\KernelTools; + class IMAPAuth extends BaseAuth { function __construct() { @@ -56,19 +59,19 @@ class IMAPAuth extends BaseAuth { function isSupported() { $ret = true; if (!function_exists('imap_open')) { - $this->mErrors['support']=tra("IMAP Authentication is not supported as PHP IMAP Extention not loaded."); + $this->mErrors['support']=KernelTools::tra("IMAP Authentication is not supported as PHP IMAP Extention not loaded."); $ret = false; } return $ret; } function createUser(&$userattr) { - $this->mErrors['create']=tra("Cannot create users in an IMAP Server."); + $this->mErrors['create']=KernelTools::tra("Cannot create users in an IMAP Server."); return false; } function canManageAuth() { - $this->mErrors[]=tra("Cannot create users in an IMAP Server."); + $this->mErrors[]=KernelTools::tra("Cannot create users in an IMAP Server."); return false; } diff --git a/auth/ldap/auth.php b/auth/ldap/auth.php index 5cb6c52..b0e599f 100644..100755 --- a/auth/ldap/auth.php +++ b/auth/ldap/auth.php @@ -8,6 +8,9 @@ /** * required setup */ +namespace Bitweaver\Users; +use Bitweaver\KernelTools; + if (file_exists(UTIL_PKG_INCLUDE_PATH."pear/Auth/Auth.php")) { require_once (UTIL_PKG_INCLUDE_PATH."pear/Auth/Auth.php"); } else { @@ -56,7 +59,7 @@ class LDAPAuth extends BaseAuth { unset($this->mConfig['group']); } - $a = new Auth('LDAP', $this->mConfig, "", false); + $a = new \Auth('LDAP', $this->mConfig, "", false); $a->_loadStorage(); // set up connection to ldap via user details // First, try by username. If that fails, try by email address. @@ -68,7 +71,7 @@ class LDAPAuth extends BaseAuth { $this->mConfig['userattr'] = $this->mConfig['email']; // Tell PEAR::Auth() to look at the 'mail' attribute // this needs testing better, should be no need to create second instance of Auth! - $a = new Auth('LDAP', $this->mConfig, "", false); + $a = new \Auth('LDAP', $this->mConfig, "", false); $a->_loadStorage(); // set up connection to ldap via user details $success = $a->storage->fetchData($user_utf8, $pass, false); @@ -106,11 +109,11 @@ class LDAPAuth extends BaseAuth { function isSupported() { $ret = true; if (!class_exists("Auth")) { - $this->mErrors['support']=tra("LDAP Authentication is not supported as PEAR Package Auth is not availible."); + $this->mErrors['support']=KernelTools::tra("LDAP Authentication is not supported as PEAR Package Auth is not availible."); $ret = false; } if (!function_exists('ldap_connect')) { - $this->mErrors['support']=tra("LDAP Authentication is not supported as PHP LDAP Extention not loaded."); + $this->mErrors['support']=KernelTools::tra("LDAP Authentication is not supported as PHP LDAP Extention not loaded."); $ret = false; } return $ret; @@ -124,7 +127,7 @@ class LDAPAuth extends BaseAuth { $userattr["email"] = $gBitDb->getOne("select `email` from `".BIT_DB_PREFIX."users_users` where `login`=?", array($userattr["login"])); } // set the Auth options - $a = new Auth("LDAP", $this->mConfig); + $a = new \Auth("LDAP", $this->mConfig); // check if the login correct if ($a->addUser($userattr["login"], $userattr["password"], $userattr) === true) { return true; @@ -141,157 +144,155 @@ class LDAPAuth extends BaseAuth { function getSettings() { global $gBitUser; - $listHash = array(); + $listHash = []; // Roles are not inteneded to match with ldap groups // This area needs a closer look if it needs to be used - $groups = array(); + $groups = []; $groups = $gBitUser->getAllGroups($listHash); - $groupsD = array(); + $groupsD = []; foreach ($groups as $g) { $groupsD[$g['group_id']]= "{$g['group_name']} ( {$g['group_desc']} )"; } $groups = $groupsD; - return array( - 'users_ldap_url' => array( - 'label' => "LDAP Connection URL", - 'type' => "text", - 'note' => "You can specify an LDAP URL, like ldap://localhost/ or ldaps://some-server/.", - 'default' => '', - ), - 'users_ldap_host' => array( - 'label' => "LDAP Host", - 'type' => "text", - 'note' => "Instead of a URL, you can specify a hostname and port explicitly. Give either a URL, or else a hostname/port (but not both).", - 'default' => 'localhost', - ), - 'users_ldap_port' => array( - 'label' => "LDAP Port", - 'type' => "text", - 'note' => "", - 'default' => '389', - ), - 'users_ldap_start_tls' => array( - 'label' => "Use Start-TLS?", - 'type' => "checkbox", - 'note' => "Please note there is a difference between ldaps:// and Start-TLS for ldap. Start-TLS uses port 389, while ldaps:// uses port 636. Both encrypted LDAP (with Start-TLS) and unencrypted LDAP can run on port 389 concurrently.", - 'default' => 'y', - ), - 'users_ldap_reqcert' => array( - 'label' => "Skip the SSL Cert validation?", - 'type' => "checkbox", - 'note' => "If Start-TLS is checked, then your LDAP server needs a trusted SSL cert -- unless you check this option, in which case you can use a self-signed (untrusted) cert.", - 'default' => 'y', - ), - 'users_ldap_referrals' => array( - 'label' => "Use Referrals?", - 'type' => "checkbox", - 'note' => "This should probably be 'yes'. (Only applies to LDAP V3 servers.)", - 'default' => 'y', - ), - 'users_ldap_basedn' => array( - 'label' => "LDAP Base DN", - 'type' => "text", - 'note' => "", - 'default' => '', - ), - 'users_ldap_userdn' => array( - 'label' => "LDAP User DN", - 'type' => "text", - 'note' => "", - 'default' => '', - ), - 'users_ldap_userattr' => array( - 'label' => "LDAP User Attribute", - 'type' => "text", - 'note' => "The LDAP Attribute to use for the user's login in Bitweaver. (This is the first attribute searched when the user logs in.)", - 'default' => 'uid', - ), - 'users_ldap_email' => array( - 'label' => "LDAP User E-Mail Address", - 'type' => "text", - 'note' => "The LDAP Attribute to use for the user's email address in Bitweaver. (This is the second attribute searched when the user logs in.)", - 'default' => 'mail', - ), - 'users_ldap_name' => array( - 'label' => "LDAP User Display Name", - 'type' => "text", - 'note' => "The LDAP Attribute to use for the user's Full Name in Bitweaver.", - 'default' => 'displayName', - ), - 'users_ldap_useroc' => array( - 'label' => "LDAP User OC", - 'type' => "text", - 'note' => "", - 'default' => '(objectClass=inetOrgPerson)', - ), - 'users_ldap_groupdn' => array( - 'label' => "LDAP Group DN", - 'type' => "text", - 'note' => "", - 'default' => '', - ), - 'users_ldap_groupattr' => array( - 'label' => "LDAP Group Atribute", - 'type' => "text", - 'note' => "", - 'default' => 'cn', - ), - 'users_ldap_groupoc' => array( - 'label' => "LDAP Group OC", - 'type' => "text", - 'note' => "", - 'default' => '(objectClass=groupOfUniqueNames)', - ), - 'users_ldap_memberattr' => array( - 'label' => "LDAP Member Attribute", - 'type' => "text", - 'note' => "", - 'default' => 'uniqueMember', - ), - 'users_ldap_memberisdn' => array( - 'label' => "LDAP Member Is DN", - 'type' => "checkbox", - 'note' => "", - 'default' => 'n', - ), - 'users_ldap_binddn' => array( - 'label' => "LDAP Bind DN", - 'type' => "text", - 'note' => "This DN will be used to search the LDAP directory for users. If left blank, 'anonymous bind' is used.", - 'default' => '', - ), - 'users_ldap_bindpw' => array( - 'label' => "LDAP Bind Pwd", - 'type' => "password", - 'note' => "", - 'default' => '', - ), - 'users_ldap_userscope' => array( - 'label' => "LDAP Scope to use when searching for users", - 'type' => "option", - 'note' => "", - 'default' => 'sub', - 'options' => array( - 'sub' => "Sub", - 'one' => "One", - 'base' => "Base", - ), - ), - 'users_ldap_group' => array( - 'label' => "LDAP Group Requirement", - 'type' => "text", - 'note' => "If this is specified, then the LDAP user must also be a member of this LDAP group to connect.", - 'default' => '' - ), - 'users_ldap_activedirectory' => array( - 'label' => "Active Directory?", - 'type' => "checkbox", - 'note' => "", - 'default' => 'n' - ), - ); + return [ + 'users_ldap_url' => [ + 'label' => "LDAP Connection URL", + 'type' => "text", + 'note' => "You can specify an LDAP URL, like ldap://localhost/ or ldaps://some-server/.", + 'default' => '', + ], + 'users_ldap_host' => [ + 'label' => "LDAP Host", + 'type' => "text", + 'note' => "Instead of a URL, you can specify a hostname and port explicitly. Give either a URL, or else a hostname/port (but not both).", + 'default' => 'localhost', + ], + 'users_ldap_port' => [ + 'label' => "LDAP Port", + 'type' => "text", + 'note' => "", + 'default' => '389', + ], + 'users_ldap_start_tls' => [ + 'label' => "Use Start-TLS?", + 'type' => "checkbox", + 'note' => "Please note there is a difference between ldaps:// and Start-TLS for ldap. Start-TLS uses port 389, while ldaps:// uses port 636. Both encrypted LDAP (with Start-TLS) and unencrypted LDAP can run on port 389 concurrently.", + 'default' => 'y', + ], + 'users_ldap_reqcert' => [ + 'label' => "Skip the SSL Cert validation?", + 'type' => "checkbox", + 'note' => "If Start-TLS is checked, then your LDAP server needs a trusted SSL cert -- unless you check this option, in which case you can use a self-signed (untrusted) cert.", + 'default' => 'y', + ], + 'users_ldap_referrals' => [ + 'label' => "Use Referrals?", + 'type' => "checkbox", + 'note' => "This should probably be 'yes'. (Only applies to LDAP V3 servers.)", + 'default' => 'y', + ], + 'users_ldap_basedn' => [ + 'label' => "LDAP Base DN", + 'type' => "text", + 'note' => "", + 'default' => '', + ], + 'users_ldap_userdn' => [ + 'label' => "LDAP User DN", + 'type' => "text", + 'note' => "", + 'default' => '', + ], + 'users_ldap_userattr' => [ + 'label' => "LDAP User Attribute", + 'type' => "text", + 'note' => "The LDAP Attribute to use for the user's login in Bitweaver. (This is the first attribute searched when the user logs in.)", + 'default' => 'uid', + ], + 'users_ldap_email' => [ + 'label' => "LDAP User E-Mail Address", + 'type' => "text", + 'note' => "The LDAP Attribute to use for the user's email address in Bitweaver. (This is the second attribute searched when the user logs in.)", + 'default' => 'mail', + ], + 'users_ldap_name' => [ + 'label' => "LDAP User Display Name", + 'type' => "text", + 'note' => "The LDAP Attribute to use for the user's Full Name in Bitweaver.", + 'default' => 'displayName', + ], + 'users_ldap_useroc' => [ + 'label' => "LDAP User OC", + 'type' => "text", + 'note' => "", + 'default' => '(objectClass=inetOrgPerson)', + ], + 'users_ldap_groupdn' => [ + 'label' => "LDAP Group DN", + 'type' => "text", + 'note' => "", + 'default' => '', + ], + 'users_ldap_groupattr' => [ + 'label' => "LDAP Group Atribute", + 'type' => "text", + 'note' => "", + 'default' => 'cn', + ], + 'users_ldap_groupoc' => [ + 'label' => "LDAP Group OC", + 'type' => "text", + 'note' => "", + 'default' => '(objectClass=groupOfUniqueNames)', + ], + 'users_ldap_memberattr' => [ + 'label' => "LDAP Member Attribute", + 'type' => "text", + 'note' => "", + 'default' => 'uniqueMember', + ], + 'users_ldap_memberisdn' => [ + 'label' => "LDAP Member Is DN", + 'type' => "checkbox", + 'note' => "", + 'default' => 'n', + ], + 'users_ldap_binddn' => [ + 'label' => "LDAP Bind DN", + 'type' => "text", + 'note' => "This DN will be used to search the LDAP directory for users. If left blank, 'anonymous bind' is used.", + 'default' => '', + ], + 'users_ldap_bindpw' => [ + 'label' => "LDAP Bind Pwd", + 'type' => "password", + 'note' => "", + 'default' => '', + ], + 'users_ldap_userscope' => [ + 'label' => "LDAP Scope to use when searching for users", + 'type' => "option", + 'note' => "", + 'default' => 'sub', + 'options' => [ + 'sub' => "Sub", + 'one' => "One", + 'base' => "Base", + ], + ], + 'users_ldap_group' => [ + 'label' => "LDAP Group Requirement", + 'type' => "text", + 'note' => "If this is specified, then the LDAP user must also be a member of this LDAP group to connect.", + 'default' => '', + ], + 'users_ldap_activedirectory' => [ + 'label' => "Active Directory?", + 'type' => "checkbox", + 'note' => "", + 'default' => 'n', + ], + ]; } -} - -?> +}
\ No newline at end of file diff --git a/auth/locate/auth.php b/auth/locate/auth.php index 5918d83..2d6bf14 100644..100755 --- a/auth/locate/auth.php +++ b/auth/locate/auth.php @@ -14,6 +14,9 @@ * @package users * @subpackage auth */ +namespace Bitweaver\Users; +use Bitweaver\KernelTools; + class LocateAuth extends BaseAuth { function __construct() { diff --git a/auth/multisites/auth.php b/auth/multisites/auth.php index 4b08421..680f4e4 100644..100755 --- a/auth/multisites/auth.php +++ b/auth/multisites/auth.php @@ -11,6 +11,9 @@ * @package users * @subpackage auth */ +namespace Bitweaver\Users; +use Bitweaver\KernelTools; + class MultisitesAuth extends BaseAuth { function __construct() { |
