Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

return groups and allow insecure ldap #10

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
issue #8: ignore case when getting groups
  • Loading branch information
Rajat Jindal committed Oct 5, 2017
commit 8355c46f47f746a5cce31938412d035ece275df6
7 changes: 5 additions & 2 deletions auth/token_issuer.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
goldap "github.com/go-ldap/ldap"
"github.com/golang/glog"
"strings"
"regexp"
)

// LDAPTokenIssuer issues cryptographically secure tokens after authenticating the
Expand Down Expand Up @@ -53,11 +54,13 @@ func (lti *LDAPTokenIssuer) getGroupsFromMembersOf(membersOf []string) []string
groupsOf := []string {}
uniqueGroups := make(map[string]struct{})

re := regexp.MustCompile(`(?i)CN=`)

for _, memberOf := range membersOf {
splitted_str := strings.Split(memberOf, ",")
for _, element := range splitted_str {
if strings.Contains(element, "CN=") {
group := strings.Replace(element, "CN=", "", -1)
if strings.Contains(strings.ToUpper(element), "CN=") {
group := re.ReplaceAllString(element, "")

if _, ok := uniqueGroups[group]; !ok {
groupsOf = append(groupsOf, group)
Expand Down