challenge: Skip already issued challenges

This commit is contained in:
WeebDataHoarder
2025-04-23 22:06:11 +02:00
parent cef915b353
commit cd372e1512

View File

@@ -108,6 +108,11 @@ func (d *RequestData) Parent() cel.Activation {
}
func (d *RequestData) EvaluateChallenges(w http.ResponseWriter, r *http.Request) {
q := r.URL.Query()
var issuedChallenge string
if q.Has(QueryArgChallenge) {
issuedChallenge = q.Get(QueryArgChallenge)
}
for _, reg := range d.State.GetChallenges() {
key := GetChallengeKeyForRequest(d.State, reg, d.Expiration(reg.Duration), r)
verifyResult, verifyState, err := reg.VerifyChallengeToken(d.State.PublicKey(), key, r)
@@ -130,6 +135,11 @@ func (d *RequestData) EvaluateChallenges(w http.ResponseWriter, r *http.Request)
}
}
}
if !verifyResult.Ok() && issuedChallenge == reg.Name {
// we issued the challenge, must skip to prevent loops
verifyResult = VerifyResultSkip
}
d.ChallengeVerify[reg.Id()] = verifyResult
d.ChallengeState[reg.Id()] = verifyState
}