Tack on request to verifyClaims
This commit is contained in:
parent
f0a0af1c1f
commit
66ca404d84
4 changed files with 6 additions and 6 deletions
|
@ -42,7 +42,7 @@ func setClaims(id string) (map[string]interface{}, error) {
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func verifyClaims(claims []byte) error {
|
func verifyClaims(claims []byte, r *http.Request) error {
|
||||||
currentTime := time.Now()
|
currentTime := time.Now()
|
||||||
var c struct {
|
var c struct {
|
||||||
Iat int64
|
Iat int64
|
||||||
|
|
|
@ -34,7 +34,7 @@ func setClaims(id string) (map[string]interface{}, error) {
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func verifyClaims(claims []byte) error {
|
func verifyClaims(claims []byte, r *http.Request) error {
|
||||||
currentTime := time.Now()
|
currentTime := time.Now()
|
||||||
var c struct {
|
var c struct {
|
||||||
Iat int64
|
Iat int64
|
||||||
|
|
6
jwt.go
6
jwt.go
|
@ -41,8 +41,8 @@ type AuthFunc func(string, string) error
|
||||||
type ClaimsFunc func(string) (map[string]interface{}, error)
|
type ClaimsFunc func(string) (map[string]interface{}, error)
|
||||||
|
|
||||||
// VerifyClaimsFunc is a type for processing and validating JWT claims on one
|
// VerifyClaimsFunc is a type for processing and validating JWT claims on one
|
||||||
// or more route's in the client-code.
|
// or more routes in the client-code.
|
||||||
type VerifyClaimsFunc func([]byte) error
|
type VerifyClaimsFunc func([]byte, *http.Request) error
|
||||||
|
|
||||||
// Config is a container for setting up the JWT middleware.
|
// Config is a container for setting up the JWT middleware.
|
||||||
type Config struct {
|
type Config struct {
|
||||||
|
@ -155,7 +155,7 @@ func (m *Middleware) Secure(h http.Handler, v VerifyClaimsFunc) http.Handler {
|
||||||
message: "decoding claims",
|
message: "decoding claims",
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
err = v(claimSet)
|
err = v(claimSet, r)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return &jwtError{
|
return &jwtError{
|
||||||
status: http.StatusUnauthorized,
|
status: http.StatusUnauthorized,
|
||||||
|
|
|
@ -32,7 +32,7 @@ var claimsFunc = func(id string) (map[string]interface{}, error) {
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
var verifyClaimsFunc = func(claims []byte) error {
|
var verifyClaimsFunc = func(claims []byte, r *http.Request) error {
|
||||||
currentTime := time.Now()
|
currentTime := time.Now()
|
||||||
var c struct {
|
var c struct {
|
||||||
Exp int64
|
Exp int64
|
||||||
|
|
Loading…
Add table
Reference in a new issue