* #bael-4684: add main source code * #bael-4684: add test * #bael-4684: add required dependencies
26 lines
899 B
Java
26 lines
899 B
Java
package com.baeldung.xss;
|
|
|
|
import org.springframework.context.annotation.Configuration;
|
|
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
|
|
import org.springframework.security.config.annotation.web.builders.WebSecurity;
|
|
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
|
|
|
|
@Configuration
|
|
public class SecurityConf extends WebSecurityConfigurerAdapter {
|
|
|
|
@Override
|
|
public void configure(WebSecurity web) {
|
|
// Ignoring here is only for this example. Normally people would apply their own authentication/authorization policies
|
|
web.ignoring().antMatchers("/**");
|
|
}
|
|
|
|
@Override
|
|
protected void configure(HttpSecurity http) throws Exception {
|
|
http
|
|
.headers()
|
|
.xssProtection()
|
|
.and()
|
|
.contentSecurityPolicy("script-src 'self'");
|
|
}
|
|
}
|