Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
有来技术
youlai-mall
提交
0e2672c1
Y
youlai-mall
项目概览
有来技术
/
youlai-mall
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
Y
youlai-mall
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
0e2672c1
编写于
2月 10, 2021
作者:
H
haoxr
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix:角色修改权限无效问题修复
上级
589bb8b2
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
4 addition
and
8 deletion
+4
-8
youlai-admin/admin-api/src/main/java/com/youlai/admin/pojo/dto/RolePermissionDTO.java
...ain/java/com/youlai/admin/pojo/dto/RolePermissionDTO.java
+2
-0
youlai-common/common-core/src/main/java/com/youlai/common/constant/AuthConstants.java
...c/main/java/com/youlai/common/constant/AuthConstants.java
+1
-1
youlai-gateway/src/main/java/com/youlai/gateway/security/AuthorizationManager.java
...ava/com/youlai/gateway/security/AuthorizationManager.java
+1
-7
未找到文件。
youlai-admin/admin-api/src/main/java/com/youlai/admin/pojo/dto/RolePermissionDTO.java
浏览文件 @
0e2672c1
...
...
@@ -10,4 +10,6 @@ public class RolePermissionDTO {
private
Long
roleId
;
private
List
<
Long
>
permissionIds
;
private
Integer
type
;
private
Long
moduleId
;
}
youlai-common/common-core/src/main/java/com/youlai/common/constant/AuthConstants.java
浏览文件 @
0e2672c1
...
...
@@ -76,5 +76,5 @@ public interface AuthConstants {
/**
* 后台管理接口路径匹配
*/
String
ADMIN_URL_PATTERN
=
"/youlai-admin/**"
;
String
ADMIN_URL_PATTERN
=
"
*_
/youlai-admin/**"
;
}
youlai-gateway/src/main/java/com/youlai/gateway/security/AuthorizationManager.java
浏览文件 @
0e2672c1
...
...
@@ -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.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录