Skip to content

Commit

Permalink
Ldap fix (#412)
Browse files Browse the repository at this point in the history
* fixed missing username for ldap

* play with lint
  • Loading branch information
madsi1m authored and labkode committed Dec 5, 2019
1 parent cbf238c commit 791ffe2
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
1 change: 1 addition & 0 deletions CONTRIBUTORS.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@
- Hugo Gonzalez Labrador <github@hugo.labkode.com>
- Ilja Neumann <ineumann@owncloud.com>
- Jörn Friedrich Dreyer <jfd@butonic.de>
- Michael D'Silva <michael.dsilva@aarnet.edu.au>
- Mohitty <mohitt@iitk.ac.in>
4 changes: 2 additions & 2 deletions pkg/auth/manager/ldap/ldap.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ type config struct {
type attributes struct {
DN string `mapstructure:"dn"`
UID string `mapstructure:"uid"`
UserName string `mapstructure:"userName"`
Mail string `mapstructure:"mail"`
DisplayName string `mapstructure:"displayName"`
}
Expand Down Expand Up @@ -141,12 +140,13 @@ func (am *mgr) Authenticate(ctx context.Context, clientID, clientSecret string)
OpaqueId: sr.Entries[0].GetAttributeValue(am.c.Schema.UID),
},
// TODO add more claims from the StandardClaims, eg EmailVerified
Username: sr.Entries[0].GetAttributeValue(am.c.Schema.UserName),
Username: sr.Entries[0].GetAttributeValue(am.c.Schema.UID),
// TODO groups
Groups: []string{},
Mail: sr.Entries[0].GetAttributeValue(am.c.Schema.Mail),
DisplayName: sr.Entries[0].GetAttributeValue(am.c.Schema.DisplayName),
}

return u, nil

}
6 changes: 4 additions & 2 deletions pkg/user/manager/ldap/ldap.go
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ func (m *manager) GetUser(ctx context.Context, uid *userpb.UserId) (*userpb.User

log.Debug().Interface("entries", sr.Entries).Msg("entries")

return &userpb.User{
u := &userpb.User{
Id: &userpb.UserId{
Idp: m.idp,
OpaqueId: uid.OpaqueId,
Expand All @@ -148,7 +148,9 @@ func (m *manager) GetUser(ctx context.Context, uid *userpb.UserId) (*userpb.User
Groups: []string{},
Mail: sr.Entries[0].GetAttributeValue(m.schema.Mail),
DisplayName: sr.Entries[0].GetAttributeValue(m.schema.DisplayName),
}, nil
}

return u, nil
}

func (m *manager) FindUsers(ctx context.Context, query string) ([]*userpb.User, error) {
Expand Down

0 comments on commit 791ffe2

Please sign in to comment.