Extract inner error when parsing JWT

This commit is contained in:
wpetit 2019-03-29 16:44:09 +01:00
parent 0751c0cf7e
commit 5986d2bb9b
1 changed files with 8 additions and 0 deletions

View File

@ -114,6 +114,10 @@ func assertServerToken(key *rsa.PublicKey, serverToken string) (*peering.ServerT
} }
token, err := jwt.ParseWithClaims(serverToken, &peering.ServerTokenClaims{}, fn) token, err := jwt.ParseWithClaims(serverToken, &peering.ServerTokenClaims{}, fn)
if err != nil { if err != nil {
validationError, ok := err.(*jwt.ValidationError)
if ok {
return nil, validationError.Inner
}
return nil, err return nil, err
} }
if !token.Valid { if !token.Valid {
@ -146,6 +150,10 @@ func assertClientToken(peerID peering.PeerID, store peering.Store, clientToken s
} }
token, err := jwt.ParseWithClaims(clientToken, &peering.ClientTokenClaims{}, fn) token, err := jwt.ParseWithClaims(clientToken, &peering.ClientTokenClaims{}, fn)
if err != nil { if err != nil {
validationError, ok := err.(*jwt.ValidationError)
if ok {
return nil, validationError.Inner
}
return nil, err return nil, err
} }
if !token.Valid { if !token.Valid {