无关风月
2025-04-11 1d9f7b0cf4251f3058badb07dd7a2bc06b6bc09a
cloud-server-gateway/src/main/java/cn/mb/cloud/gateway/filter/PermissionsFilter.java
@@ -66,16 +66,7 @@
    @Autowired
    AuthService authService;
    @Value("${cn.mbcloud.gateway.permissions.basic}")
    private Boolean isBasic = Boolean.FALSE;
    private AntPathMatcher pathMatcher = new AntPathMatcher();
    /**
     * Redis Token 仓库前缀
     */
    private String REDIS_TOKEN_STORE_PREFIX = "oauth2_";
    /**
     * 账户
@@ -127,6 +118,16 @@
     */
    @Value(("${ignore.other.uris}"))
    private String IGNORE_OTHER_URIS;
    /**
     * 世界杯
     */
    @Value(("${ignore.communityWorldCup.prefix}"))
    private String IGNORE_COMMUNITY_WORLD_CUP_PREFIX;
    /**
     * 世界杯
     */
    @Value(("${ignore.communityWorldCup.uris}"))
    private String IGNORE_COMMUNITY_WORLD_CUP_URIS;
    /**
     * 管理后台
     */
@@ -182,20 +183,20 @@
        }
        //校验参数签名 Verify parameter signature
        ResultUtil resultUtil = preHandle(request);
        if(resultUtil.getCode() != 200){
            log.info("签名异常");
            response.setRawStatusCode(resultUtil.getCode());
            byte[] bits = JSON.toJSONBytes(resultUtil);
            DataBuffer buffer = response.bufferFactory().wrap(bits);
            HttpHeaders headers = response.getHeaders();
            String first = headers.getFirst("Content-Type");
            if(StringUtils.isEmpty(first)){
                headers.add("Content-Type", "application/json;charset=UTF-8");
            }
            return response.writeWith(Mono.just(buffer));
        }
//        ResultUtil resultUtil = preHandle(request);
//        if(resultUtil.getCode() != 200){
//            log.info("签名异常");
//            response.setRawStatusCode(resultUtil.getCode());
//            byte[] bits = JSON.toJSONBytes(resultUtil);
//            DataBuffer buffer = response.bufferFactory().wrap(bits);
//            HttpHeaders headers = response.getHeaders();
//            String first = headers.getFirst("Content-Type");
//            if(StringUtils.isEmpty(first)){
//                headers.add("Content-Type", "application/json;charset=UTF-8");
//            }
//
//            return response.writeWith(Mono.just(buffer));
//        }
        return chain.filter(exchange.mutate().request(request.mutate().build()).build());
    }
@@ -268,7 +269,7 @@
        }
        //课程
        if (uri.startsWith(IGNORE_COURSE_URIS)) {
        if (uri.startsWith(IGNORE_COURSE_PREFIX)) {
            if(!StringUtils.isEmpty(IGNORE_COURSE_URIS)){
                String[] split = IGNORE_COURSE_URIS.split(",");
                for (String s : split) {
@@ -291,6 +292,18 @@
            }
        }
        //世界杯
        if (uri.startsWith(IGNORE_COMMUNITY_WORLD_CUP_PREFIX)) {
            if(!StringUtils.isEmpty(IGNORE_COMMUNITY_WORLD_CUP_URIS)){
                String[] split = IGNORE_COMMUNITY_WORLD_CUP_URIS.split(",");
                for (String s : split) {
                    if (uri.contains(s)) {
                        return PermissionResult.PASS;
                    }
                }
            }
        }
        // ----------------------------------------------------------------- 放行综合后台授权登录-UPMS