Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
Toggle navigation
This project
Loading...
Sign in
谢明辉
/
fanxing3
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit c9b6a2fb
authored
Nov 10, 2021
by
xmh
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
去除auth相关路由,auth已接入微服务,feignClient中使用微服务名称调用
1 parent
34f9d5d6
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
21 additions
and
30 deletions
fanxing-commons/src/main/java/com/viontech/fanxing/commons/config/VionConfig.java
fanxing-gateway/src/main/java/com/viontech/fanxing/forward/AuthClient.java
fanxing-gateway/src/main/java/com/viontech/fanxing/forward/AuthorizationFilter.java
fanxing-gateway/src/main/resources/application.yml
fanxing-commons/src/main/java/com/viontech/fanxing/commons/config/VionConfig.java
View file @
c9b6a2f
...
...
@@ -27,7 +27,7 @@ public class VionConfig {
/** 是否启用转发 */
private
boolean
enableForward
;
/** auth 服务地址 */
private
String
authPath
;
private
Boolean
authEnabled
;
private
Gateway
gateway
;
/** 支持的视频格式列表 */
private
List
<
String
>
supportedVideoFormats
;
...
...
fanxing-gateway/src/main/java/com/viontech/fanxing/forward/AuthClient.java
View file @
c9b6a2f
...
...
@@ -15,10 +15,10 @@ import java.util.Map;
* @author 谢明辉
* @date 2021/9/29
*/
@FeignClient
(
name
=
"
auth"
,
url
=
"${vion.auth-path}
"
)
@FeignClient
(
name
=
"
fanxing-auth
"
)
public
interface
AuthClient
{
@PostMapping
(
value
=
"/a
uth_serv/a
pi/v1/auth/authorize"
,
produces
=
MediaType
.
APPLICATION_JSON_VALUE
)
@PostMapping
(
value
=
"/api/v1/auth/authorize"
,
produces
=
MediaType
.
APPLICATION_JSON_VALUE
)
JSONObject
checkToken
(
@RequestHeader
(
"authorization"
)
String
token
,
@RequestBody
Map
<
String
,
Object
>
data
);
}
fanxing-gateway/src/main/java/com/viontech/fanxing/forward/AuthorizationFilter.java
View file @
c9b6a2f
...
...
@@ -44,22 +44,19 @@ public class AuthorizationFilter implements GlobalFilter {
@Override
public
Mono
<
Void
>
filter
(
ServerWebExchange
exchange
,
GatewayFilterChain
chain
)
{
ServerHttpRequest
request
=
exchange
.
getRequest
();
if
(!
skip
(
request
))
{
if
(
StringUtils
.
isNotBlank
(
vionConfig
.
getAuthPath
()))
{
String
token
=
getToken
(
request
);
if
(
token
==
null
)
{
return
unAuthorized
(
exchange
.
getResponse
(),
"authorization failed"
);
}
ImmutablePair
<
Boolean
,
String
>
checkResult
=
checkToken
(
token
);
Boolean
success
=
checkResult
.
left
;
if
(!
success
)
{
log
.
info
(
"token校验未通过:[{}][{}]"
,
checkResult
.
right
,
request
.
getPath
());
return
unAuthorized
(
exchange
.
getResponse
(),
checkResult
.
right
);
}
log
.
info
(
"token 校验成功:{}"
,
token
);
if
(
vionConfig
.
getAuthEnabled
()
&&
!
skip
(
request
))
{
String
token
=
getToken
(
request
);
if
(
token
==
null
)
{
return
unAuthorized
(
exchange
.
getResponse
(),
"authorization failed"
);
}
ImmutablePair
<
Boolean
,
String
>
checkResult
=
checkToken
(
token
);
Boolean
success
=
checkResult
.
left
;
if
(!
success
)
{
log
.
info
(
"token校验未通过:[{}][{}]"
,
checkResult
.
right
,
request
.
getPath
());
return
unAuthorized
(
exchange
.
getResponse
(),
checkResult
.
right
);
}
log
.
info
(
"token 校验成功:{}"
,
token
);
}
return
chain
.
filter
(
exchange
);
}
...
...
fanxing-gateway/src/main/resources/application.yml
View file @
c9b6a2f
...
...
@@ -19,22 +19,16 @@ spring:
enabled
:
true
lower-case-service-id
:
true
routes
:
-
id
:
auth
uri
:
http://192.168.9.233:30010/
predicates
:
-
Path=/auth-serv/**
filters
:
-
RewritePath=/auth-serv/?(?<segment>.*),/auth_serv/$\{segment}
-
id
:
images
uri
:
http://192.168.9.233:30007/
predicates
:
-
Path=/images/**
# - id: videoService
# uri: http://192.168.9.233:10350/
# predicates:
# - Path=/video-server/**
# filters:
# - RewritePath=/video-server/?(?<segment>.*),/$\{segment}
# - id: videoService
# uri: http://192.168.9.233:10350/
# predicates:
# - Path=/video-server/**
# filters:
# - RewritePath=/video-server/?(?<segment>.*),/$\{segment}
consul
:
# 服务发现配置
discovery
:
...
...
@@ -72,7 +66,7 @@ spring:
logging
:
config
:
classpath:logback-${spring.profiles.active}.xml
vion
:
auth-
path
:
http://192.168.9.233:30010
auth-
enabled
:
true
skip-auth
:
-
.*login.*
-
.*fanxing-task/register.*
...
...
Write
Preview
Markdown
is supported
Attach a file
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 post a comment