Skip to content

Commit 4f28001

Browse files
authored
Merge pull request #701 from DirectoryTree/FEATURE-700
Feature 700 - [Feature] Disable mandatory TLS connection for localhost
2 parents 10fe6b8 + 926fee3 commit 4f28001

File tree

5 files changed

+17
-6
lines changed

5 files changed

+17
-6
lines changed

src/Configuration/DomainConfiguration.php

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,15 +38,18 @@ class DomainConfiguration
3838
// The password to use for binding.
3939
'password' => '',
4040

41-
// Whether or not to use SSL when connecting.
41+
// Whether to use SSL when connecting.
4242
'use_ssl' => false,
4343

44-
// Whether or not to use TLS when connecting.
44+
// Whether to use TLS when connecting.
4545
'use_tls' => false,
4646

47-
// Whether or not to use SASL when connecting.
47+
// Whether to use SASL when connecting.
4848
'use_sasl' => false,
4949

50+
// Whether to allow password changes over plaintext.
51+
'allow_insecure_password_changes' => false,
52+
5053
// SASL options
5154
'sasl_options' => [
5255
'mech' => null,
@@ -56,7 +59,7 @@ class DomainConfiguration
5659
'props' => null,
5760
],
5861

59-
// Whether or not follow referrals is enabled when performing LDAP operations.
62+
// Whether follow referrals is enabled when performing LDAP operations.
6063
'follow_referrals' => false,
6164

6265
// Custom LDAP options.

src/Models/Attributes/TSProperty.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ protected function getDecodedValueForProp(string $propName, string $propValue):
202202
* Decode the property by inspecting the nibbles of each blob, checking
203203
* the control, and adding up the results into a final value.
204204
*
205-
* @param bool $string Whether or not this is simple string data.
205+
* @param bool $string Whether this is simple string data.
206206
*/
207207
protected function decodePropValue(string $hex, bool $string = false): string
208208
{

src/Models/Concerns/HasPassword.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,10 +165,16 @@ protected function assertSecureConnection(): void
165165
{
166166
$connection = $this->getConnection();
167167

168+
$config = $connection->getConfiguration();
169+
170+
if ($config->get('allow_insecure_password_changes') === true) {
171+
return;
172+
}
173+
168174
if ($connection->isConnected()) {
169175
$secure = $connection->getLdapConnection()->canChangePasswords();
170176
} else {
171-
$secure = $connection->getConfiguration()->get('use_ssl') || $connection->getConfiguration()->get('use_tls');
177+
$secure = $config->get('use_ssl') || $config->get('use_tls');
172178
}
173179

174180
if (! $secure) {

tests/Unit/Configuration/DomainConfigurationTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@ public function test_get_all()
9898
'use_ssl' => false,
9999
'use_tls' => false,
100100
'use_sasl' => false,
101+
'allow_insecure_password_changes' => false,
101102
'sasl_options' => [
102103
'mech' => null,
103104
'realm' => null,

tests/Unit/FakeDirectoryTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ public function test_fake_connection_uses_real_connections_config()
5353
'use_tls' => true,
5454
'use_ssl' => false,
5555
'use_sasl' => false,
56+
'allow_insecure_password_changes' => false,
5657
'timeout' => 5,
5758
'version' => 3,
5859
'follow_referrals' => false,

0 commit comments

Comments
 (0)