提交 0e2672c1 编写于 作者: H haoxr

fix:角色修改权限无效问题修复

上级 589bb8b2
......@@ -10,4 +10,6 @@ public class RolePermissionDTO {
private Long roleId;
private List<Long> permissionIds;
private Integer type;
private Long moduleId;
}
......@@ -76,5 +76,5 @@ public interface AuthConstants {
/**
* 后台管理接口路径匹配
*/
String ADMIN_URL_PATTERN ="/youlai-admin/**" ;
String ADMIN_URL_PATTERN ="*_/youlai-admin/**" ;
}
......@@ -35,12 +35,9 @@ public class AuthorizationManager implements ReactiveAuthorizationManager<Author
@Override
public Mono<AuthorizationDecision> check(Mono<Authentication> mono, AuthorizationContext authorizationContext) {
ServerHttpRequest request = authorizationContext.getExchange().getRequest();
String path = request.getMethodValue() + "_" + request.getURI().getPath();
AntPathMatcher pathMatcher = new AntPathMatcher();
pathMatcher.setCaseSensitive(false); // 忽略大小写
PathMatcher pathMatcher = new AntPathMatcher();
// 对应跨域的预检请求直接放行
if (request.getMethod() == HttpMethod.OPTIONS) {
return Mono.just(new AuthorizationDecision(true));
......@@ -56,11 +53,9 @@ public class AuthorizationManager implements ReactiveAuthorizationManager<Author
if (StrUtil.isBlank(token)) {
return Mono.just(new AuthorizationDecision(false));
}
// 从缓存取资源权限角色关系列表
Map<Object, Object> permissionRoles = redisTemplate.opsForHash().entries(AuthConstants.PERMISSION_ROLES_KEY);
Iterator<Object> iterator = permissionRoles.keySet().iterator();
// 请求路径匹配到的资源需要的角色权限集合authorities统计
Set<String> authorities = new HashSet<>();
while (iterator.hasNext()) {
......@@ -69,7 +64,6 @@ public class AuthorizationManager implements ReactiveAuthorizationManager<Author
authorities.addAll(Convert.toList(String.class, permissionRoles.get(pattern)));
}
}
Mono<AuthorizationDecision> authorizationDecisionMono = mono
.filter(Authentication::isAuthenticated)
.flatMapIterable(Authentication::getAuthorities)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册