Commit c9b6a2fb by xmh

去除auth相关路由,auth已接入微服务,feignClient中使用微服务名称调用

1 parent 34f9d5d6
......@@ -27,7 +27,7 @@ public class VionConfig {
/** 是否启用转发 */
private boolean enableForward;
/** auth 服务地址 */
private String authPath;
private Boolean authEnabled;
private Gateway gateway;
/** 支持的视频格式列表 */
private List<String> supportedVideoFormats;
......
......@@ -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 = "/auth_serv/api/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);
}
......@@ -44,8 +44,7 @@ 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())) {
if (vionConfig.getAuthEnabled() && !skip(request)) {
String token = getToken(request);
if (token == null) {
return unAuthorized(exchange.getResponse(), "authorization failed");
......@@ -58,8 +57,6 @@ public class AuthorizationFilter implements GlobalFilter {
}
log.info("token 校验成功:{}", token);
}
}
return chain.filter(exchange);
}
......
......@@ -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.*
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!