提交 c77edac1 编写于 作者: M ManongJu

动态权限校验

上级 21f4a911
...@@ -120,7 +120,6 @@ public class AuthFilter implements GlobalFilter , Ordered { ...@@ -120,7 +120,6 @@ public class AuthFilter implements GlobalFilter , Ordered {
return false; return false;
} }
private boolean hasPermission(String headerToken, String path){ private boolean hasPermission(String headerToken, String path){
String url = getRealUrl(path);
try { try {
if (StringUtils.isEmpty(headerToken)){ if (StringUtils.isEmpty(headerToken)){
return false; return false;
...@@ -140,16 +139,12 @@ public class AuthFilter implements GlobalFilter , Ordered { ...@@ -140,16 +139,12 @@ public class AuthFilter implements GlobalFilter , Ordered {
return false; return false;
} }
List<Authority> authorities = JSON.parseArray(authStr , Authority.class); List<Authority> authorities = JSON.parseArray(authStr , Authority.class);
return authorities.stream().anyMatch(authority -> antPathMatcher.match(authority.getAuthority(), url)); return authorities.stream().anyMatch(authority -> antPathMatcher.match(authority.getAuthority(), path));
} catch (ParseException e) { } catch (ParseException e) {
e.printStackTrace(); e.printStackTrace();
} }
return false; return false;
} }
private String getRealUrl(String path){
String[] splitUrl = path.split("/");
return path.replace("/"+splitUrl[1] , "");
}
private SignedJWT getSignedJWT(String headerToken) throws ParseException { private SignedJWT getSignedJWT(String headerToken) throws ParseException {
String token = headerToken.replace(JWTConstants.TOKEN_PREFIX, ""); String token = headerToken.replace(JWTConstants.TOKEN_PREFIX, "");
log.info("token is {}", token); log.info("token is {}", token);
......
...@@ -10,7 +10,7 @@ Target Server Type : MYSQL ...@@ -10,7 +10,7 @@ Target Server Type : MYSQL
Target Server Version : 50628 Target Server Version : 50628
File Encoding : 65001 File Encoding : 65001
Date: 2020-10-29 16:47:06 Date: 2020-10-30 09:12:20
*/ */
SET FOREIGN_KEY_CHECKS=0; SET FOREIGN_KEY_CHECKS=0;
...@@ -170,8 +170,8 @@ CREATE TABLE `sys_menu` ( ...@@ -170,8 +170,8 @@ CREATE TABLE `sys_menu` (
-- Records of sys_menu -- Records of sys_menu
-- ---------------------------- -- ----------------------------
INSERT INTO `sys_menu` VALUES ('1', 'order', null, null, '订单管理', null, '1', null, null, null, null, null, null); INSERT INTO `sys_menu` VALUES ('1', 'order', null, null, '订单管理', null, '1', null, null, null, null, null, null);
INSERT INTO `sys_menu` VALUES ('2', 'order_list', 'order', '1', '订单列表查询', '/order/list', '2', null, null, null, null, null, null); INSERT INTO `sys_menu` VALUES ('2', 'order_list', 'order', '1', '订单列表查询', '/mss-upms/order/list', '2', null, null, null, null, null, null);
INSERT INTO `sys_menu` VALUES ('3', 'order_detail', 'order', '1', '订单详情', '/order/detail', '2', null, null, null, null, null, null); INSERT INTO `sys_menu` VALUES ('3', 'order_detail', 'order', '1', '订单详情', '/mss-upms/order/detail', '2', null, null, null, null, null, null);
-- ---------------------------- -- ----------------------------
-- Table structure for sys_privilege -- Table structure for sys_privilege
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册