Skip to content

Commit 30f0bf2

Browse files
拦截器/过滤器配置优化
1 parent d52fbef commit 30f0bf2

File tree

4 files changed

+110
-160
lines changed

4 files changed

+110
-160
lines changed

src/main/java/io/geekidea/springbootplus/common/web/interceptor/TokenTimeoutInterceptor.java

Lines changed: 0 additions & 79 deletions
This file was deleted.

src/main/java/io/geekidea/springbootplus/config/FilterConfig.java

Lines changed: 0 additions & 65 deletions
This file was deleted.
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
/*
2+
* Copyright 2019-2029 geekidea(https://github.com/geekidea)
3+
* Licensed under the Apache License, Version 2.0 (the "License");
4+
* you may not use this file except in compliance with the License.
5+
* You may obtain a copy of the License at
6+
* http://www.apache.org/licenses/LICENSE-2.0
7+
* Unless required by applicable law or agreed to in writing, software
8+
* distributed under the License is distributed on an "AS IS" BASIS,
9+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10+
* See the License for the specific language governing permissions and
11+
* limitations under the License.
12+
*/
13+
14+
package io.geekidea.springbootplus.core;
15+
16+
import lombok.Data;
17+
import lombok.experimental.Accessors;
18+
import org.springframework.boot.context.properties.NestedConfigurationProperty;
19+
20+
/**
21+
* @author geekidea
22+
* @date 2019-09-29
23+
* @since 1.3.0.RELEASE
24+
**/
25+
@Data
26+
@Accessors(chain = true)
27+
public class SpringBootPlusFilterConfig {
28+
29+
/**
30+
* 请求路径Filter配置
31+
*/
32+
@NestedConfigurationProperty
33+
private FilterConfig requestPathConfig = new FilterConfig();
34+
35+
/**
36+
* 跨域Filter配置
37+
*/
38+
@NestedConfigurationProperty
39+
private FilterConfig crossDomainConfig = new FilterConfig();
40+
41+
@Data
42+
public static class FilterConfig {
43+
44+
/**
45+
* 是否启用
46+
*/
47+
private boolean enabled;
48+
49+
/**
50+
* 包含的路径
51+
*/
52+
private String[] includePaths;
53+
54+
/**
55+
* 排除路径
56+
*/
57+
private String[] excludePaths;
58+
59+
}
60+
}

src/main/resources/config/application.yml

Lines changed: 50 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,10 @@ spring:
3333
spring:
3434
profiles:
3535
active: '@profileActive@'
36-
################################ spring config end ################################
36+
################################ spring config end #################################
3737

3838

39-
############################## spring-boot-plus start #############################
39+
############################## spring-boot-plus start ##############################
4040
spring-boot-plus:
4141
# jwt配置
4242
jwt:
@@ -45,30 +45,35 @@ spring-boot-plus:
4545
issuer: spring-boot-plus
4646
subject: spring-boot-plus-jwt
4747
audience: web
48-
expire-minutes: 2
48+
# 默认过期时间30分钟,单位:秒
49+
expire-second: 1800
4950
# 拦截器配置
5051
interceptor-config:
51-
jwt-config:
52-
enabled: false
53-
include-path: /**
54-
exclude-path: /swagger-resources/**,/api-docs/**,/v2/api-docs/**,/login,/verificationCode,/doc/**,/error/**,/docs,/test/**,/resource/**
5552
permission-config:
5653
enabled: false
57-
include-path: /**
58-
exclude-path: /swagger-resources/**,/api-docs/**,/v2/api-docs/**,/adminLogin,/sysLogin,/login.html,/verificationCode,/doc/**,/error/**,/docs,/resource/**
59-
token-timeout-config:
60-
enabled: false
61-
include-path: /**
62-
exclude-path: /swagger-resources/**,/api-docs/**,/v2/api-docs/**,/docs,/resource/**
54+
include-paths: /**
55+
exclude-paths: /swagger-resources/**,/api-docs/**,/v2/api-docs/**,/adminLogin,/sysLogin,/login.html,/verificationCode,/doc/**,/error/**,/docs,/resource/**
6356
resource-config:
6457
enabled: true
65-
include-path: ${spring-boot-plus.resource-access-patterns}
58+
include-paths: ${spring-boot-plus.resource-access-patterns}
6659
upload-config:
6760
enabled: true
68-
include-path: /upload/**
61+
include-paths: /upload/**
6962
download-config:
7063
enabled: true
71-
include-path: /download/**
64+
include-paths: /download/**
65+
66+
# 过滤器配置
67+
filter-config:
68+
# 请求路径Filter配置
69+
request-path-config:
70+
enabled: true
71+
include-paths: /**
72+
# 跨域Filter配置
73+
cross-domain-config:
74+
enabled: true
75+
include-paths: /**
76+
7277
# 文件上传下载配置
7378
# 上传路径配置
7479
upload-path: /opt/upload/
@@ -81,9 +86,38 @@ spring-boot-plus:
8186
# 全局允许上传的类型
8287
allow-upload-file-extensions: jpg,png,docx,xlsx,pptx,pdf
8388
allow-download-file-extensions: jpg,png,docx,xlsx,pptx,pdf
89+
90+
# Shiro配置
91+
shiro-config:
92+
# shiro ini 多行字符串配置
93+
filter-chain-definitions: |
94+
/=anon
95+
/static/**=anon
96+
/templates/**=anon
97+
# 权限配置
98+
permission-config:
99+
# 排除登陆相关
100+
- urls: /login,/login.html,/welcome.html,/index.html
101+
permission: anon
102+
# 排除Swagger
103+
- urls: /docs,/swagger-ui.html, /webjars/springfox-swagger-ui/**,/swagger-resources/**,/v2/api-docs
104+
permission: anon
105+
# 排除SpringBootAdmin
106+
- urls: /,/favicon.ico,/actuator/**,/instances/**,/assets/**,/sba-settings.js,/applications/**
107+
permission: anon
108+
# 测试
109+
- url: /sysUser/getPageList
110+
permission: anon
111+
84112
############################### spring-boot-plus end ###############################
85113

86114

115+
############################## Spring Shiro start ##############################
116+
117+
118+
############################### Spring Shiro end ###############################
119+
120+
87121
############################### mybatis-plus start #################################
88122
mybatis-plus:
89123
check-config-location: true

0 commit comments

Comments
 (0)