From 791ffe2fd94f31ed2b428b3235585e353998c550 Mon Sep 17 00:00:00 2001 From: madsi1m <11512591+madsi1m@users.noreply.github.com> Date: Thu, 5 Dec 2019 21:09:24 +1100 Subject: [PATCH] Ldap fix (#412) * fixed missing username for ldap * play with lint --- CONTRIBUTORS.md | 1 + pkg/auth/manager/ldap/ldap.go | 4 ++-- pkg/user/manager/ldap/ldap.go | 6 ++++-- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md index fde2dbd4f1..b0e782c1da 100644 --- a/CONTRIBUTORS.md +++ b/CONTRIBUTORS.md @@ -7,4 +7,5 @@ - Hugo Gonzalez Labrador - Ilja Neumann - Jörn Friedrich Dreyer +- Michael D'Silva - Mohitty diff --git a/pkg/auth/manager/ldap/ldap.go b/pkg/auth/manager/ldap/ldap.go index 6f850b0540..2bcb54edfd 100644 --- a/pkg/auth/manager/ldap/ldap.go +++ b/pkg/auth/manager/ldap/ldap.go @@ -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"` } @@ -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 } diff --git a/pkg/user/manager/ldap/ldap.go b/pkg/user/manager/ldap/ldap.go index 842bfad699..6fd72028f2 100644 --- a/pkg/user/manager/ldap/ldap.go +++ b/pkg/user/manager/ldap/ldap.go @@ -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, @@ -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) {