X-Git-Url: http://source.bookstackapp.com/bookstack/blobdiff_plain/41438adbd1dbe8688ff8ff7d3dbb835d1e9650e1..refs/pull/3391/head:/app/Auth/Access/LdapService.php diff --git a/app/Auth/Access/LdapService.php b/app/Auth/Access/LdapService.php index ddd6ada97..2540fe2d8 100644 --- a/app/Auth/Access/LdapService.php +++ b/app/Auth/Access/LdapService.php @@ -15,12 +15,17 @@ use Illuminate\Support\Facades\Log; */ class LdapService { - protected $ldap; - protected $groupSyncService; + protected Ldap $ldap; + protected GroupSyncService $groupSyncService; + protected UserAvatars $userAvatars; + + /** + * @var resource + */ protected $ldapConnection; - protected $userAvatars; - protected $config; - protected $enabled; + + protected array $config; + protected bool $enabled; /** * LdapService constructor. @@ -165,7 +170,7 @@ class LdapService * Bind the system user to the LDAP connection using the given credentials * otherwise anonymous access is attempted. * - * @param $connection + * @param resource $connection * * @throws LdapException */ @@ -274,6 +279,7 @@ class LdapService * Get the groups a user is a part of on ldap. * * @throws LdapException + * @throws JsonDebugException */ public function getUserGroups(string $userName): array { @@ -285,7 +291,17 @@ class LdapService } $userGroups = $this->groupFilter($user); - return $this->getGroupsRecursive($userGroups, []); + $allGroups = $this->getGroupsRecursive($userGroups, []); + + if ($this->config['dump_user_groups']) { + throw new JsonDebugException([ + 'details_from_ldap' => $user, + 'parsed_direct_user_groups' => $userGroups, + 'parsed_recursive_user_groups' => $allGroups, + ]); + } + + return $allGroups; } /** @@ -368,6 +384,7 @@ class LdapService * Sync the LDAP groups to the user roles for the current user. * * @throws LdapException + * @throws JsonDebugException */ public function syncGroups(User $user, string $username) {