Skip to content
This repository has been archived by the owner on Apr 22, 2024. It is now read-only.

Commit

Permalink
Externally created tokens were failing to vaildate, it turns out that…
Browse files Browse the repository at this point in the history
… signatures were being double encoded.

I used the debugger at jwt.io to confirm.
  • Loading branch information
henderjon committed Feb 22, 2018
1 parent c702dd3 commit 2479b53
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions algorithms.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,13 @@ func (a *Algorithm) write(data []byte) (int, error) {
}

// Sign signs the token with the given hash, and key
func (a *Algorithm) Sign(unsignedToken string) (string, error) {
func (a *Algorithm) Sign(unsignedToken string) ([]byte, error) {
_, err := a.write([]byte(unsignedToken))
if err != nil {
return "", errors.Wrap(err, "Unable to write to HMAC-SHA256")
return nil, errors.Wrap(err, "Unable to write to HMAC-SHA256")
}

encodedToken := base64.RawURLEncoding.EncodeToString(a.sum(nil))
encodedToken := a.sum(nil)
a.reset()

return encodedToken, nil
Expand Down

0 comments on commit 2479b53

Please sign in to comment.