Skip to content

Commit 4e8756e

Browse files
Merge pull request #61 from geekidea/dev
🇨🇳 1.3.0.RELEASE shiro+jwt
2 parents 1fbcf5d + 9554f40 commit 4e8756e

35 files changed

+462
-356
lines changed

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# 更新日志 CHANGELOG
22

3-
## [V1.3.0-RELEASE]
3+
## [V1.3.0-RELEASE] 2019.10.05
44

55
### ⭐️ New Features
66

CODE_OF_CONDUCT.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,3 +74,4 @@ available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.ht
7474

7575
For answers to common questions about this code of conduct, see
7676
https://www.contributor-covenant.org/faq
77+

CONTRIBUTING.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
# Welcome pull request
2+

README-zh.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
2. 集成mybatis plus快速dao操作
3939
3. 快速生成后台代码: entity/param/vo/controller/service/mapper/xml
4040
4. 集成swagger2,可自动生成api文档
41-
5. 集成jwt、spring security权限控制
41+
5. 集成jwt、shiro/spring security权限控制
4242
6. 集成redis、spring cache、ehcache缓存
4343
7. 集成rabbit/rocket/kafka mq消息队列
4444
8. 集成druid连接池,JDBC性能和慢查询检测
@@ -71,9 +71,11 @@ commons-codec | 1.13 | 加密解密等工具包 |
7171
commons-collections4 | 4.4 | 集合工具包 |
7272
reflections | 0.9.11 | 反射工具包 |
7373
hibernate-validator | 6.0.17.Final | 后台参数校验注解 |
74-
jwt | 0.9.1 | json web token |
74+
Shiro | 1.4.0 | 权限控制 |
75+
JWT | 3.8.3 | JSON WEB TOKEN |
7576
hutool-all | 4.6.4 | 常用工具集 |
7677
lombok | 1.18.8 | 注解生成Java Bean等工具 |
78+
mapstruct | 1.3.0.Final | 对象属性复制工具 |
7779

7880
## CHANGELOG
7981
#### [CHANGELOG.md](https://github.com/geekidea/spring-boot-plus/blob/master/CHANGELOG.md)

README.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
- Integrated mybatis-plus fast dao operation
4141
- Quickly generate background code:entity/param/vo/controller/service/mapper/xml
4242
- Integrated swagger2, automatic generation of api documents
43-
- Integrated JWT, spring security permission control
43+
- Integrated JWT,Shiro/Spring security permission control
4444
- Integrated Redis、spring cache、ehcache,etc
4545
- Integrated Rabbit/Rocket/Kafka MQ
4646
- Integration alibaba druid connection pool, JDBC performance and slow query detection
@@ -73,9 +73,11 @@ commons-codec | 1.13 | Apache Toolkit such as encryption and decryption |
7373
commons-collections4 | 4.4 | Apache collections toolkit |
7474
reflections | 0.9.11 | Reflection Toolkit |
7575
hibernate-validator | 6.0.17.Final | Validator toolkit |
76-
jwt | 0.9.1 | JSON WEB TOKEN |
76+
Shiro | 1.4.0 | Permission control |
77+
JWT | 3.8.3 | JSON WEB TOKEN |
7778
hutool-all | 4.6.4 | Common toolset |
7879
lombok | 1.18.8 | Automatically plugs |
80+
mapstruct | 1.3.0.Final | Object property replication tool |
7981

8082
## CHANGELOG
8183
#### [CHANGELOG.md](https://github.com/geekidea/spring-boot-plus/blob/master/CHANGELOG.md)

pom.xml

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -63,11 +63,13 @@
6363
<jansi.version>1.18</jansi.version>
6464
<lombok.version>1.18.8</lombok.version>
6565
<commons-pool2.version>2.7.0</commons-pool2.version>
66-
<jwt.version>0.9.1</jwt.version>
6766
<spring-boot-admin.version>2.1.6</spring-boot-admin.version>
6867
<hutool.version>4.6.4</hutool.version>
6968
<junit.version>4.12</junit.version>
69+
<ini.version>0.5.4</ini.version>
7070
<mapstruct.version>1.3.0.Final</mapstruct.version>
71+
<shiro.version>1.4.0</shiro.version>
72+
<jwt.version>3.8.3</jwt.version>
7173

7274
<maven-compiler-plugin.version>3.8.1</maven-compiler-plugin.version>
7375
<maven-resources-plugin.version>3.1.0</maven-resources-plugin.version>
@@ -265,12 +267,14 @@
265267
</dependency>
266268
<!-- spring boot admin end -->
267269

270+
<!-- ini格式处理 -->
268271
<dependency>
269272
<groupId>org.ini4j</groupId>
270273
<artifactId>ini4j</artifactId>
271-
<version>0.5.4</version>
274+
<version>${ini.version}</version>
272275
</dependency>
273276

277+
<!-- 对象属性复制 -->
274278
<dependency>
275279
<groupId>org.mapstruct</groupId>
276280
<artifactId>mapstruct</artifactId>
@@ -283,29 +287,22 @@
283287
<scope>provided</scope>
284288
</dependency>
285289

286-
<!-- Shiro JWT start -->
290+
<!-- Shiro+JWT start -->
287291
<dependency>
288292
<groupId>org.apache.shiro</groupId>
289293
<artifactId>shiro-spring-boot-web-starter</artifactId>
290-
<version>1.4.0</version>
294+
<version>${shiro.version}</version>
291295
</dependency>
292-
293296
<dependency>
294297
<groupId>com.auth0</groupId>
295298
<artifactId>java-jwt</artifactId>
296-
<version>3.8.3</version>
299+
<version>${jwt.version}</version>
297300
</dependency>
298-
299-
<!-- <dependency>-->
300-
<!-- <groupId>io.jsonwebtoken</groupId>-->
301-
<!-- <artifactId>jjwt</artifactId>-->
302-
<!-- <version>${jwt.version}</version>-->
303-
<!-- </dependency>-->
304-
305-
<!-- Spring Security JWT start -->
301+
<!-- Shiro+JWT end -->
306302

307303
</dependencies>
308304

305+
309306
<build>
310307
<finalName>spring-boot-plus</finalName>
311308

src/main/java/io/geekidea/springbootplus/common/aop/LogAop.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
import com.alibaba.fastjson.JSONObject;
2121
import io.geekidea.springbootplus.common.api.ApiCode;
2222
import io.geekidea.springbootplus.common.api.ApiResult;
23+
import io.geekidea.springbootplus.shiro.util.JwtTokenUtil;
2324
import io.geekidea.springbootplus.util.AnsiUtil;
2425
import io.geekidea.springbootplus.util.DateUtil;
2526
import io.geekidea.springbootplus.util.IpUtil;
@@ -131,7 +132,7 @@ public Object doAround(ProceedingJoinPoint joinPoint) throws Throwable {
131132
map.put("time", DateUtil.getYYYYMMDDHHMMSS(new Date()));
132133

133134
// 获取请求头token
134-
map.put("x-auth-token",request.getHeader("x-auth-token"));
135+
map.put("token",request.getHeader(JwtTokenUtil.getTokenName()));
135136

136137
String requestInfo = null;
137138
try {

src/main/java/io/geekidea/springbootplus/common/constant/CommonConstant.java

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,14 +41,13 @@ public interface CommonConstant {
4141
/**
4242
* 登陆token
4343
*/
44-
String JWT_TOKEN_NAME = "token";
44+
String JWT_DEFAULT_TOKEN_NAME = "token";
4545

4646
/**
4747
* JWT用户名
4848
*/
4949
String JWT_USERNAME = "username";
5050

51-
5251
/**
5352
* JWT刷新新token响应状态码
5453
*/
@@ -60,6 +59,15 @@ public interface CommonConstant {
6059
*/
6160
int JWT_INVALID_TOKEN_CODE = 461;
6261

62+
/**
63+
* JWT Token默认密钥
64+
*/
65+
String JWT_DEFAULT_SECRET = "666666";
66+
67+
/**
68+
* JWT 默认过期时间,3600L,单位秒
69+
*/
70+
Long JWT_DEFAULT_EXPIRE_SECOND = 3600L;
6371

6472
/**
6573
* 初始密码

src/main/java/io/geekidea/springbootplus/common/web/filter/CrossDomainFilter.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ public void doFilter(ServletRequest servletRequest, ServletResponse servletRespo
4646
httpServletResponse.setHeader("Access-Control-Allow-Methods", "*");
4747
httpServletResponse.setHeader("Access-Control-Allow-Headers", "*");
4848
httpServletResponse.setHeader("Access-Control-Request-Headers","*");
49-
httpServletResponse.setHeader("Access-Control-Allow-Headers", "content-type,x-auth-token");
49+
httpServletResponse.setHeader("Access-Control-Allow-Headers", "content-type,token");
5050
httpServletResponse.setHeader("Access-Control-Expose-Headers", "*");
5151

5252
HttpServletRequest request = (HttpServletRequest) servletRequest;

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

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717
package io.geekidea.springbootplus.config;
1818

19+
import io.geekidea.springbootplus.shiro.util.JwtTokenUtil;
1920
import org.springframework.beans.factory.annotation.Value;
2021
import org.springframework.context.annotation.Bean;
2122
import org.springframework.context.annotation.Configuration;
@@ -113,10 +114,17 @@ private ApiInfo apiInfo() {
113114
private List<Parameter> setHeaderToken() {
114115
List<Parameter> pars = new ArrayList<>();
115116

116-
// TODO 测试token值,上线关闭
117+
// token请求头
117118
String testTokenValue = "";
118119
ParameterBuilder tokenPar = new ParameterBuilder();
119-
Parameter tokenParameter = tokenPar.name("token").description("token").modelRef(new ModelRef("string")).parameterType("header").required(false).defaultValue(testTokenValue).build();
120+
Parameter tokenParameter = tokenPar
121+
.name(JwtTokenUtil.getTokenName())
122+
.description("Token Request Header")
123+
.modelRef(new ModelRef("string"))
124+
.parameterType("header")
125+
.required(false)
126+
.defaultValue(testTokenValue)
127+
.build();
120128
pars.add(tokenParameter);
121129
return pars;
122130
}

0 commit comments

Comments
 (0)