From 65d26d4d83d4df3e87ff4fe8f73325ca4110f09b Mon Sep 17 00:00:00 2001 From: Lai Power Date: Thu, 27 Jun 2024 12:10:42 +0000 Subject: [PATCH] updated plugin `AuthLDAP` version 2.6.2 --- wp-content/plugins/authldap/authLdap.php | 14 +++---- .../features/bootstrap/FeatureContext.php | 21 +++++++++- .../log in using no groups at all.feature | 21 ++++++++++ wp-content/plugins/authldap/readme.txt | 5 ++- .../authldap/src/Exception/UnknownOption.php | 4 +- .../plugins/authldap/src/OptionFactory.php | 4 +- wp-content/plugins/authldap/src/Options.php | 5 ++- .../plugins/authldap/src/UserRoleHandler.php | 2 +- wp-content/plugins/authldap/view/admin.phtml | 39 ++++++++++--------- .../plugins/authldap/wordpress/info.php | 1 + 10 files changed, 81 insertions(+), 35 deletions(-) create mode 100644 wp-content/plugins/authldap/wordpress/info.php diff --git a/wp-content/plugins/authldap/authLdap.php b/wp-content/plugins/authldap/authLdap.php index cbe009d3..c0c54f5d 100644 --- a/wp-content/plugins/authldap/authLdap.php +++ b/wp-content/plugins/authldap/authLdap.php @@ -4,7 +4,7 @@ Plugin Name: AuthLDAP Plugin URI: https://github.com/heiglandreas/authLdap Description: This plugin allows you to use your existing LDAP as authentication base for WordPress -Version: 2.6.0 +Version: 2.6.2 Author: Andreas Heigl Author URI: http://andreas.heigl.org License: MIT @@ -77,7 +77,7 @@ function authLdap_options_panel() if (!isset($_POST['authLdapNonce'])) { die("Go away!"); } - if (!wp_verify_nonce($_POST['authLdapNonce'],'authLdapNonce')) { + if (!wp_verify_nonce($_POST['authLdapNonce'], 'authLdapNonce')) { die("Go away!"); } @@ -255,8 +255,8 @@ function authLdap_login($user, $username, $password, $already_md5 = false) $authLDAPUidAttr = authLdap_get_option('UidAttr'); $authLDAPWebAttr = authLdap_get_option('WebAttr'); $authLDAPDefaultRole = authLdap_get_option('DefaultRole'); - $authLDAPGroupEnable = authLdap_get_option('GroupEnable'); - $authLDAPGroupOverUser = authLdap_get_option('GroupOverUser'); + $authLDAPGroupEnable = filter_var(authLdap_get_option('GroupEnable'), FILTER_VALIDATE_BOOLEAN); + $authLDAPGroupOverUser = filter_var(authLdap_get_option('GroupOverUser'), FILTER_VALIDATE_BOOLEAN); $authLDAPUseUserAccount = authLdap_get_option('UserRead'); if (!$username) { @@ -373,7 +373,7 @@ function authLdap_login($user, $username, $password, $already_md5 = false) // we only need this if either LDAP groups are disabled or // if the WordPress role of the user overrides LDAP groups - if (!$authLDAPGroupEnable || $authLDAPGroupOverUser) { + if ($authLDAPGroupEnable === false || $authLDAPGroupOverUser === false) { $userRoles = authLdap_user_role($uid); if ($userRoles !== []) { $roles = array_merge($roles, $userRoles); @@ -383,8 +383,8 @@ function authLdap_login($user, $username, $password, $already_md5 = false) } // do LDAP group mapping if needed - // (if LDAP groups override worpress user role, $role is still empty) - if (empty($roles) && $authLDAPGroupEnable) { + // (if LDAP groups override wordpress user role, $role is still empty) + if ((empty($roles) || $authLDAPGroupOverUser === true) && $authLDAPGroupEnable === true) { $mappedRoles = authLdap_groupmap($realuid, $dn); if ($mappedRoles !== []) { $roles = $mappedRoles; diff --git a/wp-content/plugins/authldap/features/bootstrap/FeatureContext.php b/wp-content/plugins/authldap/features/bootstrap/FeatureContext.php index 1e495b2c..a2d109cb 100644 --- a/wp-content/plugins/authldap/features/bootstrap/FeatureContext.php +++ b/wp-content/plugins/authldap/features/bootstrap/FeatureContext.php @@ -284,6 +284,25 @@ LDIF', return trim($item); }, explode(',', $user['roles'])); Assert::false(in_array($arg2, $roles)); - } + + /** + * @Given LDAP user :arg1 is not member of LDAP group :arg2 + */ + public function ldapUserIsNotMemberOfLdapGroup($arg1, $arg2) + { + exec(sprintf( + 'ldapmodify -x -H %1$s -D "%2$s" -w %3$s 2>&1 < * * Licensed under the MIT-license. For details see the included file LICENSE.md */ +declare(strict_types=1); + namespace Org_Heigl\AuthLdap\Exception; use RuntimeException; diff --git a/wp-content/plugins/authldap/src/OptionFactory.php b/wp-content/plugins/authldap/src/OptionFactory.php index aa2955e4..97446145 100644 --- a/wp-content/plugins/authldap/src/OptionFactory.php +++ b/wp-content/plugins/authldap/src/OptionFactory.php @@ -1,13 +1,13 @@ * * Licensed under the MIT-license. For details see the included file LICENSE.md */ +declare(strict_types=1); + namespace Org_Heigl\AuthLdap; use function json_decode; diff --git a/wp-content/plugins/authldap/src/Options.php b/wp-content/plugins/authldap/src/Options.php index ee7b969c..c4d3928b 100644 --- a/wp-content/plugins/authldap/src/Options.php +++ b/wp-content/plugins/authldap/src/Options.php @@ -1,16 +1,17 @@ * * Licensed under the MIT-license. For details see the included file LICENSE.md */ +declare(strict_types=1); + namespace Org_Heigl\AuthLdap; use Org_Heigl\AuthLdap\Exception\UnknownOption; + use function array_key_exists; class Options diff --git a/wp-content/plugins/authldap/src/UserRoleHandler.php b/wp-content/plugins/authldap/src/UserRoleHandler.php index 8966980f..d8c3a006 100644 --- a/wp-content/plugins/authldap/src/UserRoleHandler.php +++ b/wp-content/plugins/authldap/src/UserRoleHandler.php @@ -23,7 +23,7 @@ class UserRoleHandler * @param string[] $roles * @return void */ - public function addRolesToUser(WP_User $user, $roles) : void + public function addRolesToUser(WP_User $user, $roles): void { if ($roles === []) { return; diff --git a/wp-content/plugins/authldap/view/admin.phtml b/wp-content/plugins/authldap/view/admin.phtml index 0c55b319..779ba26c 100644 --- a/wp-content/plugins/authldap/view/admin.phtml +++ b/wp-content/plugins/authldap/view/admin.phtml @@ -101,7 +101,7 @@ + class="regular-text" value=""/>

The URI for connecting to the LDAP-Server. This usualy takes the form @@ -139,7 +139,7 @@ + class="regular-text" value=""/>

A separator that separates multiple LDAP-URIs from one another. You can use that feature to try to authenticate against multiple LDAP-Servers @@ -152,7 +152,7 @@ - /> + />

Use StartTLS for encryption of ldap connections. This setting is not to be used in combination with ldaps connections (ldap:// only).

@@ -163,7 +163,7 @@ + class="regular-text" value=""/>

Please provide a valid filter that can be used for querying the LDAP @@ -190,7 +190,7 @@ - />
+ />

If checked the plugin will use the user's account to query their own information. If not it will use the admin account.

@@ -203,7 +203,7 @@
+ class="regular-text" value=""/>

Which Attribute from the LDAP contains the Full or the First name of the user trying to log in. @@ -220,7 +220,7 @@ + class="regular-text" value="" />

If the above Name-Attribute only contains the First Name of the user you can here specify an Attribute that contains the second name. @@ -236,7 +236,7 @@ + class="regular-text" value="" />

Please give the Attribute, that is used to identify the user. This should be the same as you used in the above Filter-Option @@ -252,7 +252,7 @@ + class="regular-text" value="" />

Which Attribute holds the eMail-Address of the user?

@@ -270,7 +270,7 @@ + class="regular-text" value="" />

If your users have a personal page (URI) stored in the LDAP, it can be provided here. @@ -291,7 +291,7 @@ get_names() as $group => $vals) : ?> @@ -317,7 +317,7 @@ - /> + />

If role determined by LDAP Group differs from existing Wordpress User's role, use LDAP Group.

@@ -329,7 +329,7 @@ + class="regular-text" value="" />

This is the base dn to lookup groups.

@@ -344,7 +344,7 @@ + class="regular-text" value="" />

This is the attribute that defines the Group-ID that can be matched against the Groups defined further down @@ -360,7 +360,7 @@ + class="regular-text" value="" />

This attribute defines the separator used for the Group-IDs listed in the Groups defined further down. This is useful if the value of Group-Attribute @@ -378,7 +378,7 @@ + class="regular-text" value="" />

Here you can add the filter for selecting groups for ther currentlly logged in user @@ -416,12 +416,13 @@ - + diff --git a/wp-content/plugins/authldap/wordpress/info.php b/wp-content/plugins/authldap/wordpress/info.php new file mode 100644 index 00000000..b3d9bbc7 --- /dev/null +++ b/wp-content/plugins/authldap/wordpress/info.php @@ -0,0 +1 @@ +