From 66ca404d841ed908aa6cc9361107b0c363c94cd8 Mon Sep 17 00:00:00 2001 From: Matthew Dillon Date: Tue, 26 May 2015 13:22:18 -0800 Subject: [PATCH] Tack on request to verifyClaims --- README.md | 2 +- examples/net-http.go | 2 +- jwt.go | 6 +++--- jwt_test.go | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 9725903..c97712c 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/examples/net-http.go b/examples/net-http.go index 51a14d1..1caef55 100644 --- a/examples/net-http.go +++ b/examples/net-http.go @@ -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 diff --git a/jwt.go b/jwt.go index a3a6a03..d37be84 100644 --- a/jwt.go +++ b/jwt.go @@ -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, diff --git a/jwt_test.go b/jwt_test.go index 59c9b08..c5579b8 100644 --- a/jwt_test.go +++ b/jwt_test.go @@ -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