refactor(stream): remove dead type branches from getIntClaim (#5594)
The jwx library always deserializes numeric claims from a parsed token as float64, so the int and int64 branches in getIntClaim could never succeed and were dead code. Keep only the float64 path, which is the one actually exercised by the token round-trip, and update the comment to document the library behavior.
This commit is contained in:
parent
08fd222791
commit
3b958dd6a7
1 changed files with 3 additions and 10 deletions
|
|
@ -92,17 +92,10 @@ func paramsFromToken(token jwt.Token) (*params, error) {
|
|||
return &p, nil
|
||||
}
|
||||
|
||||
// getIntClaim extracts an int claim from a JWT token, handling the case where
|
||||
// the value may be stored as int64 or float64 (common in JSON-based JWT libraries).
|
||||
// getIntClaim extracts a numeric claim from a JWT token. Numeric claims in a
|
||||
// parsed token are always deserialized as float64, regardless of the type used
|
||||
// when encoding.
|
||||
func getIntClaim(token jwt.Token, key string) int {
|
||||
var v int
|
||||
if err := token.Get(key, &v); err == nil {
|
||||
return v
|
||||
}
|
||||
var v64 int64
|
||||
if err := token.Get(key, &v64); err == nil {
|
||||
return int(v64)
|
||||
}
|
||||
var f float64
|
||||
if err := token.Get(key, &f); err == nil {
|
||||
return int(f)
|
||||
|
|
|
|||
Loading…
Reference in a new issue