Skip to content

Commit 0da1691

Browse files
authored
Using jwt's native ErrInvalidType instead of json.UnsupportedTypeError (#316)
Previously, when parsing claim values, we used `json.UnsupportedTypeError` to denote if a claim string value is not of the correct type. However, this could lead to panics if a nil value is present and the `Error` function of the `json.UnsupportedTypeError` is called, which does not check for nil types. Instead, we just now use `ErrInvalidType` similar to the map claims. Fixes #315
1 parent 5e00fbc commit 0da1691

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

types.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import (
44
"encoding/json"
55
"fmt"
66
"math"
7-
"reflect"
87
"strconv"
98
"time"
109
)
@@ -121,14 +120,14 @@ func (s *ClaimStrings) UnmarshalJSON(data []byte) (err error) {
121120
for _, vv := range v {
122121
vs, ok := vv.(string)
123122
if !ok {
124-
return &json.UnsupportedTypeError{Type: reflect.TypeOf(vv)}
123+
return ErrInvalidType
125124
}
126125
aud = append(aud, vs)
127126
}
128127
case nil:
129128
return nil
130129
default:
131-
return &json.UnsupportedTypeError{Type: reflect.TypeOf(v)}
130+
return ErrInvalidType
132131
}
133132

134133
*s = aud

0 commit comments

Comments
 (0)