]> BookStack Code Mirror - bookstack/commitdiff
Merge branch 'master' of https://github.com/jasonhoule/BookStack into jasonhoule...
authorDan Brown <redacted>
Mon, 24 May 2021 16:06:50 +0000 (17:06 +0100)
committerDan Brown <redacted>
Mon, 24 May 2021 16:06:50 +0000 (17:06 +0100)
1  2 
app/Auth/Access/Guards/LdapSessionGuard.php
app/Auth/Access/LdapService.php
app/Config/services.php

index cabbfbbcbb7ac17065f0446fec76af95d9a362a0,f67c04f8224d82072aa0cfc9fc765e18670df40f..a9802054a5889c4e28f6905b469eef5f4b2b168c
@@@ -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;
      }
 -
  }
index a438c098490586f44f06b607ff15892e726b60d9,a7ee3b37474d333cbeec37e1db71b8bcb73e2a8a..c5b586b4dcb8c36c6dbb7d41124f9718e47b9c70
@@@ -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']) {
index 6993396147af9b02eec0a778c81b7bb83a6764c3,230234e4c3e43a6d7a6979528efa3429f658ecf7..7fac1f51cfa4ee0b9d3743c733e64b776c6c377d
@@@ -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'),
      ],
  
  ];
Morty Proxy This is a proxified and sanitized view of the page, visit original site.