Skip to content

Commit 3852ca4

Browse files
committed
Merge remote-tracking branch 'go-gitea/main' into avatar-refactor
2 parents 7c65d1e + 123f0ae commit 3852ca4

25 files changed

+157
-29
lines changed

cmd/admin_auth_ldap.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,10 @@ var (
9393
Name: "skip-local-2fa",
9494
Usage: "Set to true to skip local 2fa for users authenticated by this source",
9595
},
96+
cli.StringFlag{
97+
Name: "avatar-attribute",
98+
Usage: "The attribute of the user’s LDAP record containing the user’s avatar.",
99+
},
96100
}
97101

98102
ldapBindDnCLIFlags = append(commonLdapCLIFlags,
@@ -234,6 +238,9 @@ func parseLdapConfig(c *cli.Context, config *ldap.Source) error {
234238
if c.IsSet("public-ssh-key-attribute") {
235239
config.AttributeSSHPublicKey = c.String("public-ssh-key-attribute")
236240
}
241+
if c.IsSet("avatar-attribute") {
242+
config.AttributeAvatar = c.String("avatar-attribute")
243+
}
237244
if c.IsSet("page-size") {
238245
config.SearchPageSize = uint32(c.Uint("page-size"))
239246
}

cmd/admin_auth_ldap_test.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ func TestAddLdapBindDn(t *testing.T) {
4545
"--surname-attribute", "sn-bind full",
4646
"--email-attribute", "mail-bind full",
4747
"--public-ssh-key-attribute", "publickey-bind full",
48+
"--avatar-attribute", "avatar-bind full",
4849
"--bind-dn", "cn=readonly,dc=full-domain-bind,dc=org",
4950
"--bind-password", "secret-bind-full",
5051
"--attributes-in-bind",
@@ -71,6 +72,7 @@ func TestAddLdapBindDn(t *testing.T) {
7172
AttributeMail: "mail-bind full",
7273
AttributesInBind: true,
7374
AttributeSSHPublicKey: "publickey-bind full",
75+
AttributeAvatar: "avatar-bind full",
7476
SearchPageSize: 99,
7577
Filter: "(memberOf=cn=user-group,ou=example,dc=full-domain-bind,dc=org)",
7678
AdminFilter: "(memberOf=cn=admin-group,ou=example,dc=full-domain-bind,dc=org)",
@@ -269,6 +271,7 @@ func TestAddLdapSimpleAuth(t *testing.T) {
269271
"--surname-attribute", "sn-simple full",
270272
"--email-attribute", "mail-simple full",
271273
"--public-ssh-key-attribute", "publickey-simple full",
274+
"--avatar-attribute", "avatar-simple full",
272275
"--user-dn", "cn=%s,ou=Users,dc=full-domain-simple,dc=org",
273276
},
274277
loginSource: &login.Source{
@@ -288,6 +291,7 @@ func TestAddLdapSimpleAuth(t *testing.T) {
288291
AttributeSurname: "sn-simple full",
289292
AttributeMail: "mail-simple full",
290293
AttributeSSHPublicKey: "publickey-simple full",
294+
AttributeAvatar: "avatar-simple full",
291295
Filter: "(&(objectClass=posixAccount)(full-simple-cn=%s))",
292296
AdminFilter: "(memberOf=cn=admin-group,ou=example,dc=full-domain-simple,dc=org)",
293297
RestrictedFilter: "(memberOf=cn=restricted-group,ou=example,dc=full-domain-simple,dc=org)",
@@ -501,6 +505,7 @@ func TestUpdateLdapBindDn(t *testing.T) {
501505
"--surname-attribute", "sn-bind full",
502506
"--email-attribute", "mail-bind full",
503507
"--public-ssh-key-attribute", "publickey-bind full",
508+
"--avatar-attribute", "avatar-bind full",
504509
"--bind-dn", "cn=readonly,dc=full-domain-bind,dc=org",
505510
"--bind-password", "secret-bind-full",
506511
"--synchronize-users",
@@ -534,6 +539,7 @@ func TestUpdateLdapBindDn(t *testing.T) {
534539
AttributeMail: "mail-bind full",
535540
AttributesInBind: false,
536541
AttributeSSHPublicKey: "publickey-bind full",
542+
AttributeAvatar: "avatar-bind full",
537543
SearchPageSize: 99,
538544
Filter: "(memberOf=cn=user-group,ou=example,dc=full-domain-bind,dc=org)",
539545
AdminFilter: "(memberOf=cn=admin-group,ou=example,dc=full-domain-bind,dc=org)",
@@ -932,6 +938,7 @@ func TestUpdateLdapSimpleAuth(t *testing.T) {
932938
"--surname-attribute", "sn-simple full",
933939
"--email-attribute", "mail-simple full",
934940
"--public-ssh-key-attribute", "publickey-simple full",
941+
"--avatar-attribute", "avatar-simple full",
935942
"--user-dn", "cn=%s,ou=Users,dc=full-domain-simple,dc=org",
936943
},
937944
id: 7,
@@ -952,6 +959,7 @@ func TestUpdateLdapSimpleAuth(t *testing.T) {
952959
AttributeSurname: "sn-simple full",
953960
AttributeMail: "mail-simple full",
954961
AttributeSSHPublicKey: "publickey-simple full",
962+
AttributeAvatar: "avatar-simple full",
955963
Filter: "(&(objectClass=posixAccount)(full-simple-cn=%s))",
956964
AdminFilter: "(memberOf=cn=admin-group,ou=example,dc=full-domain-simple,dc=org)",
957965
RestrictedFilter: "(memberOf=cn=restricted-group,ou=example,dc=full-domain-simple,dc=org)",

docs/content/doc/usage/command-line.en-us.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,7 @@ Admin operations:
152152
- `--surname-attribute value`: The attribute of the user’s LDAP record containing the user’s surname.
153153
- `--email-attribute value`: The attribute of the user’s LDAP record containing the user’s email address. Required.
154154
- `--public-ssh-key-attribute value`: The attribute of the user’s LDAP record containing the user’s public ssh key.
155+
- `--avatar-attribute value`: The attribute of the user’s LDAP record containing the user’s avatar.
155156
- `--bind-dn value`: The DN to bind to the LDAP server with when searching for the user.
156157
- `--bind-password value`: The password for the Bind DN, if any.
157158
- `--attributes-in-bind`: Fetch attributes in bind DN context.
@@ -177,6 +178,7 @@ Admin operations:
177178
- `--surname-attribute value`: The attribute of the user’s LDAP record containing the user’s surname.
178179
- `--email-attribute value`: The attribute of the user’s LDAP record containing the user’s email address.
179180
- `--public-ssh-key-attribute value`: The attribute of the user’s LDAP record containing the user’s public ssh key.
181+
- `--avatar-attribute value`: The attribute of the user’s LDAP record containing the user’s avatar.
180182
- `--bind-dn value`: The DN to bind to the LDAP server with when searching for the user.
181183
- `--bind-password value`: The password for the Bind DN, if any.
182184
- `--attributes-in-bind`: Fetch attributes in bind DN context.
@@ -202,6 +204,7 @@ Admin operations:
202204
- `--surname-attribute value`: The attribute of the user’s LDAP record containing the user’s surname.
203205
- `--email-attribute value`: The attribute of the user’s LDAP record containing the user’s email address. Required.
204206
- `--public-ssh-key-attribute value`: The attribute of the user’s LDAP record containing the user’s public ssh key.
207+
- `--avatar-attribute value`: The attribute of the user’s LDAP record containing the user’s avatar.
205208
- `--user-dn value`: The user’s DN. Required.
206209
- Examples:
207210
- `gitea admin auth add-ldap-simple --name ldap --security-protocol unencrypted --host mydomain.org --port 389 --user-dn "cn=%s,ou=Users,dc=mydomain,dc=org" --user-filter "(&(objectClass=posixAccount)(cn=%s))" --email-attribute mail`
@@ -223,6 +226,7 @@ Admin operations:
223226
- `--surname-attribute value`: The attribute of the user’s LDAP record containing the user’s surname.
224227
- `--email-attribute value`: The attribute of the user’s LDAP record containing the user’s email address.
225228
- `--public-ssh-key-attribute value`: The attribute of the user’s LDAP record containing the user’s public ssh key.
229+
- `--avatar-attribute value`: The attribute of the user’s LDAP record containing the user’s avatar.
226230
- `--user-dn value`: The user’s DN.
227231
- Examples:
228232
- `gitea admin auth update-ldap-simple --id 1 --name "my ldap auth source"`

models/user_avatar.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,15 @@ func (u *User) UploadAvatar(data []byte) error {
132132
return sess.Commit()
133133
}
134134

135+
// IsUploadAvatarChanged returns true if the current user's avatar would be changed with the provided data
136+
func (u *User) IsUploadAvatarChanged(data []byte) bool {
137+
if !u.UseCustomAvatar || len(u.Avatar) == 0 {
138+
return true
139+
}
140+
avatarID := fmt.Sprintf("%x", md5.Sum([]byte(fmt.Sprintf("%d-%x", u.ID, md5.Sum(data)))))
141+
return u.Avatar != avatarID
142+
}
143+
135144
// DeleteAvatar deletes the user's custom avatar.
136145
func (u *User) DeleteAvatar() error {
137146
aPath := u.CustomAvatarRelativePath()

modules/git/repo.go

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -425,14 +425,24 @@ func (repo *Repository) CreateBundle(ctx context.Context, commit string, out io.
425425
}
426426
defer os.RemoveAll(tmp)
427427

428-
tmpFile := filepath.Join(tmp, "bundle")
429-
args := []string{
430-
"bundle",
431-
"create",
432-
tmpFile,
433-
commit,
428+
env := append(os.Environ(), "GIT_OBJECT_DIRECTORY="+filepath.Join(repo.Path, "objects"))
429+
_, err = NewCommandContext(ctx, "init", "--bare").RunInDirWithEnv(tmp, env)
430+
if err != nil {
431+
return err
432+
}
433+
434+
_, err = NewCommandContext(ctx, "reset", "--soft", commit).RunInDirWithEnv(tmp, env)
435+
if err != nil {
436+
return err
434437
}
435-
_, err = NewCommandContext(ctx, args...).RunInDir(repo.Path)
438+
439+
_, err = NewCommandContext(ctx, "branch", "-m", "bundle").RunInDirWithEnv(tmp, env)
440+
if err != nil {
441+
return err
442+
}
443+
444+
tmpFile := filepath.Join(tmp, "bundle")
445+
_, err = NewCommandContext(ctx, "bundle", "create", tmpFile, "bundle", "HEAD").RunInDirWithEnv(tmp, env)
436446
if err != nil {
437447
return err
438448
}

options/locale/locale_en-US.ini

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2421,6 +2421,7 @@ auths.attribute_name = First Name Attribute
24212421
auths.attribute_surname = Surname Attribute
24222422
auths.attribute_mail = Email Attribute
24232423
auths.attribute_ssh_public_key = Public SSH Key Attribute
2424+
auths.attribute_avatar = Avatar Attribute
24242425
auths.attributes_in_bind = Fetch Attributes in Bind DN Context
24252426
auths.allow_deactivate_all = Allow an empty search result to deactivate all users
24262427
auths.use_paged_search = Use Paged Search

options/locale/locale_ru-RU.ini

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -508,7 +508,7 @@ public_profile=Открытый профиль
508508
biography_placeholder=Расскажите немного о себе
509509
profile_desc=Ваш адрес электронной почты будет использован для уведомлений и других операций.
510510
password_username_disabled=Нелокальным пользователям запрещено изменение их имени пользователя. Для получения более подробной информации обратитесь к администратору сайта.
511-
full_name=ФИО
511+
full_name=Имя и фамилия
512512
website=Веб-сайт
513513
location=Местоположение
514514
update_theme=Обновить тему
@@ -1202,8 +1202,8 @@ pulls.merged_by_fake=слито %[1]s пользователем %[2]s
12021202
issues.closed_by=закрыт %[1]s пользователем <a href="%[2]s">%[3]s</a>
12031203
issues.opened_by_fake=открыт %[1]s пользователем %[2]s
12041204
issues.closed_by_fake=закрыт %[1]s пользователем %[2]s
1205-
issues.previous=Предыдущая страница
1206-
issues.next=Следующая страница
1205+
issues.previous=Предыдущая
1206+
issues.next=Следующая
12071207
issues.open_title=Открыто
12081208
issues.closed_title=Закрыто
12091209
issues.num_comments=комментариев: %d

routers/web/admin/auths.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,7 @@ func parseLDAPConfig(form forms.AuthenticationForm) *ldap.Source {
136136
AttributeMail: form.AttributeMail,
137137
AttributesInBind: form.AttributesInBind,
138138
AttributeSSHPublicKey: form.AttributeSSHPublicKey,
139+
AttributeAvatar: form.AttributeAvatar,
139140
SearchPageSize: pageSize,
140141
Filter: form.Filter,
141142
GroupsEnabled: form.GroupsEnabled,
@@ -161,6 +162,7 @@ func parseSMTPConfig(form forms.AuthenticationForm) *smtp.Source {
161162
SkipVerify: form.SkipVerify,
162163
HeloHostname: form.HeloHostname,
163164
DisableHelo: form.DisableHelo,
165+
SkipLocalTwoFA: form.SkipLocalTwoFA,
164166
}
165167
}
166168

@@ -244,8 +246,9 @@ func NewAuthSourcePost(ctx *context.Context) {
244246
hasTLS = true
245247
case login.PAM:
246248
config = &pamService.Source{
247-
ServiceName: form.PAMServiceName,
248-
EmailDomain: form.PAMEmailDomain,
249+
ServiceName: form.PAMServiceName,
250+
EmailDomain: form.PAMEmailDomain,
251+
SkipLocalTwoFA: form.SkipLocalTwoFA,
249252
}
250253
case login.OAuth2:
251254
config = parseOAuth2Config(form)

routers/web/user/setting/keys.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ func DeleteKey(ctx *context.Context) {
209209
return
210210
}
211211
if external {
212-
ctx.Flash.Error(ctx.Tr("setting.ssh_externally_managed"))
212+
ctx.Flash.Error(ctx.Tr("settings.ssh_externally_managed"))
213213
ctx.Redirect(setting.AppSubURL + "/user/settings/keys")
214214
return
215215
}

routers/web/user/setting/security_twofa.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ func RegenerateScratchTwoFactor(ctx *context.Context) {
3232
t, err := login.GetTwoFactorByUID(ctx.User.ID)
3333
if err != nil {
3434
if login.IsErrTwoFactorNotEnrolled(err) {
35-
ctx.Flash.Error(ctx.Tr("setting.twofa_not_enrolled"))
35+
ctx.Flash.Error(ctx.Tr("settings.twofa_not_enrolled"))
3636
ctx.Redirect(setting.AppSubURL + "/user/settings/security")
3737
}
3838
ctx.ServerError("SettingsTwoFactor: Failed to GetTwoFactorByUID", err)
@@ -62,7 +62,7 @@ func DisableTwoFactor(ctx *context.Context) {
6262
t, err := login.GetTwoFactorByUID(ctx.User.ID)
6363
if err != nil {
6464
if login.IsErrTwoFactorNotEnrolled(err) {
65-
ctx.Flash.Error(ctx.Tr("setting.twofa_not_enrolled"))
65+
ctx.Flash.Error(ctx.Tr("settings.twofa_not_enrolled"))
6666
ctx.Redirect(setting.AppSubURL + "/user/settings/security")
6767
}
6868
ctx.ServerError("SettingsTwoFactor: Failed to GetTwoFactorByUID", err)
@@ -150,7 +150,7 @@ func EnrollTwoFactor(ctx *context.Context) {
150150
if t != nil {
151151
// already enrolled - we should redirect back!
152152
log.Warn("Trying to re-enroll %-v in twofa when already enrolled", ctx.User)
153-
ctx.Flash.Error(ctx.Tr("setting.twofa_is_enrolled"))
153+
ctx.Flash.Error(ctx.Tr("settings.twofa_is_enrolled"))
154154
ctx.Redirect(setting.AppSubURL + "/user/settings/security")
155155
return
156156
}
@@ -175,7 +175,7 @@ func EnrollTwoFactorPost(ctx *context.Context) {
175175
t, err := login.GetTwoFactorByUID(ctx.User.ID)
176176
if t != nil {
177177
// already enrolled
178-
ctx.Flash.Error(ctx.Tr("setting.twofa_is_enrolled"))
178+
ctx.Flash.Error(ctx.Tr("settings.twofa_is_enrolled"))
179179
ctx.Redirect(setting.AppSubURL + "/user/settings/security")
180180
return
181181
}

services/archiver/archiver.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -136,9 +136,11 @@ func doArchive(r *ArchiveRequest) (*models.RepoArchiver, error) {
136136
if err == nil {
137137
if archiver.Status == models.RepoArchiverGenerating {
138138
archiver.Status = models.RepoArchiverReady
139-
return archiver, models.UpdateRepoArchiverStatus(ctx, archiver)
139+
if err = models.UpdateRepoArchiverStatus(ctx, archiver); err != nil {
140+
return nil, err
141+
}
140142
}
141-
return archiver, nil
143+
return archiver, committer.Commit()
142144
}
143145

144146
if !errors.Is(err, os.ErrNotExist) {

services/auth/source/ldap/source.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ type Source struct {
4242
AttributeMail string // E-mail attribute
4343
AttributesInBind bool // fetch attributes in bind context (not user)
4444
AttributeSSHPublicKey string // LDAP SSH Public Key attribute
45+
AttributeAvatar string
4546
SearchPageSize uint32 // Search with paging page size
4647
Filter string // Query filter to validate entry
4748
AdminFilter string // Query filter to check if user is admin
@@ -53,7 +54,7 @@ type Source struct {
5354
GroupFilter string // Group Name Filter
5455
GroupMemberUID string // Group Attribute containing array of UserUID
5556
UserUID string // User Attribute listed in Group
56-
SkipLocalTwoFA bool // Skip Local 2fa for users authenticated with this source
57+
SkipLocalTwoFA bool `json:",omitempty"` // Skip Local 2fa for users authenticated with this source
5758

5859
// reference to the loginSource
5960
loginSource *login.Source

services/auth/source/ldap/source_authenticate.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,10 @@ func (source *Source) Authenticate(user *models.User, userName, password string)
9696
err = models.RewriteAllPublicKeys()
9797
}
9898

99+
if err == nil && len(source.AttributeAvatar) > 0 {
100+
_ = user.UploadAvatar(sr.Avatar)
101+
}
102+
99103
return user, err
100104
}
101105

services/auth/source/ldap/source_search.go

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ type SearchResult struct {
2727
IsAdmin bool // if user is administrator
2828
IsRestricted bool // if user is restricted
2929
LowerName string // Lowername
30+
Avatar []byte
3031
}
3132

3233
func (ls *Source) sanitizedUserQuery(username string) (string, bool) {
@@ -266,7 +267,8 @@ func (ls *Source) SearchEntry(name, passwd string, directBind bool) *SearchResul
266267
return nil
267268
}
268269

269-
var isAttributeSSHPublicKeySet = len(strings.TrimSpace(ls.AttributeSSHPublicKey)) > 0
270+
isAttributeSSHPublicKeySet := len(strings.TrimSpace(ls.AttributeSSHPublicKey)) > 0
271+
isAtributeAvatarSet := len(strings.TrimSpace(ls.AttributeAvatar)) > 0
270272

271273
attribs := []string{ls.AttributeUsername, ls.AttributeName, ls.AttributeSurname, ls.AttributeMail}
272274
if len(strings.TrimSpace(ls.UserUID)) > 0 {
@@ -275,8 +277,11 @@ func (ls *Source) SearchEntry(name, passwd string, directBind bool) *SearchResul
275277
if isAttributeSSHPublicKeySet {
276278
attribs = append(attribs, ls.AttributeSSHPublicKey)
277279
}
280+
if isAtributeAvatarSet {
281+
attribs = append(attribs, ls.AttributeAvatar)
282+
}
278283

279-
log.Trace("Fetching attributes '%v', '%v', '%v', '%v', '%v', '%v' with filter '%s' and base '%s'", ls.AttributeUsername, ls.AttributeName, ls.AttributeSurname, ls.AttributeMail, ls.AttributeSSHPublicKey, ls.UserUID, userFilter, userDN)
284+
log.Trace("Fetching attributes '%v', '%v', '%v', '%v', '%v', '%v', '%v' with filter '%s' and base '%s'", ls.AttributeUsername, ls.AttributeName, ls.AttributeSurname, ls.AttributeMail, ls.AttributeSSHPublicKey, ls.AttributeAvatar, ls.UserUID, userFilter, userDN)
280285
search := ldap.NewSearchRequest(
281286
userDN, ldap.ScopeWholeSubtree, ldap.NeverDerefAliases, 0, 0, false, userFilter,
282287
attribs, nil)
@@ -296,6 +301,7 @@ func (ls *Source) SearchEntry(name, passwd string, directBind bool) *SearchResul
296301
}
297302

298303
var sshPublicKey []string
304+
var Avatar []byte
299305

300306
username := sr.Entries[0].GetAttributeValue(ls.AttributeUsername)
301307
firstname := sr.Entries[0].GetAttributeValue(ls.AttributeName)
@@ -363,6 +369,10 @@ func (ls *Source) SearchEntry(name, passwd string, directBind bool) *SearchResul
363369
}
364370
}
365371

372+
if isAtributeAvatarSet {
373+
Avatar = sr.Entries[0].GetRawAttributeValue(ls.AttributeAvatar)
374+
}
375+
366376
return &SearchResult{
367377
LowerName: strings.ToLower(username),
368378
Username: username,
@@ -372,6 +382,7 @@ func (ls *Source) SearchEntry(name, passwd string, directBind bool) *SearchResul
372382
SSHPublicKey: sshPublicKey,
373383
IsAdmin: isAdmin,
374384
IsRestricted: isRestricted,
385+
Avatar: Avatar,
375386
}
376387
}
377388

@@ -403,14 +414,18 @@ func (ls *Source) SearchEntries() ([]*SearchResult, error) {
403414

404415
userFilter := fmt.Sprintf(ls.Filter, "*")
405416

406-
var isAttributeSSHPublicKeySet = len(strings.TrimSpace(ls.AttributeSSHPublicKey)) > 0
417+
isAttributeSSHPublicKeySet := len(strings.TrimSpace(ls.AttributeSSHPublicKey)) > 0
418+
isAtributeAvatarSet := len(strings.TrimSpace(ls.AttributeAvatar)) > 0
407419

408420
attribs := []string{ls.AttributeUsername, ls.AttributeName, ls.AttributeSurname, ls.AttributeMail}
409421
if isAttributeSSHPublicKeySet {
410422
attribs = append(attribs, ls.AttributeSSHPublicKey)
411423
}
424+
if isAtributeAvatarSet {
425+
attribs = append(attribs, ls.AttributeAvatar)
426+
}
412427

413-
log.Trace("Fetching attributes '%v', '%v', '%v', '%v', '%v' with filter %s and base %s", ls.AttributeUsername, ls.AttributeName, ls.AttributeSurname, ls.AttributeMail, ls.AttributeSSHPublicKey, userFilter, ls.UserBase)
428+
log.Trace("Fetching attributes '%v', '%v', '%v', '%v', '%v', '%v' with filter %s and base %s", ls.AttributeUsername, ls.AttributeName, ls.AttributeSurname, ls.AttributeMail, ls.AttributeSSHPublicKey, ls.AttributeAvatar, userFilter, ls.UserBase)
414429
search := ldap.NewSearchRequest(
415430
ls.UserBase, ldap.ScopeWholeSubtree, ldap.NeverDerefAliases, 0, 0, false, userFilter,
416431
attribs, nil)
@@ -442,8 +457,10 @@ func (ls *Source) SearchEntries() ([]*SearchResult, error) {
442457
if isAttributeSSHPublicKeySet {
443458
result[i].SSHPublicKey = v.GetAttributeValues(ls.AttributeSSHPublicKey)
444459
}
460+
if isAtributeAvatarSet {
461+
result[i].Avatar = v.GetRawAttributeValue(ls.AttributeAvatar)
462+
}
445463
result[i].LowerName = strings.ToLower(result[i].Username)
446-
447464
}
448465

449466
return result, nil

0 commit comments

Comments
 (0)