From 2b65ae5fe25456858544263279adec38743ab89d Mon Sep 17 00:00:00 2001 From: mzc5649 <13027087095@163.com> Date: Mon, 19 Apr 2021 10:17:50 +0800 Subject: [PATCH] =?UTF-8?q?=E3=80=90add=E3=80=91=E6=B7=BB=E5=8A=A0?= =?UTF-8?q?=E8=B7=A8=E7=AB=99=E7=99=BD=E5=90=8D=E5=8D=95=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/com/jero/config/CsrfFilter.java | 41 +------------------ .../src/main/resources/application-dev.yml | 4 +- .../src/main/resources/application-prod.yml | 2 + .../src/main/resources/application-test.yml | 3 +- .../resources/jero/jero_database.properties | 2 +- .../src/main/resources/whiteUrls.txt | 0 6 files changed, 10 insertions(+), 42 deletions(-) delete mode 100644 jero-boot/jero-boot-single-startup/src/main/resources/whiteUrls.txt diff --git a/jero-boot/jero-boot-base/jero-boot-base-core/src/main/java/com/jero/config/CsrfFilter.java b/jero-boot/jero-boot-base/jero-boot-base-core/src/main/java/com/jero/config/CsrfFilter.java index 584801db..2ce5432a 100644 --- a/jero-boot/jero-boot-base/jero-boot-base-core/src/main/java/com/jero/config/CsrfFilter.java +++ b/jero-boot/jero-boot-base/jero-boot-base-core/src/main/java/com/jero/config/CsrfFilter.java @@ -36,7 +36,8 @@ public class CsrfFilter implements Filter { /** * 白名单 */ - private List whiteUrls = new ArrayList<>(); + @Value("${jero.whiteUrls}") + private List whiteUrls; /** * size @@ -45,45 +46,7 @@ public class CsrfFilter implements Filter { @Override 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(); - } 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 diff --git a/jero-boot/jero-boot-single-startup/src/main/resources/application-dev.yml b/jero-boot/jero-boot-single-startup/src/main/resources/application-dev.yml index 903ad1d7..a6909fc8 100644 --- a/jero-boot/jero-boot-single-startup/src/main/resources/application-dev.yml +++ b/jero-boot/jero-boot-single-startup/src/main/resources/application-dev.yml @@ -131,7 +131,7 @@ spring: connectionProperties: druid.stat.mergeSql\=true;druid.stat.slowSqlMillis\=5000 datasource: 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 password: 123456 driver-class-name: com.mysql.cj.jdbc.Driver @@ -246,6 +246,8 @@ jero : enabled: true # 文件限制后缀黑名单 fileSuffixLimits : 0x00,%00,\\00,.jsp,.exe,.php,.asp,.aspx,.jspx,.xml,.html,.js,.sh,.bin + # 跨站白名单 + whiteUrls: #cas单点登录 cas: prefixUrl: http://cas.example.org:8443/cas diff --git a/jero-boot/jero-boot-single-startup/src/main/resources/application-prod.yml b/jero-boot/jero-boot-single-startup/src/main/resources/application-prod.yml index 8d3d7fad..b7112cfa 100644 --- a/jero-boot/jero-boot-single-startup/src/main/resources/application-prod.yml +++ b/jero-boot/jero-boot-single-startup/src/main/resources/application-prod.yml @@ -246,6 +246,8 @@ jero : enabled: true # 文件限制后缀黑名单 fileSuffixLimits : 0x00,%00,\\00,.jsp,.exe,.php,.asp,.aspx,.jspx,.xml,.html,.js,.sh,.bin + # 跨站白名单 + whiteUrls: #cas单点登录 cas: prefixUrl: http://cas.example.org:8443/cas diff --git a/jero-boot/jero-boot-single-startup/src/main/resources/application-test.yml b/jero-boot/jero-boot-single-startup/src/main/resources/application-test.yml index 1ec1ed28..ac7de9c8 100644 --- a/jero-boot/jero-boot-single-startup/src/main/resources/application-test.yml +++ b/jero-boot/jero-boot-single-startup/src/main/resources/application-test.yml @@ -246,7 +246,8 @@ jero : enabled: true # 文件限制后缀黑名单 fileSuffixLimits : 0x00,%00,\\00,.jsp,.exe,.php,.asp,.aspx,.jspx,.xml,.html,.js,.sh,.bin - + # 跨站白名单 + whiteUrls: #Mybatis输出sql日志 logging: level: diff --git a/jero-boot/jero-boot-single-startup/src/main/resources/jero/jero_database.properties b/jero-boot/jero-boot-single-startup/src/main/resources/jero/jero_database.properties index 58611f93..df8d1ea4 100644 --- a/jero-boot/jero-boot-single-startup/src/main/resources/jero/jero_database.properties +++ b/jero-boot/jero-boot-single-startup/src/main/resources/jero/jero_database.properties @@ -2,7 +2,7 @@ driver_name=com.mysql.cj.jdbc.Driver url=jdbc:mysql://localhost:3306/jero-boot?useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai username=root -password=root +password=123456 database_name=jero-boot #oracle diff --git a/jero-boot/jero-boot-single-startup/src/main/resources/whiteUrls.txt b/jero-boot/jero-boot-single-startup/src/main/resources/whiteUrls.txt deleted file mode 100644 index e69de29b..00000000