Skip to content

Commit

Permalink
fix: npe if ldap query doesn't return attributes
Browse files Browse the repository at this point in the history
We cannot assume the LDAP server will have group attributes programmed
everytime. So handle it accordingly.
  • Loading branch information
rchincha committed Dec 20, 2023
1 parent 59f41ac commit 9c6a25a
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions pkg/api/ldap.go
Original file line number Diff line number Diff line change
Expand Up @@ -216,8 +216,11 @@ func (lc *LDAPClient) Authenticate(username, password string) (bool, map[string]
}

userDN := search.Entries[0].DN
userAttributes := search.Entries[0].Attributes[0]
userGroups := userAttributes.Values
var userGroups []string

Check failure on line 219 in pkg/api/ldap.go

View workflow job for this annotation

GitHub Actions / lint

declarations should never be cuddled (wsl)
if len(search.Entries[0].Attributes) > 0 {

Check failure on line 220 in pkg/api/ldap.go

View workflow job for this annotation

GitHub Actions / lint

only one cuddle assignment allowed before if statement (wsl)
userAttributes := search.Entries[0].Attributes[0]
userGroups = userAttributes.Values
}
user := map[string]string{}

for _, attr := range lc.Attributes {
Expand Down

0 comments on commit 9c6a25a

Please sign in to comment.