Commit c9b6a2fb by xmh

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

1 parent 34f9d5d6
...@@ -27,7 +27,7 @@ public class VionConfig { ...@@ -27,7 +27,7 @@ public class VionConfig {
/** 是否启用转发 */ /** 是否启用转发 */
private boolean enableForward; private boolean enableForward;
/** auth 服务地址 */ /** auth 服务地址 */
private String authPath; private Boolean authEnabled;
private Gateway gateway; private Gateway gateway;
/** 支持的视频格式列表 */ /** 支持的视频格式列表 */
private List<String> supportedVideoFormats; private List<String> supportedVideoFormats;
......
...@@ -15,10 +15,10 @@ import java.util.Map; ...@@ -15,10 +15,10 @@ import java.util.Map;
* @author 谢明辉 * @author 谢明辉
* @date 2021/9/29 * @date 2021/9/29
*/ */
@FeignClient(name = "auth", url = "${vion.auth-path}") @FeignClient(name = "fanxing-auth")
public interface AuthClient { 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); JSONObject checkToken(@RequestHeader("authorization") String token, @RequestBody Map<String, Object> data);
} }
...@@ -44,8 +44,7 @@ public class AuthorizationFilter implements GlobalFilter { ...@@ -44,8 +44,7 @@ public class AuthorizationFilter implements GlobalFilter {
@Override @Override
public Mono<Void> filter(ServerWebExchange exchange, GatewayFilterChain chain) { public Mono<Void> filter(ServerWebExchange exchange, GatewayFilterChain chain) {
ServerHttpRequest request = exchange.getRequest(); ServerHttpRequest request = exchange.getRequest();
if (!skip(request)) { if (vionConfig.getAuthEnabled() && !skip(request)) {
if (StringUtils.isNotBlank(vionConfig.getAuthPath())) {
String token = getToken(request); String token = getToken(request);
if (token == null) { if (token == null) {
return unAuthorized(exchange.getResponse(), "authorization failed"); return unAuthorized(exchange.getResponse(), "authorization failed");
...@@ -58,8 +57,6 @@ public class AuthorizationFilter implements GlobalFilter { ...@@ -58,8 +57,6 @@ public class AuthorizationFilter implements GlobalFilter {
} }
log.info("token 校验成功:{}", token); log.info("token 校验成功:{}", token);
} }
}
return chain.filter(exchange); return chain.filter(exchange);
} }
......
...@@ -19,22 +19,16 @@ spring: ...@@ -19,22 +19,16 @@ spring:
enabled: true enabled: true
lower-case-service-id: true lower-case-service-id: true
routes: routes:
- id: auth
uri: http://192.168.9.233:30010/
predicates:
- Path=/auth-serv/**
filters:
- RewritePath=/auth-serv/?(?<segment>.*),/auth_serv/$\{segment}
- id: images - id: images
uri: http://192.168.9.233:30007/ uri: http://192.168.9.233:30007/
predicates: predicates:
- Path=/images/** - Path=/images/**
# - id: videoService # - id: videoService
# uri: http://192.168.9.233:10350/ # uri: http://192.168.9.233:10350/
# predicates: # predicates:
# - Path=/video-server/** # - Path=/video-server/**
# filters: # filters:
# - RewritePath=/video-server/?(?<segment>.*),/$\{segment} # - RewritePath=/video-server/?(?<segment>.*),/$\{segment}
consul: consul:
# 服务发现配置 # 服务发现配置
discovery: discovery:
...@@ -72,7 +66,7 @@ spring: ...@@ -72,7 +66,7 @@ spring:
logging: logging:
config: classpath:logback-${spring.profiles.active}.xml config: classpath:logback-${spring.profiles.active}.xml
vion: vion:
auth-path: http://192.168.9.233:30010 auth-enabled: true
skip-auth: skip-auth:
- .*login.* - .*login.*
- .*fanxing-task/register.* - .*fanxing-task/register.*
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!