Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
cloud-platform
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
youjj
cloud-platform
Commits
42b20f5a
Commit
42b20f5a
authored
Aug 06, 2019
by
jiaorz
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
网关日志限制修改
parent
343f24e1
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
40 additions
and
2 deletions
+40
-2
pom.xml
ace-gate/pom.xml
+6
-0
GatewayServerBootstrap.java
.../github/wxiaoqi/security/gate/GatewayServerBootstrap.java
+1
-2
AccessGatewayFilter.java
...hub/wxiaoqi/security/gate/filter/AccessGatewayFilter.java
+33
-0
No files found.
ace-gate/pom.xml
View file @
42b20f5a
...
@@ -93,6 +93,12 @@
...
@@ -93,6 +93,12 @@
<artifactId>
ace-interface
</artifactId>
<artifactId>
ace-interface
</artifactId>
<version>
2.0-SNAPSHOT
</version>
<version>
2.0-SNAPSHOT
</version>
</dependency>
</dependency>
<dependency>
<groupId>
com.github.wxiaoqi
</groupId>
<artifactId>
ace-admin-api
</artifactId>
<version>
2.0-SNAPSHOT
</version>
<scope>
compile
</scope>
</dependency>
<dependency>
<dependency>
<groupId>
com.github.wxiaoqi
</groupId>
<groupId>
com.github.wxiaoqi
</groupId>
<artifactId>
ace-auth-client
</artifactId>
<artifactId>
ace-auth-client
</artifactId>
...
...
ace-gate/src/main/java/com/github/wxiaoqi/security/gate/GatewayServerBootstrap.java
View file @
42b20f5a
...
@@ -4,7 +4,6 @@ import com.github.wxiaoqi.security.api.vo.config.HeaderConfig;
...
@@ -4,7 +4,6 @@ import com.github.wxiaoqi.security.api.vo.config.HeaderConfig;
import
com.github.wxiaoqi.security.auth.client.EnableAceAuthClient
;
import
com.github.wxiaoqi.security.auth.client.EnableAceAuthClient
;
import
com.github.wxiaoqi.security.gate.utils.DBLog
;
import
com.github.wxiaoqi.security.gate.utils.DBLog
;
import
org.springframework.boot.SpringApplication
;
import
org.springframework.boot.SpringApplication
;
import
org.springframework.boot.autoconfigure.SpringBootApplication
;
import
org.springframework.cloud.client.SpringCloudApplication
;
import
org.springframework.cloud.client.SpringCloudApplication
;
import
org.springframework.cloud.client.discovery.EnableDiscoveryClient
;
import
org.springframework.cloud.client.discovery.EnableDiscoveryClient
;
import
org.springframework.cloud.openfeign.EnableFeignClients
;
import
org.springframework.cloud.openfeign.EnableFeignClients
;
...
@@ -17,7 +16,7 @@ import org.springframework.cloud.openfeign.EnableFeignClients;
...
@@ -17,7 +16,7 @@ import org.springframework.cloud.openfeign.EnableFeignClients;
@SpringCloudApplication
@SpringCloudApplication
@EnableDiscoveryClient
@EnableDiscoveryClient
@EnableAceAuthClient
@EnableAceAuthClient
@EnableFeignClients
(
value
=
{
"com.github.wxiaoqi.security.auth.client.feign"
,
"com.github.wxiaoqi.security.gate.feign"
},
defaultConfiguration
=
HeaderConfig
.
class
)
@EnableFeignClients
(
value
=
{
"com.github.wxiaoqi.security.auth.client.feign"
,
"com.github.wxiaoqi.security.gate.feign"
,
"com.github.wxiaoqi.security.admin.feign"
},
defaultConfiguration
=
HeaderConfig
.
class
)
public
class
GatewayServerBootstrap
{
public
class
GatewayServerBootstrap
{
public
static
void
main
(
String
[]
args
)
{
public
static
void
main
(
String
[]
args
)
{
DBLog
.
getInstance
().
start
();
DBLog
.
getInstance
().
start
();
...
...
ace-gate/src/main/java/com/github/wxiaoqi/security/gate/filter/AccessGatewayFilter.java
View file @
42b20f5a
package
com
.
github
.
wxiaoqi
.
security
.
gate
.
filter
;
package
com
.
github
.
wxiaoqi
.
security
.
gate
.
filter
;
import
com.alibaba.fastjson.JSONObject
;
import
com.alibaba.fastjson.JSONObject
;
import
com.github.wxiaoqi.security.admin.feign.UserFeign
;
import
com.github.wxiaoqi.security.admin.feign.dto.AppUserDTO
;
import
com.github.wxiaoqi.security.admin.feign.dto.UserDTO
;
import
com.github.wxiaoqi.security.api.vo.authority.PermissionInfo
;
import
com.github.wxiaoqi.security.api.vo.authority.PermissionInfo
;
import
com.github.wxiaoqi.security.api.vo.log.LogInfo
;
import
com.github.wxiaoqi.security.api.vo.log.LogInfo
;
import
com.github.wxiaoqi.security.auth.client.config.ServiceAuthConfig
;
import
com.github.wxiaoqi.security.auth.client.config.ServiceAuthConfig
;
...
@@ -67,6 +70,9 @@ public class AccessGatewayFilter implements GlobalFilter {
...
@@ -67,6 +70,9 @@ public class AccessGatewayFilter implements GlobalFilter {
@Lazy
@Lazy
private
ILogService
logService
;
private
ILogService
logService
;
@Autowired
UserFeign
userFeign
;
@Value
(
"${gate.ignore.startWith}"
)
@Value
(
"${gate.ignore.startWith}"
)
private
String
startWith
;
private
String
startWith
;
...
@@ -314,6 +320,8 @@ public class AccessGatewayFilter implements GlobalFilter {
...
@@ -314,6 +320,8 @@ public class AccessGatewayFilter implements GlobalFilter {
private
void
recordLog
(
ServerHttpRequest
request
,
Object
body
)
{
private
void
recordLog
(
ServerHttpRequest
request
,
Object
body
)
{
// 记录要访问的url
// 记录要访问的url
if
(!
getNotLogUri
().
contains
(
request
.
getURI
().
getRawPath
()))
{
if
(!
getNotLogUri
().
contains
(
request
.
getURI
().
getRawPath
()))
{
StringBuilder
builder
=
new
StringBuilder
();
StringBuilder
builder
=
new
StringBuilder
();
log
.
info
(
"=================请求uri:"
+
request
.
getURI
().
getRawPath
());
log
.
info
(
"=================请求uri:"
+
request
.
getURI
().
getRawPath
());
// 记录访问的方法
// 记录访问的方法
...
@@ -325,6 +333,12 @@ public class AccessGatewayFilter implements GlobalFilter {
...
@@ -325,6 +333,12 @@ public class AccessGatewayFilter implements GlobalFilter {
builder
.
append
(
", header { "
);
builder
.
append
(
", header { "
);
for
(
Map
.
Entry
<
String
,
List
<
String
>>
entry
:
request
.
getHeaders
().
entrySet
())
{
for
(
Map
.
Entry
<
String
,
List
<
String
>>
entry
:
request
.
getHeaders
().
entrySet
())
{
builder
.
append
(
entry
.
getKey
()).
append
(
":"
).
append
(
StringUtils
.
join
(
entry
.
getValue
(),
","
)).
append
(
","
);
builder
.
append
(
entry
.
getKey
()).
append
(
":"
).
append
(
StringUtils
.
join
(
entry
.
getValue
(),
","
)).
append
(
","
);
if
(
"Authorization"
.
equals
(
entry
.
getKey
()))
{
if
(
entry
.
getValue
()
!=
null
&&
entry
.
getValue
().
size
()
>
0
)
{
getAdminUserInfo
(
entry
.
getValue
().
get
(
0
));
}
}
}
}
log
.
info
(
"=================请求头header:"
+
builder
.
toString
());
log
.
info
(
"=================请求头header:"
+
builder
.
toString
());
// 记录参数
// 记录参数
...
@@ -343,10 +357,29 @@ public class AccessGatewayFilter implements GlobalFilter {
...
@@ -343,10 +357,29 @@ public class AccessGatewayFilter implements GlobalFilter {
log
.
info
(
"=================请求参数:"
+
builder
.
toString
());
log
.
info
(
"=================请求参数:"
+
builder
.
toString
());
}
}
}
}
private
void
getAdminUserInfo
(
String
token
)
{
if
(
token
!=
null
)
{
UserDTO
userDTO
=
userFeign
.
userinfoByToken
(
token
).
getData
();
if
(
userDTO
!=
null
)
{
log
.
info
(
"=================后台用户名:username = {}"
,
userDTO
.
getUsername
());
log
.
info
(
"=================后台姓名: name = {}"
,
userDTO
.
getName
());
}
else
{
AppUserDTO
appUserDTO
=
userFeign
.
userDetailByToken
(
token
).
getData
();
if
(
appUserDTO
!=
null
)
{
log
.
info
(
"=================APP用户名:userId = {}"
,
appUserDTO
.
getUserid
());
log
.
info
(
"=================APP姓名: name = {}"
,
appUserDTO
.
getRealname
());
log
.
info
(
"=================APP手机号: phone = {}"
,
appUserDTO
.
getUsername
());
}
}
}
}
@Value
(
"${logback.ignore-log-path}"
)
@Value
(
"${logback.ignore-log-path}"
)
String
[]
path
;
String
[]
path
;
public
List
<
String
>
getNotLogUri
()
{
public
List
<
String
>
getNotLogUri
()
{
return
Arrays
.
asList
(
path
);
return
Arrays
.
asList
(
path
);
}
}
}
}
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