Pass http challenge if we passed it previously on the request

This commit is contained in:
WeebDataHoarder
2025-04-07 23:44:29 +02:00
parent 1144424eff
commit b3f471bb30

View File

@@ -240,6 +240,13 @@ func NewState(p policy.Policy, settings StateSettings) (state *State, err error)
}
c.ServeChallenge = func(w http.ResponseWriter, r *http.Request, key []byte, expiry time.Time) challenge.Result {
data := RequestDataFromContext(r.Context())
if result := data.Challenges[c.Id]; result.Ok() {
return challenge.ResultPass
}
var cookieValue string
if expectedCookie != "" {
if cookie, err := r.Cookie(expectedCookie); err != nil || cookie == nil {
@@ -283,6 +290,8 @@ func NewState(p policy.Policy, settings StateSettings) (state *State, err error)
utils.SetCookie(utils.CookiePrefix+challengeName, token, expiry, w)
}
data.Challenges[c.Id] = challenge.VerifyResultPASS
// we passed it!
return challenge.ResultPass
}