signature should be populated after parsing a valid token

This commit is contained in:
Dave Grijalva 2015-11-16 12:42:37 -08:00
parent 2bd555e247
commit b728399c73
2 changed files with 5 additions and 2 deletions

View File

@ -98,7 +98,8 @@ func (p *Parser) Parse(tokenString string, keyFunc Keyfunc) (*Token, error) {
} }
// Perform validation // 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.err = err.Error()
vErr.Errors |= ValidationErrorSignatureInvalid vErr.Errors |= ValidationErrorSignatureInvalid
} }

View File

@ -184,9 +184,11 @@ func TestParser_Parse(t *testing.T) {
if e := err.(*jwt.ValidationError).Errors; e != data.errors { if e := err.(*jwt.ValidationError).Errors; e != data.errors {
t.Errorf("[%v] Errors don't match expectation. %v != %v", data.name, 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)
}
} }
} }