Skip to content

Commit

Permalink
fixed an error in ParseAndVerify (#26)
Browse files Browse the repository at this point in the history
  • Loading branch information
paulish authored and cristaloleg committed Jan 27, 2020
1 parent f09e58e commit 01e9f36
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
2 changes: 1 addition & 1 deletion parse.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ func ParseAndVerify(raw []byte, signer Signer) (*Token, error) {
if err != nil {
return nil, err
}
if err := signer.Verify(token.signature, token.payload); err != nil {
if err := signer.Verify(token.payload, token.signature); err != nil {
return nil, err
}
return token, nil
Expand Down
14 changes: 14 additions & 0 deletions parse_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package jwt

import (
"testing"
)

func TestParseAndVerifyString(t *testing.T) {
sign, _ := NewHS256([]byte(`test-key-256`))
token := "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJhdWQiOiJhdWRpZW5jZSIsImp0aSI6Imp1c3QgYW4gaWQifQ.6EWV4IFTyCqCUn-_R1AFRgJptvmV09Os57WAejPcf7Q"

if _, err := ParseAndVerifyString(token, sign); err != nil {
t.Fatal(err)
}
}

0 comments on commit 01e9f36

Please sign in to comment.