MaybeKeyToBytes converts the x.Sensitive type into []byte if the type of interface really is x.Sensitive. We keep the type x.Sensitive for private and public keys so that it doesn't get printed into the logs but the type the JWT library needs is []byte.
(k interface{})
| 21 | // is x.Sensitive. We keep the type x.Sensitive for private and public keys so that it |
| 22 | // doesn't get printed into the logs but the type the JWT library needs is []byte. |
| 23 | func MaybeKeyToBytes(k interface{}) interface{} { |
| 24 | if kb, ok := k.(Sensitive); ok { |
| 25 | return []byte(kb) |
| 26 | } |
| 27 | return k |
| 28 | } |
| 29 | |
| 30 | func ParseJWT(jwtStr string) (jwt.MapClaims, error) { |
| 31 | token, err := jwt.Parse(jwtStr, func(token *jwt.Token) (interface{}, error) { |
no outgoing calls