Tack on request to verifyClaims

This commit is contained in:
Matthew Dillon 2015-05-26 13:22:18 -08:00
parent f0a0af1c1f
commit 66ca404d84
4 changed files with 6 additions and 6 deletions

View file

@ -42,7 +42,7 @@ func setClaims(id string) (map[string]interface{}, error) {
}, nil
}
func verifyClaims(claims []byte) error {
func verifyClaims(claims []byte, r *http.Request) error {
currentTime := time.Now()
var c struct {
Iat int64

View file

@ -34,7 +34,7 @@ func setClaims(id string) (map[string]interface{}, error) {
}, nil
}
func verifyClaims(claims []byte) error {
func verifyClaims(claims []byte, r *http.Request) error {
currentTime := time.Now()
var c struct {
Iat int64

6
jwt.go
View file

@ -41,8 +41,8 @@ type AuthFunc func(string, string) error
type ClaimsFunc func(string) (map[string]interface{}, error)
// VerifyClaimsFunc is a type for processing and validating JWT claims on one
// or more route's in the client-code.
type VerifyClaimsFunc func([]byte) error
// or more routes in the client-code.
type VerifyClaimsFunc func([]byte, *http.Request) error
// Config is a container for setting up the JWT middleware.
type Config struct {
@ -155,7 +155,7 @@ func (m *Middleware) Secure(h http.Handler, v VerifyClaimsFunc) http.Handler {
message: "decoding claims",
}
}
err = v(claimSet)
err = v(claimSet, r)
if err != nil {
return &jwtError{
status: http.StatusUnauthorized,

View file

@ -32,7 +32,7 @@ var claimsFunc = func(id string) (map[string]interface{}, error) {
}, nil
}
var verifyClaimsFunc = func(claims []byte) error {
var verifyClaimsFunc = func(claims []byte, r *http.Request) error {
currentTime := time.Now()
var c struct {
Exp int64