
entry-point.rest-webflux.security-headers-filter.mustache Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of scaffold-clean-architecture Show documentation
Show all versions of scaffold-clean-architecture Show documentation
Gradle plugin to create a clean application in Java that already works, It follows our best practices!
package {{package}}.api.config;
import org.springframework.http.HttpHeaders;
import org.springframework.stereotype.Component;
import org.springframework.web.server.ServerWebExchange;
import org.springframework.web.server.WebFilter;
import org.springframework.web.server.WebFilterChain;
import reactor.core.publisher.Mono;
@Component
public class SecurityHeadersConfig implements WebFilter {
@Override
public Mono filter(ServerWebExchange exchange, WebFilterChain chain) {
HttpHeaders headers = exchange.getResponse().getHeaders();
headers.set("Content-Security-Policy", "default-src 'self'; frame-ancestors 'self'; form-action 'self'");
headers.set("Strict-Transport-Security", "max-age=31536000;");
headers.set("X-Content-Type-Options", "nosniff");
headers.set("Server", "");
headers.set("Cache-Control", "no-store");
headers.set("Pragma", "no-cache");
headers.set("Referrer-Policy", "strict-origin-when-cross-origin");
return chain.filter(exchange);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy