lowercase DisplayName attributes when reading SSO response (#12545)
this is to accommodate providers like [Okta][1] that send the user's full name as an attribute named `displayName` [1]: https://developer.okta.com/docs/reference/api/users/#default-profile-properties
This commit is contained in:
@@ -0,0 +1 @@
|
||||
- Ignore casing in SAML response for display name. For example the display name attribute can be provided now as `displayname` or `displayName`.
|
||||
@@ -6,6 +6,7 @@ import (
|
||||
"encoding/xml"
|
||||
"errors"
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
"github.com/fleetdm/fleet/v4/server/fleet"
|
||||
)
|
||||
@@ -108,7 +109,7 @@ func (r resp) UserID() string {
|
||||
func (r resp) UserDisplayName() string {
|
||||
if r.response != nil {
|
||||
for _, attr := range r.response.Assertion.AttributeStatement.Attributes {
|
||||
if _, ok := validDisplayNameAttrs[attr.Name]; ok {
|
||||
if _, ok := validDisplayNameAttrs[strings.ToLower(attr.Name)]; ok {
|
||||
for _, v := range attr.AttributeValues {
|
||||
if v.Value != "" {
|
||||
return v.Value
|
||||
|
||||
@@ -508,6 +508,7 @@ func TestUserDisplayName(t *testing.T) {
|
||||
}{
|
||||
{"name", []AttributeValue{{Value: "Name Surname"}}, "Name Surname"},
|
||||
{"displayname", []AttributeValue{{Value: "Name Surname"}}, "Name Surname"},
|
||||
{"displayName", []AttributeValue{{Value: "Name Surname"}}, "Name Surname"},
|
||||
{"cn", []AttributeValue{{Value: "Name Surname"}}, "Name Surname"},
|
||||
{"urn:oid:2.5.4.3", []AttributeValue{{Value: "Name Surname"}}, "Name Surname"},
|
||||
{"http://schemas.xmlsoap.org/ws/2005/05/identity/claims/name", []AttributeValue{{Value: "Name Surname"}}, "Name Surname"},
|
||||
|
||||
Reference in New Issue
Block a user