Skip to content

Commit

Permalink
Merge pull request #1888 from VF-mbrauer/UPN-Lowercase
Browse files Browse the repository at this point in the history
Added the possibility to activate lowercase for UPN-Strings
  • Loading branch information
sagikazarmark authored Jan 6, 2021
2 parents fc7f1ef + 0d53fa2 commit ee50c09
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions connector/microsoft/microsoft.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"fmt"
"io"
"net/http"
"strings"
"sync"
"time"

Expand Down Expand Up @@ -51,6 +52,7 @@ type Config struct {
Groups []string `json:"groups"`
GroupNameFormat GroupNameFormat `json:"groupNameFormat"`
UseGroupsAsWhitelist bool `json:"useGroupsAsWhitelist"`
EmailToLowercase bool `json:"emailToLowercase"`
}

// Open returns a strategy for logging in through Microsoft.
Expand All @@ -67,6 +69,7 @@ func (c *Config) Open(id string, logger log.Logger) (connector.Connector, error)
groupNameFormat: c.GroupNameFormat,
useGroupsAsWhitelist: c.UseGroupsAsWhitelist,
logger: logger,
emailToLowercase: c.EmailToLowercase,
}
// By default allow logins from both personal and business/school
// accounts.
Expand Down Expand Up @@ -109,6 +112,7 @@ type microsoftConnector struct {
groups []string
useGroupsAsWhitelist bool
logger log.Logger
emailToLowercase bool
}

func (c *microsoftConnector) isOrgTenant() bool {
Expand Down Expand Up @@ -171,6 +175,10 @@ func (c *microsoftConnector) HandleCallback(s connector.Scopes, r *http.Request)
return identity, fmt.Errorf("microsoft: get user: %v", err)
}

if c.emailToLowercase {
user.Email = strings.ToLower(user.Email)
}

identity = connector.Identity{
UserID: user.ID,
Username: user.Name,
Expand Down

0 comments on commit ee50c09

Please sign in to comment.