remove redundant JWT validation introduced in #5535
This commit is contained in:
parent
eebfdbc8ae
commit
8e5c0b17ba
@ -86,17 +86,12 @@ func withUser(fn handleFunc) handleFunc {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var tk authToken
|
var tk authToken
|
||||||
p := jwt.NewParser(jwt.WithValidMethods([]string{jwt.SigningMethodHS256.Alg()}))
|
p := jwt.NewParser(jwt.WithValidMethods([]string{jwt.SigningMethodHS256.Alg()}), jwt.WithExpirationRequired())
|
||||||
token, err := request.ParseFromRequest(r, &extractor{}, keyFunc, request.WithClaims(&tk), request.WithParser(p))
|
token, err := request.ParseFromRequest(r, &extractor{}, keyFunc, request.WithClaims(&tk), request.WithParser(p))
|
||||||
if (err != nil || !token.Valid) && !renewableErr(err, d) {
|
if (err != nil || !token.Valid) && !renewableErr(err, d) {
|
||||||
return http.StatusUnauthorized, nil
|
return http.StatusUnauthorized, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
err = jwt.NewValidator(jwt.WithExpirationRequired()).Validate(tk)
|
|
||||||
if err != nil {
|
|
||||||
return http.StatusUnauthorized, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
expiresSoon := tk.ExpiresAt != nil && time.Until(tk.ExpiresAt.Time) < time.Hour
|
expiresSoon := tk.ExpiresAt != nil && time.Until(tk.ExpiresAt.Time) < time.Hour
|
||||||
updated := tk.IssuedAt != nil && tk.IssuedAt.Unix() < d.store.Users.LastUpdate(tk.User.ID)
|
updated := tk.IssuedAt != nil && tk.IssuedAt.Unix() < d.store.Users.LastUpdate(tk.User.ID)
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user