【add】添加跨站白名单配置

This commit is contained in:
mzc5649
2021-04-19 10:17:50 +08:00
parent c864043c11
commit 2b65ae5fe2
6 changed files with 10 additions and 42 deletions
@@ -36,7 +36,8 @@ public class CsrfFilter implements Filter {
/** /**
* 白名单 * 白名单
*/ */
private List<String> whiteUrls = new ArrayList<>(); @Value("${jero.whiteUrls}")
private List<String> whiteUrls;
/** /**
* size * size
@@ -45,45 +46,7 @@ public class CsrfFilter implements Filter {
@Override @Override
public void init(FilterConfig filterConfig) throws ServletException { public void init(FilterConfig filterConfig) throws ServletException {
FileInputStream fis = null;
InputStreamReader isr = null;
BufferedReader br = null;
try {
File file = ResourceUtils.getFile("classpath:whiteUrls.txt");
fis = new FileInputStream(file);
isr = new InputStreamReader(fis);
br = new BufferedReader(isr);
String url = null;
while((url = br.readLine()) != null){
whiteUrls.add(url);
}
size = whiteUrls.size(); size = whiteUrls.size();
} catch (IOException e) {
e.printStackTrace();
} finally {
if(fis!=null){
try {
fis.close();
} catch (IOException e) {
e.printStackTrace();
}
}
if(isr!=null){
try {
isr.close();
} catch (IOException e) {
e.printStackTrace();
}
}
if(br!=null){
try {
br.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
} }
@Override @Override
@@ -131,7 +131,7 @@ spring:
connectionProperties: druid.stat.mergeSql\=true;druid.stat.slowSqlMillis\=5000 connectionProperties: druid.stat.mergeSql\=true;druid.stat.slowSqlMillis\=5000
datasource: datasource:
master: master:
url: jdbc:mysql://10.0.3.44:3306/jero-boot?characterEncoding=UTF-8&useUnicode=true&useSSL=false&tinyInt1isBit=false&allowPublicKeyRetrieval=true&serverTimezone=Asia/Shanghai url: jdbc:mysql://localhost:3306/jero-boot?characterEncoding=UTF-8&useUnicode=true&useSSL=false&tinyInt1isBit=false&allowPublicKeyRetrieval=true&serverTimezone=Asia/Shanghai
username: root username: root
password: 123456 password: 123456
driver-class-name: com.mysql.cj.jdbc.Driver driver-class-name: com.mysql.cj.jdbc.Driver
@@ -246,6 +246,8 @@ jero :
enabled: true enabled: true
# 文件限制后缀黑名单 # 文件限制后缀黑名单
fileSuffixLimits : 0x00,%00,\\00,.jsp,.exe,.php,.asp,.aspx,.jspx,.xml,.html,.js,.sh,.bin fileSuffixLimits : 0x00,%00,\\00,.jsp,.exe,.php,.asp,.aspx,.jspx,.xml,.html,.js,.sh,.bin
# 跨站白名单
whiteUrls:
#cas单点登录 #cas单点登录
cas: cas:
prefixUrl: http://cas.example.org:8443/cas prefixUrl: http://cas.example.org:8443/cas
@@ -246,6 +246,8 @@ jero :
enabled: true enabled: true
# 文件限制后缀黑名单 # 文件限制后缀黑名单
fileSuffixLimits : 0x00,%00,\\00,.jsp,.exe,.php,.asp,.aspx,.jspx,.xml,.html,.js,.sh,.bin fileSuffixLimits : 0x00,%00,\\00,.jsp,.exe,.php,.asp,.aspx,.jspx,.xml,.html,.js,.sh,.bin
# 跨站白名单
whiteUrls:
#cas单点登录 #cas单点登录
cas: cas:
prefixUrl: http://cas.example.org:8443/cas prefixUrl: http://cas.example.org:8443/cas
@@ -246,7 +246,8 @@ jero :
enabled: true enabled: true
# 文件限制后缀黑名单 # 文件限制后缀黑名单
fileSuffixLimits : 0x00,%00,\\00,.jsp,.exe,.php,.asp,.aspx,.jspx,.xml,.html,.js,.sh,.bin fileSuffixLimits : 0x00,%00,\\00,.jsp,.exe,.php,.asp,.aspx,.jspx,.xml,.html,.js,.sh,.bin
# 跨站白名单
whiteUrls:
#Mybatis输出sql日志 #Mybatis输出sql日志
logging: logging:
level: level:
@@ -2,7 +2,7 @@
driver_name=com.mysql.cj.jdbc.Driver driver_name=com.mysql.cj.jdbc.Driver
url=jdbc:mysql://localhost:3306/jero-boot?useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai url=jdbc:mysql://localhost:3306/jero-boot?useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai
username=root username=root
password=root password=123456
database_name=jero-boot database_name=jero-boot
#oracle #oracle