Skip to content

NOW MANAGED ON CODEBERG

Merge branch 'master' of https://github.com/jasonhoule/BookStack into jasonhoule-master

Dan Brown85db812feaae
diff --cc app/Auth/Access/Guards/LdapSessionGuard.php
index cabbfbbcb,f67c04f82..a9802054a
--- a/app/Auth/Access/Guards/LdapSessionGuard.php
+++ b/app/Auth/Access/Guards/LdapSessionGuard.php
@@@ -115,6 -117,17 +115,16 @@@ class LdapSessionGuard extends External
'password' => Str::random(32),
];
- return $this->registrationService->registerUser($details, null, false);
+ $user = $this->registrationService->registerUser($details, null, false);
+
+ if (config('services.ldap.import_thumbnail_photos')) {
+ $imageService = app()->make(ImageService::class);
+ $image = $imageService->saveNewFromBase64Uri('data:image/jpg;base64,'.base64_encode($ldapUserDetails['avatar']), $ldapUserDetails['uid'].'.jpg', 'user');
+
+ $user['image_id'] = $image->id;
+ $user->save();
+ }
+
+ return $user;
}
-
}
diff --cc app/Auth/Access/LdapService.php
index a438c0984,a7ee3b374..c5b586b4d
--- a/app/Auth/Access/LdapService.php
+++ b/app/Auth/Access/LdapService.php
@@@ -85,10 -86,11 +86,11 @@@ class LdapService extends ExternalAuthS
$userCn = $this->getUserResponseProperty($user, 'cn', null);
$formatted = [
- 'uid' => $this->getUserResponseProperty($user, $idAttr, $user['dn']),
- 'name' => $this->getUserResponseProperty($user, $displayNameAttr, $userCn),
- 'dn' => $user['dn'],
+ 'uid' => $this->getUserResponseProperty($user, $idAttr, $user['dn']),
+ 'name' => $this->getUserResponseProperty($user, $displayNameAttr, $userCn),
+ 'dn' => $user['dn'],
'email' => $this->getUserResponseProperty($user, $emailAttr, null),
+ 'avatar'=> $this->getUserResponseProperty($user, $thumbnailAttr, null),
];
if ($this->config['dump_user_details']) {
diff --cc app/Config/services.php
index 699339614,230234e4c..7fac1f51c
--- a/app/Config/services.php
+++ b/app/Config/services.php
@@@ -132,7 -132,8 +132,9 @@@ return
'group_attribute' => env('LDAP_GROUP_ATTRIBUTE', 'memberOf'),
'remove_from_groups' => env('LDAP_REMOVE_FROM_GROUPS', false),
'tls_insecure' => env('LDAP_TLS_INSECURE', false),
+ 'start_tls' => env('LDAP_START_TLS', false),
+ 'import_thumbnail_photos' => env('LDAP_IMPORT_THUMBNAIL_PHOTOS', false),
+ 'thumbnail_attribute' => env('LDAP_THUMBNAIL_ATTRIBUTE', 'thumbnailPhoto'),
],
];