Skip to content

Commit ec3ca93

Browse files
committed
merge security
1 parent aa1e377 commit ec3ca93

File tree

100 files changed

+906
-27
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

100 files changed

+906
-27
lines changed

README.md

Lines changed: 28 additions & 1 deletion

pom.xml

Lines changed: 61 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,15 @@
22
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
33
<modelVersion>4.0.0</modelVersion>
44
<packaging>pom</packaging>
5-
<parent>
5+
<parent>
66
<groupId>org.springframework.boot</groupId>
77
<artifactId>spring-boot-starter-parent</artifactId>
8-
<version>2.5.4</version>
8+
<version>2.7.1</version>
99
<relativePath /> <!-- lookup parent from repository -->
1010
</parent>
1111
<groupId>com.codingapi.springboot</groupId>
1212
<artifactId>springboot-framework-parent</artifactId>
13-
<version>1.0.5</version>
13+
<version>0.0.1</version>
1414

1515
<url>https://github.com/codingapi/springboot-framewrok</url>
1616
<name>springboot-framework-parent</name>
@@ -30,6 +30,10 @@
3030
<nexus.staging.maven.plugin>1.6.3</nexus.staging.maven.plugin>
3131

3232
<fastjson.version>2.0.7</fastjson.version>
33+
<jsonwebtoken.jjwt.version>0.11.5</jsonwebtoken.jjwt.version>
34+
<codingapi.framework.version>0.0.1</codingapi.framework.version>
35+
<commons-io.version>2.7</commons-io.version>
36+
<commons-dbutils.version>1.7</commons-dbutils.version>
3337

3438
</properties>
3539

@@ -63,6 +67,51 @@
6367
<artifactId>fastjson</artifactId>
6468
<version>${fastjson.version}</version>
6569
</dependency>
70+
71+
<dependency>
72+
<groupId>commons-io</groupId>
73+
<artifactId>commons-io</artifactId>
74+
<version>${commons-io.version}</version>
75+
</dependency>
76+
77+
78+
<dependency>
79+
<groupId>io.jsonwebtoken</groupId>
80+
<artifactId>jjwt-api</artifactId>
81+
<version>${jsonwebtoken.jjwt.version}</version>
82+
</dependency>
83+
84+
<dependency>
85+
<groupId>io.jsonwebtoken</groupId>
86+
<artifactId>jjwt-impl</artifactId>
87+
<version>${jsonwebtoken.jjwt.version}</version>
88+
</dependency>
89+
90+
<dependency>
91+
<groupId>io.jsonwebtoken</groupId>
92+
<artifactId>jjwt-jackson</artifactId>
93+
<version>${jsonwebtoken.jjwt.version}</version>
94+
</dependency>
95+
96+
<dependency>
97+
<groupId>com.codingapi.springboot</groupId>
98+
<artifactId>springboot-starter</artifactId>
99+
<version>${codingapi.framework.version}</version>
100+
</dependency>
101+
102+
<dependency>
103+
<groupId>com.codingapi.springboot</groupId>
104+
<artifactId>springboot-starter-security-jwt</artifactId>
105+
<version>${codingapi.framework.version}</version>
106+
</dependency>
107+
108+
109+
<dependency>
110+
<groupId>commons-dbutils</groupId>
111+
<artifactId>commons-dbutils</artifactId>
112+
<version>${commons-dbutils.version}</version>
113+
</dependency>
114+
66115
</dependencies>
67116
</dependencyManagement>
68117

@@ -121,9 +170,10 @@
121170
<activeByDefault>true</activeByDefault>
122171
</activation>
123172
<modules>
124-
<module>springboot-framework</module>
173+
<module>springboot-starter</module>
125174
<module>springboot-example</module>
126-
<module>springboot-data-permission</module>
175+
<module>springboot-starter-data-permission</module>
176+
<module>springboot-starter-security-jwt</module>
127177
</modules>
128178
</profile>
129179

@@ -132,9 +182,10 @@
132182
<id>travis</id>
133183

134184
<modules>
135-
<module>springboot-framework</module>
185+
<module>springboot-starter</module>
136186
<module>springboot-example</module>
137-
<module>springboot-data-permission</module>
187+
<module>springboot-starter-data-permission</module>
188+
<module>springboot-starter-security-jwt</module>
138189
</modules>
139190

140191
<build>
@@ -178,8 +229,9 @@
178229
<id>ossrh</id>
179230

180231
<modules>
181-
<module>springboot-framework</module>
182-
<module>springboot-data-permission</module>
232+
<module>springboot-starter</module>
233+
<module>springboot-starter-data-permission</module>
234+
<module>springboot-starter-security-jwt</module>
183235
</modules>
184236

185237

springboot-example/pom.xml

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@
44
<parent>
55
<groupId>com.codingapi.springboot</groupId>
66
<artifactId>springboot-framework-parent</artifactId>
7-
<version>1.0.5</version>
7+
<version>0.0.1</version>
88
</parent>
99
<artifactId>springboot-example</artifactId>
10-
<version>1.0.5</version>
10+
<version>0.0.1</version>
1111

1212
<name>springboot-example</name>
1313
<description>springboot-example project for Spring Boot</description>
@@ -28,8 +28,12 @@
2828

2929
<dependency>
3030
<groupId>com.codingapi.springboot</groupId>
31-
<artifactId>springboot-framework</artifactId>
32-
<version>1.0.5</version>
31+
<artifactId>springboot-starter</artifactId>
32+
</dependency>
33+
34+
<dependency>
35+
<groupId>com.codingapi.springboot</groupId>
36+
<artifactId>springboot-starter-security-jwt</artifactId>
3337
</dependency>
3438

3539
<dependency>

springboot-example/src/main/java/com/codingapi/springboot/example/controller/DemoController.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
import com.codingapi.springboot.framework.dto.response.Response;
44
import com.codingapi.springboot.framework.dto.response.SingleResponse;
55
import com.codingapi.springboot.framework.exception.LocaleMessageException;
6+
import org.springframework.security.access.prepost.PreAuthorize;
7+
import org.springframework.security.core.context.SecurityContextHolder;
68
import org.springframework.web.bind.annotation.GetMapping;
79
import org.springframework.web.bind.annotation.RequestMapping;
810
import org.springframework.web.bind.annotation.RestController;
@@ -11,6 +13,14 @@
1113
@RequestMapping("/demo")
1214
public class DemoController {
1315

16+
@GetMapping("/index")
17+
@PreAuthorize(value = "hasRole('ROLE_ADMIN')")
18+
public String index(){
19+
String loginUserName = SecurityContextHolder.getContext().getAuthentication().getName();
20+
return "hello:"+loginUserName;
21+
}
22+
23+
1424
@GetMapping("/error")
1525
public Response error(){
1626
throw new LocaleMessageException("hello.error");

springboot-example/src/main/resources/application.properties

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,9 @@ spring.datasource.url=jdbc:h2:file:./demo.db
55
spring.jpa.database-platform=org.hibernate.dialect.H2Dialect
66
spring.jpa.hibernate.ddl-auto=create-drop
77
spring.jpa.show-sql=true
8+
9+
security.jwt.properties.jwt-secret-key=YWRmc2Rhc2Rkc3h4eDEyM3NkZnNkZkFTQVNEc2RGQCMkIyRRQVNEYXNkQVNBU0RBU0RTQUZTREZTREZBU0Rkc2Rm
10+
#15\u5206\u949F\u6709\u6548\u671F 1000*60*15=900000
11+
security.jwt.properties.jwt-time=900000
12+
#10\u5206\u949F\u540E\u66F4\u6362\u4EE4\u724C 1000*60*10=600000
13+
security.jwt.properties.jwt-rest-time=600000
Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,4 @@
1-
hello.error=Hello Error
1+
hello.error=Hello Error
2+
login.error = login error
3+
token.expire = token expire
4+
api.error = this is an error info
Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,4 @@
1-
hello.error=Hello Error
1+
hello.error=Hello Error
2+
login.error = login error
3+
token.expire = token expire
4+
api.error = this is an error info
Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,4 @@
1-
hello.error=你好 出错了
1+
hello.error=你好 出错了
2+
login.error = \u767B\u9646\u5931\u8D25
3+
token.expire = TOKEN\u8FC7\u671F
4+
api.error = \u8FD9\u662F\u4E00\u4E2A\u9519\u8BEF\u63D0\u793A\u4FE1\u606F

springboot-data-permission/pom.xml renamed to springboot-starter-data-permission/pom.xml

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@
55
<parent>
66
<artifactId>springboot-framework-parent</artifactId>
77
<groupId>com.codingapi.springboot</groupId>
8-
<version>1.0.5</version>
8+
<version>0.0.1</version>
99
</parent>
1010
<modelVersion>4.0.0</modelVersion>
1111

12-
<artifactId>springboot-data-permission</artifactId>
12+
<artifactId>springboot-starter-data-permission</artifactId>
1313

1414
<properties>
1515
<java.version>1.8</java.version>
@@ -20,7 +20,6 @@
2020
<dependency>
2121
<groupId>commons-dbutils</groupId>
2222
<artifactId>commons-dbutils</artifactId>
23-
<version>1.7</version>
2423
</dependency>
2524

2625

@@ -31,8 +30,7 @@
3130

3231
<dependency>
3332
<groupId>com.codingapi.springboot</groupId>
34-
<artifactId>springboot-framework</artifactId>
35-
<version>1.0.5</version>
33+
<artifactId>springboot-starter</artifactId>
3634
</dependency>
3735

3836
<dependency>

0 commit comments

Comments
 (0)