Skip to content

Commit 6c14c09

Browse files
committed
Add ability to disable LDAP certificate validation
1 parent 85f330c commit 6c14c09

3 files changed

Lines changed: 9 additions & 0 deletions

File tree

.env.example

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,8 @@ LDAP_GROUP_ATTRIBUTE="memberOf"
7676
# Would you like to remove users from roles on BookStack if they do not match on LDAP
7777
# If false, the ldap groups-roles sync will only add users to roles
7878
LDAP_REMOVE_FROM_GROUPS=false
79+
# Set this option to disable LDAPS Certificate Verification
80+
LDAP_TLS_INSECURE=false
7981

8082
# Mail settings
8183
MAIL_DRIVER=smtp

app/Auth/Access/LdapService.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,8 +169,14 @@ protected function getConnection()
169169
}
170170
$hostName = $ldapServer[0] . ($hasProtocol?':':'') . $ldapServer[1];
171171
$defaultPort = $ldapServer[0] === 'ldaps' ? 636 : 389;
172+
172173
$ldapConnection = $this->ldap->connect($hostName, count($ldapServer) > 2 ? intval($ldapServer[2]) : $defaultPort);
173174

175+
// Check if TLS_INSECURE is set
176+
if($this->config['tls_insecure']) {
177+
$this->ldap->setOption($ldapConnection, LDAP_OPT_X_TLS_REQUIRE_CERT, LDAP_OPT_X_TLS_NEVER);
178+
}
179+
174180
if ($ldapConnection === false) {
175181
throw new LdapException(trans('errors.ldap_cannot_connect'));
176182
}

config/services.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,7 @@
148148
'user_to_groups' => env('LDAP_USER_TO_GROUPS',false),
149149
'group_attribute' => env('LDAP_GROUP_ATTRIBUTE', 'memberOf'),
150150
'remove_from_groups' => env('LDAP_REMOVE_FROM_GROUPS',false),
151+
'tls_insecure' => env('LDAP_TLS_INSECURE', false),
151152
]
152153

153154
];

0 commit comments

Comments
 (0)