Java/Spring Boot - JHipster
Supported versions
DataDome supports Springs versions until they are unsupported by the maintainer.
You can find the support schedule of each Spring versions on these website:
- For Spring Boot
- For Spring Framework
This module is compatible with the following Spring versions:
- Spring Boot version 3 and above
- Spring Framework versions 6 and above
Add dependency for DataDome Java Module
When using Maven, update your pom.xml
file with the following content:
<project>
...
<dependencies>
...
<dependency>
<groupId>co.datadome.module</groupId>
<artifactId>datadome-java-module</artifactId>
<version>2.1.1</version>
</dependency>
...
</dependencies>
...
</project>
Register the DataDomeFilter
Add a FilterRegistrationBean in your Java web configuration file. It has to be registered with the highest priority order.
For JHipster, you may use WebConfigurer.java
.
public class WebConfigurer implements ServletContextInitializer, WebServerFactoryCustomizer<WebServerFactory> {
/* section to copy */
@Bean
public FilterRegistrationBean<DataDomeFilter> dataDomeFilter() {
FilterRegistrationBean<DataDomeFilter> filterRegistrationBean = new FilterRegistrationBean<>();
filterRegistrationBean.setFilter(new DataDomeFilter());
filterRegistrationBean.setName("datadome-filter");
filterRegistrationBean.addUrlPatterns("/*");
filterRegistrationBean.addInitParameter("datadome.apikey", "YOUR_DATADOME_SERVER_SIDE_KEY");
filterRegistrationBean.setOrder(Ordered.HIGHEST_PRECEDENCE);
return filterRegistrationBean;
}
/* end of section*/
}
List of possible init parameters to add in the iniParameters map:
Settings | Description | Default |
---|---|---|
datadome.apikey | License key to access API | |
datadome.hostname | API server's hostname Available endpoints | api.datadome.co |
datadome.ssl | Use SSL between the filter and the API server | true |
datadome.regex | Inclusion Regex | "" |
datadome.exclusion_regex | Exclusion Regex | \.(js|css|jpg|jpeg|png|ico|gif|tiff|svg|woff|woff2|ttf|eot|mp4|otf)$ |
datadome.connection_timeout | Connection timeout (in ms) | 150 |
datadome.read_timeout | Read timeout (in ms) | 50 |
datadome.max_connections | Maximum open connections to the API server | 100 |
datadome.use_x_forwarded_host | Use the request header x-forwarded-host instead of host (used for cookie, dashboard domain...) | false |
datadome.use_forwarded | use the request header forwarded to override x-forwarded-* values | false |
datadome.proxy_server | Host that will be used as proxy server See here | |
datadome.proxy_port | TCP port at the proxy server See here | |
datadome.proxy_ssl | Is the connection to the proxy established through TLS See here | false |
datadome.skip_ips | IPv4 or IPv6 subnetwork list on which DataDome validation is not executed, e.g.: "2a03:2880:1000::/36,124.66.0.0/17" |
FAQ
How do I call the DataDome API via an outbound proxy?
The DataDome module can be used with an outbound proxy. Two options are available for the proxy configuration:
-
Use system settings such as
-Dhttp.proxyHost=1.2.3.4 -Dhttp.proxyPort=8080 -Dhttps.proxyHost=1.2.3.4 -Dhttps.proxyPort=8443
when running your Java application. -
Use optional DataDome init parameters
datadome.proxy_server
,datadome.proxy_port
,datadome.proxy_ssl
inweb.xml
.
Network latency
Using the DataDome module with an outbound proxy can slow down the request to DataDome API and increase timeouts. Please adjust timeout settings accordingly.
Updated 9 days ago