diff --git a/parser.go b/parser.go index 40b02bc..3fc27bf 100644 --- a/parser.go +++ b/parser.go @@ -98,7 +98,8 @@ func (p *Parser) Parse(tokenString string, keyFunc Keyfunc) (*Token, error) { } // Perform validation - if err = token.Method.Verify(strings.Join(parts[0:2], "."), parts[2], key); err != nil { + token.Signature = parts[2] + if err = token.Method.Verify(strings.Join(parts[0:2], "."), token.Signature, key); err != nil { vErr.err = err.Error() vErr.Errors |= ValidationErrorSignatureInvalid } diff --git a/parser_test.go b/parser_test.go index 97d9eee..9115017 100644 --- a/parser_test.go +++ b/parser_test.go @@ -184,9 +184,11 @@ func TestParser_Parse(t *testing.T) { if e := err.(*jwt.ValidationError).Errors; e != data.errors { t.Errorf("[%v] Errors don't match expectation. %v != %v", data.name, e, data.errors) } - } } + if data.valid && token.Signature == "" { + t.Errorf("[%v] Signature is left unpopulated after parsing", data.name) + } } }