adhere to jwt/v4 security recommendation: "validate the alg presented is what you expect"

This commit is contained in:
jake-dog 2025-05-13 21:10:24 -04:00
parent 07fe90ff5f
commit 6e6beab914

View File

@ -87,7 +87,8 @@ func withUser(fn handleFunc) handleFunc {
}
var tk authToken
token, err := request.ParseFromRequest(r, &extractor{}, keyFunc, request.WithClaims(&tk))
p := jwt.NewParser(jwt.WithValidMethods([]string{jwt.SigningMethodHS256.Alg()}))
token, err := request.ParseFromRequest(r, &extractor{}, keyFunc, request.WithClaims(&tk), request.WithParser(p))
if (err != nil || !token.Valid) && !renewableErr(err, d) {
return http.StatusUnauthorized, nil