File tree 2 files changed +27
-1
lines changed
2 files changed +27
-1
lines changed Original file line number Diff line number Diff line change @@ -12,7 +12,7 @@ type Claims struct {
12
12
jwt.Claims
13
13
Groups []string `json:"groups,omitempty"`
14
14
Email string `json:"email,omitempty"`
15
- EmailVerified bool `json:"email_verified,omitempty "`
15
+ EmailVerified bool `json:"- "`
16
16
Name string `json:"name,omitempty"`
17
17
ServiceAccountName string `json:"service_account_name,omitempty"`
18
18
ServiceAccountNamespace string `json:"service_account_namespace,omitempty"`
@@ -52,6 +52,10 @@ func (c *Claims) UnmarshalJSON(data []byte) error {
52
52
return err
53
53
}
54
54
55
+ if localClaim .RawClaim ["email_verified" ] == true || localClaim .RawClaim ["email_verified" ] == "true" {
56
+ localClaim .EmailVerified = true
57
+ }
58
+
55
59
* c = Claims (localClaim )
56
60
return nil
57
61
}
Original file line number Diff line number Diff line change @@ -134,6 +134,28 @@ func TestUnmarshalJSON(t *testing.T) {
134
134
},
135
135
},
136
136
},
137
+ {
138
+ description : "email verify field as string" ,
139
+ data : `{"email_verified":"true"}` ,
140
+ expectedErr : nil ,
141
+ expectedClaims : & Claims {
142
+ RawClaim : map [string ]interface {}{
143
+ "email_verified" : "true" ,
144
+ },
145
+ EmailVerified : true ,
146
+ },
147
+ },
148
+ {
149
+ description : "email verify field as bool" ,
150
+ data : `{"email_verified":true}` ,
151
+ expectedErr : nil ,
152
+ expectedClaims : & Claims {
153
+ RawClaim : map [string ]interface {}{
154
+ "email_verified" : true ,
155
+ },
156
+ EmailVerified : true ,
157
+ },
158
+ },
137
159
{
138
160
description : "unmarshal no data" ,
139
161
data : `{}` ,
You can’t perform that action at this time.
0 commit comments