Skip to content
This repository has been archived by the owner on May 21, 2022. It is now read-only.

Only minor changes #173

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,9 @@ func (e ValidationError) Error() string {
return e.Inner.Error()
} else if e.text != "" {
return e.text
} else {
return "token is invalid"
}
} else {
return "token is invalid"
}
}

// No errors
Expand Down
17 changes: 8 additions & 9 deletions hmac.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,27 +23,26 @@ var (
func init() {
// HS256
SigningMethodHS256 = &SigningMethodHMAC{"HS256", crypto.SHA256}
RegisterSigningMethod(SigningMethodHS256.Alg(), func() SigningMethod {
return SigningMethodHS256
})
SigningMethodHS256.Register()

// HS384
SigningMethodHS384 = &SigningMethodHMAC{"HS384", crypto.SHA384}
RegisterSigningMethod(SigningMethodHS384.Alg(), func() SigningMethod {
return SigningMethodHS384
})
SigningMethodHS384.Register()

// HS512
SigningMethodHS512 = &SigningMethodHMAC{"HS512", crypto.SHA512}
RegisterSigningMethod(SigningMethodHS512.Alg(), func() SigningMethod {
return SigningMethodHS512
})
SigningMethodHS512.Register()
}

func (m *SigningMethodHMAC) Alg() string {
return m.Name
}

// Register the signing method
func (m *SigningMethodHMAC) Register() {
RegisterSigningMethod(m.Name, func() SigningMethod { return m })
}

// Verify the signature of HSXXX tokens. Returns nil if the signature is valid.
func (m *SigningMethodHMAC) Verify(signingString, signature string, key interface{}) error {
// Verify the key is the right type
Expand Down