parseString tries to parse a key in the map claims type as a [string] type. If the key does not exist, an empty string is returned. If the key has the wrong type, an error is returned.
(key string)
| 90 | // If the key does not exist, an empty string is returned. If the key has the |
| 91 | // wrong type, an error is returned. |
| 92 | func (m MapClaims) parseString(key string) (string, error) { |
| 93 | var ( |
| 94 | ok bool |
| 95 | raw any |
| 96 | iss string |
| 97 | ) |
| 98 | raw, ok = m[key] |
| 99 | if !ok { |
| 100 | return "", nil |
| 101 | } |
| 102 | |
| 103 | iss, ok = raw.(string) |
| 104 | if !ok { |
| 105 | return "", newError(fmt.Sprintf("%s is invalid", key), ErrInvalidType) |
| 106 | } |
| 107 | |
| 108 | return iss, nil |
| 109 | } |