Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
I
ioc_sixiang_license
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
zengtianlai3
ioc_sixiang_license
Commits
035f9501
Commit
035f9501
authored
Jun 14, 2022
by
zengtianlai3
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' into 'm33'
# Conflicts: # license/pom.xml
parents
68341bf9
9fabaa02
Changes
11
Show whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
161 additions
and
58 deletions
+161
-58
.gitignore
.gitignore
+0
-1
Maven__com_auth0_java_jwt_3_8_2.xml
.idea/libraries/Maven__com_auth0_java_jwt_3_8_2.xml
+0
-13
Maven__commons_codec_commons_codec_1_15.xml
.idea/libraries/Maven__commons_codec_commons_codec_1_15.xml
+0
-13
Maven__org_apache_commons_commons_collections4_4_1.xml
...es/Maven__org_apache_commons_commons_collections4_4_1.xml
+0
-13
Maven__org_apache_poi_poi_3_17.xml
.idea/libraries/Maven__org_apache_poi_poi_3_17.xml
+0
-13
pom.xml
license/pom.xml
+7
-0
CorsConfig.java
.../src/main/java/iot/sixiang/license/config/CorsConfig.java
+2
-3
BaseSwaggerConfig.java
...iot/sixiang/license/config/swagger/BaseSwaggerConfig.java
+76
-0
SwaggerConfig.java
...ava/iot/sixiang/license/config/swagger/SwaggerConfig.java
+25
-0
SwaggerProperties.java
...iot/sixiang/license/config/swagger/SwaggerProperties.java
+43
-0
JwtFilter.java
license/src/main/java/iot/sixiang/license/jwt/JwtFilter.java
+8
-2
No files found.
.gitignore
View file @
035f9501
.idea
.idea
\ No newline at end of file
.idea/libraries/Maven__com_auth0_java_jwt_3_8_2.xml
deleted
100644 → 0
View file @
68341bf9
<component
name=
"libraryTable"
>
<library
name=
"Maven: com.auth0:java-jwt:3.8.2"
>
<CLASSES>
<root
url=
"jar://C:/tools/Spring/mvn_repository/com/auth0/java-jwt/3.8.2/java-jwt-3.8.2.jar!/"
/>
</CLASSES>
<JAVADOC>
<root
url=
"jar://C:/tools/Spring/mvn_repository/com/auth0/java-jwt/3.8.2/java-jwt-3.8.2-javadoc.jar!/"
/>
</JAVADOC>
<SOURCES>
<root
url=
"jar://C:/tools/Spring/mvn_repository/com/auth0/java-jwt/3.8.2/java-jwt-3.8.2-sources.jar!/"
/>
</SOURCES>
</library>
</component>
\ No newline at end of file
.idea/libraries/Maven__commons_codec_commons_codec_1_15.xml
deleted
100644 → 0
View file @
68341bf9
<component
name=
"libraryTable"
>
<library
name=
"Maven: commons-codec:commons-codec:1.15"
>
<CLASSES>
<root
url=
"jar://C:/tools/Spring/mvn_repository/commons-codec/commons-codec/1.15/commons-codec-1.15.jar!/"
/>
</CLASSES>
<JAVADOC>
<root
url=
"jar://C:/tools/Spring/mvn_repository/commons-codec/commons-codec/1.15/commons-codec-1.15-javadoc.jar!/"
/>
</JAVADOC>
<SOURCES>
<root
url=
"jar://C:/tools/Spring/mvn_repository/commons-codec/commons-codec/1.15/commons-codec-1.15-sources.jar!/"
/>
</SOURCES>
</library>
</component>
\ No newline at end of file
.idea/libraries/Maven__org_apache_commons_commons_collections4_4_1.xml
deleted
100644 → 0
View file @
68341bf9
<component
name=
"libraryTable"
>
<library
name=
"Maven: org.apache.commons:commons-collections4:4.1"
>
<CLASSES>
<root
url=
"jar://C:/tools/Spring/mvn_repository/org/apache/commons/commons-collections4/4.1/commons-collections4-4.1.jar!/"
/>
</CLASSES>
<JAVADOC>
<root
url=
"jar://C:/tools/Spring/mvn_repository/org/apache/commons/commons-collections4/4.1/commons-collections4-4.1-javadoc.jar!/"
/>
</JAVADOC>
<SOURCES>
<root
url=
"jar://C:/tools/Spring/mvn_repository/org/apache/commons/commons-collections4/4.1/commons-collections4-4.1-sources.jar!/"
/>
</SOURCES>
</library>
</component>
\ No newline at end of file
.idea/libraries/Maven__org_apache_poi_poi_3_17.xml
deleted
100644 → 0
View file @
68341bf9
<component
name=
"libraryTable"
>
<library
name=
"Maven: org.apache.poi:poi:3.17"
>
<CLASSES>
<root
url=
"jar://C:/tools/Spring/mvn_repository/org/apache/poi/poi/3.17/poi-3.17.jar!/"
/>
</CLASSES>
<JAVADOC>
<root
url=
"jar://C:/tools/Spring/mvn_repository/org/apache/poi/poi/3.17/poi-3.17-javadoc.jar!/"
/>
</JAVADOC>
<SOURCES>
<root
url=
"jar://C:/tools/Spring/mvn_repository/org/apache/poi/poi/3.17/poi-3.17-sources.jar!/"
/>
</SOURCES>
</library>
</component>
\ No newline at end of file
license/pom.xml
View file @
035f9501
...
@@ -65,6 +65,13 @@
...
@@ -65,6 +65,13 @@
<version>
2.0
</version>
<version>
2.0
</version>
</dependency>
</dependency>
<!--Knife4j API文档生产工具-->
<dependency>
<groupId>
com.github.xiaoymin
</groupId>
<artifactId>
knife4j-spring-boot-starter
</artifactId>
<version>
2.0.9
</version>
</dependency>
<dependency>
<dependency>
<groupId>
com.alibaba
</groupId>
<groupId>
com.alibaba
</groupId>
<artifactId>
fastjson
</artifactId>
<artifactId>
fastjson
</artifactId>
...
...
license/src/main/java/iot/sixiang/license/config/CorsConfig.java
View file @
035f9501
...
@@ -24,8 +24,8 @@ public class CorsConfig implements WebMvcConfigurer {
...
@@ -24,8 +24,8 @@ public class CorsConfig implements WebMvcConfigurer {
@Override
@Override
public
void
addResourceHandlers
(
ResourceHandlerRegistry
registry
)
{
public
void
addResourceHandlers
(
ResourceHandlerRegistry
registry
)
{
// TODO Auto-generated method stub
registry
.
addResourceHandler
(
"doc.html"
).
addResourceLocations
(
"classpath:/META-INF/resources/"
);
registry
.
addResourceHandler
(
"/webjars/**"
).
addResourceLocations
(
"classpath:/META-INF/resources/webjars/"
);
}
}
@Override
@Override
...
@@ -33,5 +33,4 @@ public class CorsConfig implements WebMvcConfigurer {
...
@@ -33,5 +33,4 @@ public class CorsConfig implements WebMvcConfigurer {
registry
.
addInterceptor
(
authenticationInterceptor
)
registry
.
addInterceptor
(
authenticationInterceptor
)
.
addPathPatterns
(
"/**"
);
.
addPathPatterns
(
"/**"
);
}
}
}
}
license/src/main/java/iot/sixiang/license/config/swagger/BaseSwaggerConfig.java
0 → 100644
View file @
035f9501
package
iot
.
sixiang
.
license
.
config
.
swagger
;
import
org.springframework.context.annotation.Bean
;
import
springfox.documentation.builders.ApiInfoBuilder
;
import
springfox.documentation.builders.PathSelectors
;
import
springfox.documentation.builders.RequestHandlerSelectors
;
import
springfox.documentation.service.*
;
import
springfox.documentation.spi.DocumentationType
;
import
springfox.documentation.spi.service.contexts.SecurityContext
;
import
springfox.documentation.spring.web.plugins.Docket
;
import
java.util.ArrayList
;
import
java.util.List
;
public
abstract
class
BaseSwaggerConfig
{
@Bean
public
Docket
createRestApi
()
{
SwaggerProperties
swaggerProperties
=
swaggerProperties
();
Docket
docket
=
new
Docket
(
DocumentationType
.
SWAGGER_2
)
.
apiInfo
(
apiInfo
(
swaggerProperties
))
.
select
()
.
apis
(
RequestHandlerSelectors
.
basePackage
(
swaggerProperties
.
getApiBasePackage
()))
.
paths
(
PathSelectors
.
any
())
.
build
();
if
(
swaggerProperties
.
isEnableSecurity
())
{
docket
.
securitySchemes
(
securitySchemes
()).
securityContexts
(
securityContexts
());
}
return
docket
;
}
private
ApiInfo
apiInfo
(
SwaggerProperties
swaggerProperties
)
{
return
new
ApiInfoBuilder
()
.
title
(
swaggerProperties
.
getTitle
())
.
description
(
swaggerProperties
.
getDescription
())
.
contact
(
new
Contact
(
swaggerProperties
.
getContactName
(),
swaggerProperties
.
getContactUrl
(),
swaggerProperties
.
getContactEmail
()))
.
version
(
swaggerProperties
.
getVersion
())
.
build
();
}
private
List
<
ApiKey
>
securitySchemes
()
{
//设置请求头信息
List
<
ApiKey
>
result
=
new
ArrayList
<>();
ApiKey
apiKey
=
new
ApiKey
(
"Authorization"
,
"Authorization"
,
"header"
);
result
.
add
(
apiKey
);
return
result
;
}
private
List
<
SecurityContext
>
securityContexts
()
{
//设置需要登录认证的路径
List
<
SecurityContext
>
result
=
new
ArrayList
<>();
result
.
add
(
getContextByPath
(
"/*/.*"
));
return
result
;
}
private
SecurityContext
getContextByPath
(
String
pathRegex
)
{
return
SecurityContext
.
builder
()
.
securityReferences
(
defaultAuth
())
.
forPaths
(
PathSelectors
.
regex
(
pathRegex
))
.
build
();
}
private
List
<
SecurityReference
>
defaultAuth
()
{
List
<
SecurityReference
>
result
=
new
ArrayList
<>();
AuthorizationScope
authorizationScope
=
new
AuthorizationScope
(
"global"
,
"accessEverything"
);
AuthorizationScope
[]
authorizationScopes
=
new
AuthorizationScope
[
1
];
authorizationScopes
[
0
]
=
authorizationScope
;
result
.
add
(
new
SecurityReference
(
"Authorization"
,
authorizationScopes
));
return
result
;
}
/**
* 自定义Swagger配置
*/
public
abstract
SwaggerProperties
swaggerProperties
();
}
license/src/main/java/iot/sixiang/license/config/swagger/SwaggerConfig.java
0 → 100644
View file @
035f9501
package
iot
.
sixiang
.
license
.
config
.
swagger
;
import
org.springframework.context.annotation.Configuration
;
import
springfox.documentation.swagger2.annotations.EnableSwagger2WebMvc
;
/**
* Created by M=54G
* Date 4/27/21 9:37 AM
* Description API文档相关配置
*/
@Configuration
@EnableSwagger2WebMvc
public
class
SwaggerConfig
extends
BaseSwaggerConfig
{
@Override
public
SwaggerProperties
swaggerProperties
()
{
return
SwaggerProperties
.
builder
()
.
apiBasePackage
(
"iot.sixiang.license.controller"
)
.
title
(
"实名制接口"
)
.
description
(
"实名制接口文档"
)
.
contactName
(
"ACC"
)
.
version
(
"1.0"
)
.
enableSecurity
(
true
)
.
build
();
}
}
license/src/main/java/iot/sixiang/license/config/swagger/SwaggerProperties.java
0 → 100644
View file @
035f9501
package
iot
.
sixiang
.
license
.
config
.
swagger
;
import
lombok.Builder
;
import
lombok.Data
;
import
lombok.EqualsAndHashCode
;
@Data
@EqualsAndHashCode
(
callSuper
=
false
)
@Builder
public
class
SwaggerProperties
{
/**
* API文档生成基础路径
*/
private
String
apiBasePackage
;
/**
* 是否要启用登录认证
*/
private
boolean
enableSecurity
;
/**
* 文档标题
*/
private
String
title
;
/**
* 文档描述
*/
private
String
description
;
/**
* 文档版本
*/
private
String
version
;
/**
* 文档联系人姓名
*/
private
String
contactName
;
/**
* 文档联系人网址
*/
private
String
contactUrl
;
/**
* 文档联系人邮箱
*/
private
String
contactEmail
;
}
license/src/main/java/iot/sixiang/license/jwt/JwtFilter.java
View file @
035f9501
...
@@ -5,7 +5,6 @@ import com.auth0.jwt.interfaces.Claim;
...
@@ -5,7 +5,6 @@ import com.auth0.jwt.interfaces.Claim;
import
com.auth0.jwt.interfaces.DecodedJWT
;
import
com.auth0.jwt.interfaces.DecodedJWT
;
import
iot.sixiang.license.model.ResResult
;
import
iot.sixiang.license.model.ResResult
;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.http.HttpStatus
;
import
javax.servlet.*
;
import
javax.servlet.*
;
import
javax.servlet.annotation.WebFilter
;
import
javax.servlet.annotation.WebFilter
;
...
@@ -20,6 +19,13 @@ public class JwtFilter implements Filter {
...
@@ -20,6 +19,13 @@ public class JwtFilter implements Filter {
private
static
final
String
url1
=
"/login"
;
private
static
final
String
url1
=
"/login"
;
private
static
final
String
url2
=
"/resource"
;
private
static
final
String
url2
=
"/resource"
;
private
static
final
String
url3
=
"/doc.html"
;
private
static
final
String
url4
=
"/v3/swagger-login"
;
private
static
final
String
url5
=
"/swagger-ui.html"
;
private
static
final
String
url6
=
"/static"
;
private
static
final
String
url7
=
"/swagger-resources"
;
private
static
final
String
url8
=
"/webjars/"
;
@Override
@Override
public
void
init
(
FilterConfig
filterConfig
)
throws
ServletException
{
public
void
init
(
FilterConfig
filterConfig
)
throws
ServletException
{
...
@@ -40,7 +46,7 @@ public class JwtFilter implements Filter {
...
@@ -40,7 +46,7 @@ public class JwtFilter implements Filter {
String
token
=
request
.
getHeader
(
"authorization"
);
String
token
=
request
.
getHeader
(
"authorization"
);
boolean
check
=
true
;
boolean
check
=
true
;
String
uri
=
request
.
getRequestURI
();
String
uri
=
request
.
getRequestURI
();
if
(
uri
.
contains
(
url1
)
||
uri
.
contains
(
url2
))
{
if
(
uri
.
contains
(
url1
)
||
uri
.
contains
(
url2
)
||
uri
.
contains
(
url3
)
||
uri
.
contains
(
url4
)
||
uri
.
contains
(
url5
)
||
uri
.
contains
(
url6
)
||
uri
.
contains
(
url7
)
||
uri
.
contains
(
url8
)
)
{
check
=
false
;
check
=
false
;
}
}
if
(!
check
)
{
if
(!
check
)
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment