Skip to content

Commit

Permalink
fix: SSO with Jumpcloud "email_verified" field argoproj#12257 (argopr…
Browse files Browse the repository at this point in the history
…oj#12318)

Signed-off-by: Son Bui <sonbv00@gmail.com>
  • Loading branch information
sonbui00 authored and isubasinghe committed Feb 24, 2024
1 parent 02a2659 commit 26e2377
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 1 deletion.
6 changes: 5 additions & 1 deletion server/auth/types/claims.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ type Claims struct {
jwt.Claims
Groups []string `json:"groups,omitempty"`
Email string `json:"email,omitempty"`
EmailVerified bool `json:"email_verified,omitempty"`
EmailVerified bool `json:"-"`
Name string `json:"name,omitempty"`
ServiceAccountName string `json:"service_account_name,omitempty"`
ServiceAccountNamespace string `json:"service_account_namespace,omitempty"`
Expand Down Expand Up @@ -52,6 +52,10 @@ func (c *Claims) UnmarshalJSON(data []byte) error {
return err
}

if localClaim.RawClaim["email_verified"] == true || localClaim.RawClaim["email_verified"] == "true" {
localClaim.EmailVerified = true
}

*c = Claims(localClaim)
return nil
}
Expand Down
22 changes: 22 additions & 0 deletions server/auth/types/claims_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,28 @@ func TestUnmarshalJSON(t *testing.T) {
},
},
},
{
description: "email verify field as string",
data: `{"email_verified":"true"}`,
expectedErr: nil,
expectedClaims: &Claims{
RawClaim: map[string]interface{}{
"email_verified": "true",
},
EmailVerified: true,
},
},
{
description: "email verify field as bool",
data: `{"email_verified":true}`,
expectedErr: nil,
expectedClaims: &Claims{
RawClaim: map[string]interface{}{
"email_verified": true,
},
EmailVerified: true,
},
},
{
description: "unmarshal no data",
data: `{}`,
Expand Down

0 comments on commit 26e2377

Please sign in to comment.