Skip to content

Commit 627b4f0

Browse files
committed
Use base Altcha payload for challenge verification
1 parent 4d4e8a0 commit 627b4f0

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

captchaservice-backend/src/main/java/de/muenchen/captchaservice/data/ExtendedPayload.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,18 @@ public class ExtendedPayload extends Altcha.Payload {
1414
*/
1515
private Long took;
1616

17+
/**
18+
* Converts this {@code ExtendedPayload} instance into a plain {@link Altcha.Payload}
19+
* object that contains only the standard fields required for validation.
20+
*/
21+
public Altcha.Payload toBasePayload() {
22+
Altcha.Payload base = new Altcha.Payload();
23+
base.algorithm = this.algorithm;
24+
base.challenge = this.challenge;
25+
base.number = this.number;
26+
base.salt = this.salt;
27+
base.signature = this.signature;
28+
return base;
29+
}
30+
1731
}

captchaservice-backend/src/main/java/de/muenchen/captchaservice/service/captcha/CaptchaService.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,8 @@ public boolean verify(final String siteKey, final ExtendedPayload payload, final
5757
return false;
5858
}
5959
try {
60-
final boolean isValid = Altcha.verifySolution(payload, captchaProperties.hmacKey(), true);
60+
Altcha.Payload base = payload.toBasePayload();
61+
final boolean isValid = Altcha.verifySolution(base, captchaProperties.hmacKey(), true);
6162
if (isValid) {
6263
metricsService.recordVerifySuccess(siteKey, sourceAddress);
6364

0 commit comments

Comments
 (0)