]> BookStack Code Mirror - bookstack/commitdiff
Fixed LDAP group sync using wrong user filter
authorDan Brown <redacted>
Sun, 19 Aug 2018 14:24:42 +0000 (15:24 +0100)
committerDan Brown <redacted>
Sun, 19 Aug 2018 14:24:42 +0000 (15:24 +0100)
LDAP group sync was trying to find users based on the external_auth_id
which is not garunteed to match the username entered so somtimes
the search for a user would fail.

This passes the username to the group sync.
Picked up by @yoyokko in #959.

app/Http/Controllers/Auth/LoginController.php
app/Services/LdapService.php

index 791c265ad3b0a838491bb02f44f0d205e156bbe7..c0541c9e29c4c78fa32ef4197d5f7257e06eff3f 100644 (file)
@@ -103,7 +103,7 @@ class LoginController extends Controller
 
         // Sync LDAP groups if required
         if ($this->ldapService->shouldSyncGroups()) {
-            $this->ldapService->syncGroups($user);
+            $this->ldapService->syncGroups($user, $request->get($this->username()));
         }
 
         $path = session()->pull('url.intended', '/');
index c11094aa9f6bdc08855cdaf2bed91134f9657b9f..11223433bd113041a8edd3138d92dbd6445ef867 100644 (file)
@@ -299,11 +299,12 @@ class LdapService
     /**
      * Sync the LDAP groups to the user roles for the current user
      * @param \BookStack\User $user
+     * @param string $username
      * @throws LdapException
      */
-    public function syncGroups(User $user)
+    public function syncGroups(User $user, string $username)
     {
-        $userLdapGroups = $this->getUserGroups($user->external_auth_id);
+        $userLdapGroups = $this->getUserGroups($username);
 
         // Get the ids for the roles from the names
         $ldapGroupsAsRoles = $this->matchLdapGroupsToSystemsRoles($userLdapGroups);