|
@@ -4,7 +4,6 @@ import com.alibaba.fastjson.JSON;
|
|
|
import com.auth0.jwt.interfaces.Claim;
|
|
|
import com.auth0.jwt.interfaces.DecodedJWT;
|
|
|
import com.diagbot.util.JwtUtil;
|
|
|
-import com.diagbot.util.StringUtil;
|
|
|
import com.lantone.config.ExclusionUrl;
|
|
|
import com.lantone.facade.TokenFacade;
|
|
|
import com.lantone.security.dto.Result;
|
|
@@ -41,9 +40,17 @@ public class AuthGlobalFilter implements GlobalFilter, Ordered {
|
|
|
private ExclusionUrl exclusionUrl;
|
|
|
@Autowired
|
|
|
TokenFacade tokenFacade;
|
|
|
-
|
|
|
+ /**
|
|
|
+ * @Author songxl
|
|
|
+ * @Description 全局过滤器过滤方法
|
|
|
+ * @Date 2021/6/29
|
|
|
+ * @Param [exchange, chain]
|
|
|
+ * @Return reactor.core.publisher.Mono<java.lang.Void>
|
|
|
+ * @MethodName filter
|
|
|
+ */
|
|
|
@Override
|
|
|
public Mono<Void> filter(ServerWebExchange exchange, GatewayFilterChain chain) {
|
|
|
+
|
|
|
ServerHttpRequest request = exchange.getRequest();
|
|
|
ServerHttpResponse response = exchange.getResponse();
|
|
|
//1.swagger请求不要拦截
|
|
@@ -76,7 +83,14 @@ public class AuthGlobalFilter implements GlobalFilter, Ordered {
|
|
|
public int getOrder() {
|
|
|
return 0;
|
|
|
}
|
|
|
-
|
|
|
+ /**
|
|
|
+ * @Author songxl
|
|
|
+ * @Description 白名单请求判断
|
|
|
+ * @Date 2021/7/1
|
|
|
+ * @Param [path]
|
|
|
+ * @Return boolean
|
|
|
+ * @MethodName isExclusionUrl
|
|
|
+ */
|
|
|
private boolean isExclusionUrl(String path) {
|
|
|
List<String> exclusions = exclusionUrl.getUrl();
|
|
|
if (exclusions.size() == 0) {
|
|
@@ -89,7 +103,14 @@ public class AuthGlobalFilter implements GlobalFilter, Ordered {
|
|
|
}
|
|
|
return false;
|
|
|
}
|
|
|
-
|
|
|
+ /**
|
|
|
+ * @Author songxl
|
|
|
+ * @Description 从token获取权限信息,判断token是否有该请求权限
|
|
|
+ * @Date 2021/7/1
|
|
|
+ * @Param [headerToken, path]
|
|
|
+ * @Return boolean
|
|
|
+ * @MethodName hasPermission
|
|
|
+ */
|
|
|
private boolean hasPermission(String headerToken, String path) {
|
|
|
String url, method;
|
|
|
try {
|
|
@@ -110,7 +131,14 @@ public class AuthGlobalFilter implements GlobalFilter, Ordered {
|
|
|
}
|
|
|
return false;
|
|
|
}
|
|
|
-
|
|
|
+ /**
|
|
|
+ * @Author songxl
|
|
|
+ * @Description 请求返回拼装方法
|
|
|
+ * @Date 2021/7/1
|
|
|
+ * @Param [response, i, msg]
|
|
|
+ * @Return reactor.core.publisher.Mono<java.lang.Void>
|
|
|
+ * @MethodName getVoidMono
|
|
|
+ */
|
|
|
private Mono<Void> getVoidMono(ServerHttpResponse response, int i, String msg) {
|
|
|
response.getHeaders().setContentType(MediaType.APPLICATION_JSON);
|
|
|
response.setStatusCode(HttpStatus.OK);
|