feat:添加网关路由权限细粒度控制

This commit is contained in:
hxrui 2021-02-05 20:14:58 +08:00
parent 962069ad45
commit 1a1483a5a7
70 changed files with 91 additions and 129 deletions

View File

@ -2,11 +2,9 @@ package com.youlai.mall.oms.pojo;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.youlai.common.core.base.BaseEntity;
import com.youlai.common.base.BaseEntity;
import lombok.Data;
import java.util.Date;
@Data
public class OmsOrder extends BaseEntity {

View File

@ -2,7 +2,7 @@ package com.youlai.mall.oms.pojo;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.youlai.common.core.base.BaseEntity;
import com.youlai.common.base.BaseEntity;
import lombok.Data;

View File

@ -3,7 +3,7 @@ package com.youlai.mall.oms.pojo.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.youlai.common.core.base.BaseEntity;
import com.youlai.common.base.BaseEntity;
import lombok.Data;
import java.util.Date;

View File

@ -3,7 +3,7 @@ package com.youlai.mall.oms.pojo.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.youlai.common.core.base.BaseEntity;
import com.youlai.common.base.BaseEntity;
import lombok.Data;
import java.util.Date;

View File

@ -3,7 +3,7 @@ package com.youlai.mall.oms.pojo.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.youlai.common.core.base.BaseEntity;
import com.youlai.common.base.BaseEntity;
import lombok.Data;
/**

View File

@ -3,7 +3,7 @@ package com.youlai.mall.oms.pojo.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.youlai.common.core.base.BaseEntity;
import com.youlai.common.base.BaseEntity;
import lombok.Data;
/**

View File

@ -3,7 +3,7 @@ package com.youlai.mall.oms.pojo.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.youlai.common.core.base.BaseEntity;
import com.youlai.common.base.BaseEntity;
import lombok.Data;
import java.util.Date;

View File

@ -3,7 +3,7 @@ package com.youlai.mall.oms.pojo.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.youlai.common.core.base.BaseEntity;
import com.youlai.common.base.BaseEntity;
import lombok.Data;
/**

View File

@ -1,6 +1,6 @@
package com.youlai.mall.oms.pojo.vo;
import com.youlai.common.core.base.BaseVO;
import com.youlai.common.base.BaseVO;
import lombok.Data;
/**

View File

@ -1,6 +1,6 @@
package com.youlai.mall.oms.pojo.vo;
import com.youlai.common.core.base.BaseVO;
import com.youlai.common.base.BaseVO;
import lombok.Getter;
import lombok.Setter;

View File

@ -1,6 +1,6 @@
package com.youlai.mall.oms.pojo.vo;
import com.youlai.common.core.base.BaseVO;
import com.youlai.common.base.BaseVO;
import lombok.Builder;
import lombok.Getter;
import lombok.Setter;

View File

@ -1,6 +1,6 @@
package com.youlai.mall.oms.pojo.vo;
import com.youlai.common.core.base.BaseVO;
import com.youlai.common.base.BaseVO;
import lombok.Data;
/**

View File

@ -1,6 +1,6 @@
package com.youlai.mall.oms.pojo.vo;
import com.youlai.common.core.base.BaseVO;
import com.youlai.common.base.BaseVO;
import lombok.Data;
import javax.validation.constraints.NotBlank;

View File

@ -1,6 +1,6 @@
package com.youlai.mall.oms.pojo.vo;
import com.youlai.common.core.base.BaseVO;
import com.youlai.common.base.BaseVO;
import com.youlai.mall.oms.pojo.entity.OrderDeliveryEntity;
import com.youlai.mall.oms.pojo.entity.OrderEntity;
import com.youlai.mall.oms.pojo.entity.OrderGoodsEntity;

View File

@ -1,6 +1,6 @@
package com.youlai.mall.pms.api;
import com.youlai.common.core.result.Result;
import com.youlai.common.result.Result;
import com.youlai.mall.pms.pojo.dto.SkuDTO;
import com.youlai.mall.pms.pojo.vo.SkuInfoVO;
import com.youlai.mall.pms.pojo.vo.WareSkuStockVO;

View File

@ -2,7 +2,7 @@ package com.youlai.mall.pms.pojo;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.youlai.common.core.base.BaseEntity;
import com.youlai.common.base.BaseEntity;
import lombok.Data;

View File

@ -3,7 +3,7 @@ package com.youlai.mall.pms.pojo;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.youlai.common.core.base.BaseEntity;
import com.youlai.common.base.BaseEntity;
import lombok.Data;
@Data

View File

@ -1,13 +1,10 @@
package com.youlai.mall.pms.pojo;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.youlai.common.core.base.BaseEntity;
import com.youlai.common.base.BaseEntity;
import lombok.Data;
import java.util.List;
@Data
public class PmsSku extends BaseEntity {

View File

@ -3,7 +3,7 @@ package com.youlai.mall.pms.pojo;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.youlai.common.core.base.BaseEntity;
import com.youlai.common.base.BaseEntity;
import lombok.Data;
import lombok.experimental.Accessors;
import org.springframework.data.annotation.Id;

View File

@ -1,9 +1,8 @@
package com.youlai.mall.pms.pojo;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.youlai.common.core.base.BaseEntity;
import com.youlai.common.base.BaseEntity;
import lombok.Data;
/**

View File

@ -2,7 +2,7 @@ package com.youlai.mall.pms.pojo;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.youlai.common.core.base.BaseEntity;
import com.youlai.common.base.BaseEntity;
import lombok.Data;
/**

View File

@ -1,6 +1,6 @@
package com.youlai.mall.pms.pojo.dto;
import com.youlai.common.core.base.BaseVO;
import com.youlai.common.base.BaseVO;
import lombok.Data;
/**

View File

@ -1,6 +1,6 @@
package com.youlai.mall.pms.pojo.vo;
import com.youlai.common.core.base.BaseVO;
import com.youlai.common.base.BaseVO;
import lombok.Data;
/**

View File

@ -1,6 +1,6 @@
package com.youlai.mall.pms.pojo.vo;
import com.youlai.common.core.base.BaseVO;
import com.youlai.common.base.BaseVO;
import lombok.Builder;
import lombok.Getter;
import lombok.Setter;

View File

@ -1,6 +1,6 @@
package com.youlai.mall.pms.pojo.vo;
import com.youlai.common.core.base.BaseVO;
import com.youlai.common.base.BaseVO;
import lombok.Data;
/**

View File

@ -1,6 +1,6 @@
package com.youlai.mall.pms.pojo.vo;
import com.youlai.common.core.base.BaseVO;
import com.youlai.common.base.BaseVO;
import lombok.Data;
/**

View File

@ -1,6 +1,6 @@
package com.youlai.mall.pms.pojo.vo;
import com.youlai.common.core.base.BaseVO;
import com.youlai.common.base.BaseVO;
import lombok.Data;
import java.util.List;

View File

@ -1,6 +1,6 @@
package com.youlai.mall.pms.search.controller;
import com.youlai.common.core.result.Result;
import com.youlai.common.result.Result;
import com.youlai.mall.pms.search.service.IPmsSearchService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;

View File

@ -14,7 +14,7 @@ import org.springframework.stereotype.Service;
import java.io.IOException;
import java.util.List;
import static com.youlai.common.core.constant.EsIndexContstants.PMS_SPU;
import static com.youlai.common.constant.EsIndexContstants.PMS_SPU;
@Service
@AllArgsConstructor

View File

@ -2,7 +2,7 @@ package com.youlai.mall.sms.pojo;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.youlai.common.core.base.BaseEntity;
import com.youlai.common.base.BaseEntity;
import lombok.Data;
import java.util.Date;

View File

@ -1,6 +1,6 @@
package com.youlai.mall.ums.api;
import com.youlai.common.core.result.Result;
import com.youlai.common.result.Result;
import com.youlai.mall.ums.pojo.UmsUser;
import com.youlai.mall.ums.pojo.dto.AuthMemberDTO;
import com.youlai.mall.ums.pojo.dto.MemberDTO;

View File

@ -3,7 +3,7 @@ package com.youlai.mall.ums.pojo;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.youlai.common.core.base.BaseEntity;
import com.youlai.common.base.BaseEntity;
import lombok.Data;
import lombok.experimental.Accessors;

View File

@ -4,7 +4,7 @@ package com.youlai.mall.ums.pojo;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.youlai.common.core.base.BaseEntity;
import com.youlai.common.base.BaseEntity;
import lombok.Data;
import lombok.experimental.Accessors;

View File

@ -1,7 +1,7 @@
package com.youlai.admin.api;
import com.youlai.admin.pojo.dto.UserDTO;
import com.youlai.common.core.result.Result;
import com.youlai.common.result.Result;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;

View File

@ -2,7 +2,7 @@ package com.youlai.admin.pojo.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.youlai.common.core.base.BaseEntity;
import com.youlai.common.base.BaseEntity;
import lombok.Data;
@Data

View File

@ -2,7 +2,7 @@ package com.youlai.admin.pojo.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.youlai.common.core.base.BaseEntity;
import com.youlai.common.base.BaseEntity;
import lombok.Data;
@Data

View File

@ -2,7 +2,7 @@ package com.youlai.admin.pojo.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.youlai.common.core.base.BaseEntity;
import com.youlai.common.base.BaseEntity;
import lombok.Data;
import lombok.experimental.Accessors;

View File

@ -3,9 +3,8 @@ package com.youlai.admin.pojo.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.youlai.common.core.base.BaseEntity;
import com.youlai.common.base.BaseEntity;
import lombok.Data;
import java.util.List;

View File

@ -2,7 +2,7 @@ package com.youlai.admin.pojo.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.youlai.common.core.base.BaseEntity;
import com.youlai.common.base.BaseEntity;
import lombok.Data;
import lombok.experimental.Accessors;
@ -16,7 +16,8 @@ public class SysPermission extends BaseEntity {
private Long id;
private String name;
private String perm;
private Long menuId;
private Long moduleId;
private String method;
private Integer type;
// 拥有资源权限角色ID集合

View File

@ -3,8 +3,7 @@ package com.youlai.admin.pojo.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.youlai.common.core.base.BaseEntity;
import com.youlai.common.base.BaseEntity;
import lombok.Data;
import java.util.List;

View File

@ -2,7 +2,7 @@ package com.youlai.admin.pojo.entity;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.youlai.common.core.base.BaseEntity;
import com.youlai.common.base.BaseEntity;
import lombok.Data;
import java.util.List;

View File

@ -1,7 +1,7 @@
package com.youlai.admin.pojo.vo;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.youlai.common.core.base.BaseEntity;
import com.youlai.common.base.BaseEntity;
import lombok.Data;
import java.util.List;

View File

@ -6,9 +6,9 @@ import com.youlai.auth.domain.User;
import com.youlai.auth.filter.CustomClientCredentialsTokenEndpointFilter;
import com.youlai.auth.service.JdbcClientDetailsServiceImpl;
import com.youlai.auth.service.UserDetailsServiceImpl;
import com.youlai.common.core.constant.AuthConstants;
import com.youlai.common.core.result.Result;
import com.youlai.common.core.result.ResultCode;
import com.youlai.common.constant.AuthConstants;
import com.youlai.common.result.Result;
import com.youlai.common.result.ResultCode;
import lombok.AllArgsConstructor;
import lombok.SneakyThrows;
import org.springframework.context.annotation.Bean;

View File

@ -5,10 +5,10 @@ import cn.binarywang.wx.miniapp.bean.WxMaJscode2SessionResult;
import cn.binarywang.wx.miniapp.bean.WxMaUserInfo;
import cn.hutool.core.util.StrUtil;
import com.youlai.auth.domain.Oauth2Token;
import com.youlai.common.core.constant.AuthConstants;
import com.youlai.common.core.constant.GlobalConstants;
import com.youlai.common.core.result.Result;
import com.youlai.common.core.result.ResultCode;
import com.youlai.common.constant.AuthConstants;
import com.youlai.common.constant.GlobalConstants;
import com.youlai.common.result.Result;
import com.youlai.common.result.ResultCode;
import com.youlai.common.web.exception.BizException;
import com.youlai.mall.ums.api.MemberFeignService;
import com.youlai.mall.ums.pojo.UmsUser;

View File

@ -1,8 +1,8 @@
package com.youlai.auth.controller;
import cn.hutool.json.JSONObject;
import com.youlai.common.core.constant.AuthConstants;
import com.youlai.common.core.result.Result;
import com.youlai.common.constant.AuthConstants;
import com.youlai.common.result.Result;
import com.youlai.common.web.util.WebUtils;
import io.swagger.annotations.Api;
import lombok.AllArgsConstructor;

View File

@ -2,7 +2,7 @@ package com.youlai.auth.domain;
import cn.hutool.core.collection.CollectionUtil;
import com.youlai.admin.pojo.dto.UserDTO;
import com.youlai.common.core.constant.AuthConstants;
import com.youlai.common.constant.AuthConstants;
import com.youlai.mall.ums.pojo.dto.AuthMemberDTO;
import lombok.Data;
import lombok.NoArgsConstructor;

View File

@ -1,7 +1,7 @@
package com.youlai.auth.exception;
import com.youlai.common.core.result.Result;
import com.youlai.common.core.result.ResultCode;
import com.youlai.common.result.Result;
import com.youlai.common.result.ResultCode;
import lombok.extern.slf4j.Slf4j;
import org.springframework.security.authentication.InternalAuthenticationServiceException;
import org.springframework.security.oauth2.common.exceptions.InvalidGrantException;

View File

@ -3,9 +3,9 @@ package com.youlai.auth.service;
import com.youlai.admin.pojo.dto.UserDTO;
import com.youlai.admin.api.UserFeignService;
import com.youlai.auth.domain.User;
import com.youlai.common.core.constant.AuthConstants;
import com.youlai.common.core.result.Result;
import com.youlai.common.core.result.ResultCode;
import com.youlai.common.constant.AuthConstants;
import com.youlai.common.result.Result;
import com.youlai.common.result.ResultCode;
import com.youlai.mall.ums.pojo.dto.AuthMemberDTO;
import com.youlai.mall.ums.api.MemberFeignService;
import lombok.AllArgsConstructor;

View File

@ -1,4 +1,4 @@
package com.youlai.common.core.base;
package com.youlai.common.base;
public class BaseController<T> {

View File

@ -1,4 +1,4 @@
package com.youlai.common.core.base;
package com.youlai.common.base;
import com.baomidou.mybatisplus.annotation.FieldFill;

View File

@ -1,4 +1,4 @@
package com.youlai.common.core.base;
package com.youlai.common.base;
import lombok.Data;
import lombok.ToString;

View File

@ -6,14 +6,14 @@
* 版权所有侵权必究
*/
package com.youlai.common.core.base;
package com.youlai.common.base;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.metadata.OrderItem;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.youlai.common.core.constant.RenrenConstant;
import com.youlai.common.core.xss.SQLFilter;
import com.youlai.common.constant.RenrenConstant;
import com.youlai.common.xss.SQLFilter;
import java.util.Map;

View File

@ -1,4 +1,4 @@
package com.youlai.common.core.constant;
package com.youlai.common.constant;
public interface AuthConstants {
@ -23,7 +23,7 @@ public interface AuthConstants {
/**
* Redis缓存权限规则key
*/
String PERMISSION_RULES_KEY = "auth:permission:rules";
String PERMISSION_ROLES_KEY = "auth:permission:roles";
/**
* 黑名单token前缀

View File

@ -1,4 +1,4 @@
package com.youlai.common.core.constant;
package com.youlai.common.constant;
public interface EsIndexContstants {

View File

@ -1,4 +1,4 @@
package com.youlai.common.core.constant;
package com.youlai.common.constant;
public interface GlobalConstants {

View File

@ -6,7 +6,7 @@
* 版权所有侵权必究
*/
package com.youlai.common.core.constant;
package com.youlai.common.constant;
/**
* 常量

View File

@ -1,4 +1,4 @@
package com.youlai.common.core.enums;
package com.youlai.common.enums;
import lombok.Getter;
import lombok.Setter;

View File

@ -1,4 +1,4 @@
package com.youlai.common.core.result;
package com.youlai.common.result;
/**
* @author haoxr

View File

@ -1,4 +1,4 @@
package com.youlai.common.core.result;
package com.youlai.common.result;
import com.fasterxml.jackson.annotation.JsonInclude;
import lombok.Data;

View File

@ -1,4 +1,4 @@
package com.youlai.common.core.result;
package com.youlai.common.result;
import lombok.AllArgsConstructor;
import lombok.NoArgsConstructor;

View File

@ -1,4 +1,4 @@
package com.youlai.common.core.xss;
package com.youlai.common.xss;
import java.util.*;
import java.util.concurrent.ConcurrentHashMap;

View File

@ -6,7 +6,7 @@
* 版权所有侵权必究
*/
package com.youlai.common.core.xss;
package com.youlai.common.xss;
import cn.hutool.core.util.StrUtil;

View File

@ -1,6 +1,6 @@
package com.youlai.common.web.exception;
import com.youlai.common.core.result.IResultCode;
import com.youlai.common.result.IResultCode;
import lombok.Getter;
@Getter

View File

@ -1,7 +1,7 @@
package com.youlai.common.web.exception;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.youlai.common.core.result.Result;
import com.youlai.common.result.Result;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

View File

@ -1,13 +0,0 @@
package com.youlai.common.web.service;
/**
* @Author haoxr
* @Date 2021-02-05 15:06
* @Version 1.0.0
*/
public class PermissionService {
}

View File

@ -2,8 +2,8 @@ package com.youlai.common.web.util;
import cn.hutool.json.JSONObject;
import cn.hutool.json.JSONUtil;
import com.youlai.common.core.constant.AuthConstants;
import com.youlai.common.core.result.ResultCode;
import com.youlai.common.constant.AuthConstants;
import com.youlai.common.result.ResultCode;
import lombok.extern.slf4j.Slf4j;
import org.springframework.http.server.reactive.ServerHttpResponse;
import org.springframework.web.context.request.RequestContextHolder;

View File

@ -1,21 +1,14 @@
package com.youlai.gateway.config;
import cn.hutool.core.util.ArrayUtil;
import cn.hutool.json.JSONUtil;
import com.youlai.common.core.constant.AuthConstants;
import com.youlai.common.core.result.Result;
import com.youlai.common.core.result.ResultCode;
import com.youlai.common.constant.AuthConstants;
import com.youlai.common.result.ResultCode;
import com.youlai.gateway.security.AuthorizationManager;
import com.youlai.gateway.util.WebUtils;
import lombok.AllArgsConstructor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.convert.converter.Converter;
import org.springframework.core.io.buffer.DataBuffer;
import org.springframework.core.io.buffer.DataBufferUtils;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.security.authentication.AbstractAuthenticationToken;
import org.springframework.security.config.annotation.web.reactive.EnableWebFluxSecurity;
import org.springframework.security.config.web.server.ServerHttpSecurity;
@ -28,8 +21,6 @@ import org.springframework.security.web.server.ServerAuthenticationEntryPoint;
import org.springframework.security.web.server.authorization.ServerAccessDeniedHandler;
import reactor.core.publisher.Mono;
import java.nio.charset.Charset;
/**
* 资源服务器配置
*/
@ -85,8 +76,6 @@ public class ResourceServerConfig {
};
}
/**
* @return
* @link https://blog.csdn.net/qq_24230139/article/details/105091273

View File

@ -4,11 +4,9 @@ import cn.hutool.core.util.StrUtil;
import cn.hutool.json.JSONObject;
import cn.hutool.json.JSONUtil;
import com.nimbusds.jose.JWSObject;
import com.youlai.common.core.constant.AuthConstants;
import com.youlai.common.core.result.Result;
import com.youlai.common.core.result.ResultCode;
import com.youlai.common.constant.AuthConstants;
import com.youlai.common.result.ResultCode;
import com.youlai.gateway.util.WebUtils;
import lombok.AllArgsConstructor;
import lombok.SneakyThrows;
import lombok.extern.slf4j.Slf4j;
import org.apache.logging.log4j.util.Strings;
@ -17,20 +15,14 @@ import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.gateway.filter.GatewayFilterChain;
import org.springframework.cloud.gateway.filter.GlobalFilter;
import org.springframework.core.Ordered;
import org.springframework.core.io.buffer.DataBuffer;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpMethod;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.http.server.reactive.ServerHttpRequest;
import org.springframework.http.server.reactive.ServerHttpResponse;
import org.springframework.stereotype.Component;
import org.springframework.web.server.ServerWebExchange;
import reactor.core.publisher.Mono;
import java.nio.charset.Charset;
/**
* 全局过滤器
*/

View File

@ -2,7 +2,7 @@ package com.youlai.gateway.security;
import cn.hutool.core.convert.Convert;
import cn.hutool.core.util.StrUtil;
import com.youlai.common.core.constant.AuthConstants;
import com.youlai.common.constant.AuthConstants;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.data.redis.core.RedisTemplate;
@ -37,8 +37,9 @@ public class AuthorizationManager implements ReactiveAuthorizationManager<Author
public Mono<AuthorizationDecision> check(Mono<Authentication> mono, AuthorizationContext authorizationContext) {
ServerHttpRequest request = authorizationContext.getExchange().getRequest();
String path = request.getURI().getPath();
PathMatcher pathMatcher = new AntPathMatcher();
String path = request.getMethodValue() + "_" + request.getURI().getPath();
AntPathMatcher pathMatcher = new AntPathMatcher();
pathMatcher.setCaseSensitive(false); // 忽略大小写
// 对应跨域的预检请求直接放行
if (request.getMethod() == HttpMethod.OPTIONS) {
@ -57,7 +58,7 @@ public class AuthorizationManager implements ReactiveAuthorizationManager<Author
}
// 从缓存取资源权限角色关系列表
Map<Object, Object> permissionRoles = redisTemplate.opsForHash().entries(AuthConstants.PERMISSION_RULES_KEY);
Map<Object, Object> permissionRoles = redisTemplate.opsForHash().entries(AuthConstants.PERMISSION_ROLES_KEY);
Iterator<Object> iterator = permissionRoles.keySet().iterator();
// 请求路径匹配到的资源需要的角色权限集合authorities统计

View File

@ -1,8 +1,8 @@
package com.youlai.gateway.util;
import cn.hutool.json.JSONUtil;
import com.youlai.common.core.result.Result;
import com.youlai.common.core.result.ResultCode;
import com.youlai.common.result.Result;
import com.youlai.common.result.ResultCode;
import org.springframework.core.io.buffer.DataBuffer;
import org.springframework.core.io.buffer.DataBufferUtils;
import org.springframework.http.HttpHeaders;