Merge pull request #1888 from VF-mbrauer/UPN-Lowercase
Added the possibility to activate lowercase for UPN-Strings
This commit is contained in:
commit
ee50c09313
1 changed files with 8 additions and 0 deletions
|
@ -9,6 +9,7 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
"strings"
|
||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
@ -51,6 +52,7 @@ type Config struct {
|
||||||
Groups []string `json:"groups"`
|
Groups []string `json:"groups"`
|
||||||
GroupNameFormat GroupNameFormat `json:"groupNameFormat"`
|
GroupNameFormat GroupNameFormat `json:"groupNameFormat"`
|
||||||
UseGroupsAsWhitelist bool `json:"useGroupsAsWhitelist"`
|
UseGroupsAsWhitelist bool `json:"useGroupsAsWhitelist"`
|
||||||
|
EmailToLowercase bool `json:"emailToLowercase"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// Open returns a strategy for logging in through Microsoft.
|
// Open returns a strategy for logging in through Microsoft.
|
||||||
|
@ -67,6 +69,7 @@ func (c *Config) Open(id string, logger log.Logger) (connector.Connector, error)
|
||||||
groupNameFormat: c.GroupNameFormat,
|
groupNameFormat: c.GroupNameFormat,
|
||||||
useGroupsAsWhitelist: c.UseGroupsAsWhitelist,
|
useGroupsAsWhitelist: c.UseGroupsAsWhitelist,
|
||||||
logger: logger,
|
logger: logger,
|
||||||
|
emailToLowercase: c.EmailToLowercase,
|
||||||
}
|
}
|
||||||
// By default allow logins from both personal and business/school
|
// By default allow logins from both personal and business/school
|
||||||
// accounts.
|
// accounts.
|
||||||
|
@ -109,6 +112,7 @@ type microsoftConnector struct {
|
||||||
groups []string
|
groups []string
|
||||||
useGroupsAsWhitelist bool
|
useGroupsAsWhitelist bool
|
||||||
logger log.Logger
|
logger log.Logger
|
||||||
|
emailToLowercase bool
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *microsoftConnector) isOrgTenant() bool {
|
func (c *microsoftConnector) isOrgTenant() bool {
|
||||||
|
@ -171,6 +175,10 @@ func (c *microsoftConnector) HandleCallback(s connector.Scopes, r *http.Request)
|
||||||
return identity, fmt.Errorf("microsoft: get user: %v", err)
|
return identity, fmt.Errorf("microsoft: get user: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if c.emailToLowercase {
|
||||||
|
user.Email = strings.ToLower(user.Email)
|
||||||
|
}
|
||||||
|
|
||||||
identity = connector.Identity{
|
identity = connector.Identity{
|
||||||
UserID: user.ID,
|
UserID: user.ID,
|
||||||
Username: user.Name,
|
Username: user.Name,
|
||||||
|
|
Reference in a new issue