Remove unused captcha configuration
This commit is contained in:
parent
a9a2e40fed
commit
5934b7344a
|
@ -58,50 +58,4 @@ public class RegistrationCaptchaManager {
|
|||
? Optional.of(captchaChecker.verify(Action.REGISTRATION, captcha.get(), sourceHost))
|
||||
: Optional.empty();
|
||||
}
|
||||
|
||||
public boolean requiresCaptcha(final String number, final String forwardedFor, String sourceHost,
|
||||
final boolean pushChallengeMatch) {
|
||||
if (testDevices.contains(number)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!pushChallengeMatch) {
|
||||
return true;
|
||||
}
|
||||
|
||||
final String countryCode = Util.getCountryCode(number);
|
||||
final String region = Util.getRegion(number);
|
||||
|
||||
DynamicCaptchaConfiguration captchaConfig = dynamicConfigurationManager.getConfiguration()
|
||||
.getCaptchaConfiguration();
|
||||
|
||||
boolean countryFiltered = captchaConfig.getSignupCountryCodes().contains(countryCode) ||
|
||||
captchaConfig.getSignupRegions().contains(region);
|
||||
|
||||
try {
|
||||
rateLimiters.getSmsVoiceIpLimiter().validate(sourceHost);
|
||||
} catch (RateLimitExceededException e) {
|
||||
logger.info("Rate limit exceeded: {}, {} ({})", number, sourceHost, forwardedFor);
|
||||
rateLimitedHostMeter.mark();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
try {
|
||||
rateLimiters.getSmsVoicePrefixLimiter().validate(Util.getNumberPrefix(number));
|
||||
} catch (RateLimitExceededException e) {
|
||||
logger.info("Prefix rate limit exceeded: {}, {} ({})", number, sourceHost, forwardedFor);
|
||||
rateLimitedPrefixMeter.mark();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
if (countryFiltered) {
|
||||
countryFilteredHostMeter.mark();
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -43,36 +43,10 @@ public class DynamicCaptchaConfiguration {
|
|||
@NotNull
|
||||
private Map<Action, BigDecimal> scoreFloorByAction = Collections.emptyMap();
|
||||
|
||||
@JsonProperty
|
||||
@NotNull
|
||||
private Set<String> signupCountryCodes = Collections.emptySet();
|
||||
|
||||
@JsonProperty
|
||||
@NotNull
|
||||
private Set<String> signupRegions = Collections.emptySet();
|
||||
|
||||
public BigDecimal getScoreFloor() {
|
||||
return scoreFloor;
|
||||
}
|
||||
|
||||
public Set<String> getSignupCountryCodes() {
|
||||
return signupCountryCodes;
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
public void setSignupCountryCodes(Set<String> numbers) {
|
||||
this.signupCountryCodes = numbers;
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
public void setSignupRegions(final Set<String> signupRegions) {
|
||||
this.signupRegions = signupRegions;
|
||||
}
|
||||
|
||||
public Set<String> getSignupRegions() {
|
||||
return signupRegions;
|
||||
}
|
||||
|
||||
public boolean isAllowHCaptcha() {
|
||||
return allowHCaptcha;
|
||||
}
|
||||
|
|
|
@ -249,8 +249,6 @@ class DynamicConfigurationTest {
|
|||
{
|
||||
final String captchaConfig = """
|
||||
captcha:
|
||||
signupCountryCodes:
|
||||
- 1
|
||||
scoreFloor: null
|
||||
""";
|
||||
|
||||
|
@ -261,8 +259,6 @@ class DynamicConfigurationTest {
|
|||
{
|
||||
final String captchaConfig = """
|
||||
captcha:
|
||||
signupCountryCodes:
|
||||
- 1
|
||||
scoreFloor: 0.9
|
||||
scoreFloorByAction:
|
||||
challenge: 0.1
|
||||
|
@ -282,7 +278,6 @@ class DynamicConfigurationTest {
|
|||
DynamicConfigurationManager.parseConfiguration(captchaConfig, DynamicConfiguration.class).orElseThrow()
|
||||
.getCaptchaConfiguration();
|
||||
|
||||
assertEquals(Set.of("1"), config.getSignupCountryCodes());
|
||||
assertEquals(0.9f, config.getScoreFloor().floatValue());
|
||||
assertEquals(0.1f, config.getScoreFloorByAction().get(Action.CHALLENGE).floatValue());
|
||||
assertEquals(0.2f, config.getScoreFloorByAction().get(Action.REGISTRATION).floatValue());
|
||||
|
|
Loading…
Reference in New Issue