Fix keep challenge

This commit is contained in:
Pascal Engélibert 2025-04-06 18:05:47 +02:00
commit af9e46c714
2 changed files with 14 additions and 8 deletions

View file

@ -36,6 +36,6 @@ policy-groups:
- name: robots.txt
first-line: "^GET /robots.txt "
action: allow
- name: Favicon
first-line: "^GET /favicon.ico "
action: allow
- name: Test
first-line: "^GET /test/[a-z]+/"
action: challenge

View file

@ -143,10 +143,9 @@ async fn main() {
}
}
let mut allow = false;
let mut valid_challenge = false;
if let (Some(req_challenge), Some(req_proof)) = (req_challenge, req_proof) {
let mut allow = false;
if let Some(req_challenge) = req_challenge {
valid_challenge = challenge::verify_challenge_cookie(
req_challenge,
&secret,
@ -154,8 +153,15 @@ async fn main() {
req_ip,
config.challenge_timeout,
);
allow = valid_challenge
&& challenge::check_challenge(req_challenge, req_proof, TARGET_ZEROS);
if let Some(req_proof) = req_proof {
allow = valid_challenge
&& challenge::check_challenge(
req_challenge,
req_proof,
TARGET_ZEROS,
);
}
}
if allow {