com.github.mkopylec.recaptcha.validation.ValidationConfiguration Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of recaptcha-spring-boot-starter Show documentation
Show all versions of recaptcha-spring-boot-starter Show documentation
Spring Boot starter for Google's reCAPTCHA
package com.github.mkopylec.recaptcha.validation;
import com.github.mkopylec.recaptcha.RecaptchaProperties;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.client.RestTemplate;
@Configuration("recaptchaValidationConfiguration")
@EnableConfigurationProperties(RecaptchaProperties.class)
@ConditionalOnProperty(name = "recaptcha.testing.enabled", havingValue = "false", matchIfMissing = true)
public class ValidationConfiguration {
private final RecaptchaProperties recaptcha;
public ValidationConfiguration(RecaptchaProperties recaptcha) {
this.recaptcha = recaptcha;
}
@Bean
@ConditionalOnMissingBean
public RecaptchaValidator userResponseValidator(RestTemplate restTemplate) {
return new RecaptchaValidator(restTemplate, recaptcha);
}
@Bean
@ConditionalOnMissingBean
public RestTemplate restTemplate() {
return new RestTemplate();
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy