防火墙 过滤 XSS SQL 攻击

v1.4.1
Parker 4 years ago
parent 06dab595a5
commit 3926872ff9

@ -0,0 +1,43 @@
package org.opsli.core.conf;
import org.opsli.core.waf.XssProperties;
import org.opsli.core.waf.filter.WafFilter;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import javax.servlet.DispatcherType;
/**
* @author 951755883@qq.com
* @date 2018/10/26
*/
@Configuration
@EnableConfigurationProperties({XssProperties.class})
public class WafConfig {
@Autowired
XssProperties xssProperties;
@Bean
@ConditionalOnProperty(prefix = XssProperties.XSS, name = "enable", havingValue = "true", matchIfMissing = false)
public FilterRegistrationBean xssFilterRegistration() {
WafFilter wafFilter = new WafFilter();
wafFilter.setUrlExclusion(xssProperties.getUrlExclusion());
wafFilter.setEnableSqlFilter(xssProperties.isSqlFilter());
wafFilter.setEnableXssFilter(xssProperties.isEnable());
FilterRegistrationBean registration = new FilterRegistrationBean();
registration.setDispatcherTypes(DispatcherType.REQUEST);
registration.setFilter(wafFilter);
registration.addUrlPatterns(xssProperties.getUrlPatterns());
registration.setName(xssProperties.getName());
registration.setOrder(xssProperties.getOrder());
return registration;
}
}
Loading…
Cancel
Save