Skip to content

Commit

Permalink
fix: SSO with Jumpcloud "email_verified" field #12257 (#12318)
Browse files Browse the repository at this point in the history
Signed-off-by: Son Bui <sonbv00@gmail.com>
Signed-off-by: Isitha Subasinghe <isubasinghe@student.unimelb.edu.au>
  • Loading branch information
sonbui00 authored and isubasinghe committed Feb 28, 2024
1 parent 16c4970 commit d4d28b5
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 d4d28b5

Please sign in to comment.