You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
19 lines
1.5 KiB
19 lines
1.5 KiB
|
1 month ago
|
# 01 — ApiPermissionCache + ApiPermissionInterceptor 核心拦截链路
|
||
|
|
|
||
|
|
**What to build:** 构建基于 apiUrl 的动态权限拦截机制。一个 Caffeine 进程内缓存加载 sys_menu 中 status=enabled 且 apiUrl 非空的 button 节点,生成 {apiUrlPattern, permsCode} 规则列表。一个 HandlerInterceptor 用 AntPathMatcher 匹配请求 URL,从 SecurityContext 读当前用户 authority 集合,匹配到规则但用户无对应 perms → 403;未匹配任何规则 → 放行(fail-open)。拦截器注册到 MVC 配置中,位于 JWT 过滤器之后、Controller 之前。
|
||
|
|
|
||
|
|
**Blocked by:** None — can start immediately
|
||
|
|
|
||
|
|
**Status:** ready-for-agent
|
||
|
|
|
||
|
|
- [ ] ApiPermissionCache:Caffeine 缓存,懒加载 sys_menu 中 menuType=3 AND status='enabled' AND apiUrl IS NOT NULL 的节点,产出 List<{pattern, perms}>
|
||
|
|
- [ ] ApiPermissionCache.invalidate():清空缓存,下次请求重建
|
||
|
|
- [ ] ApiPermissionInterceptor:HandlerInterceptor,preHandle 中匹配请求 URI,检查 authority
|
||
|
|
- [ ] Ant 风格匹配:* 单层通配,** 多层通配,用 Spring 内置 AntPathMatcher
|
||
|
|
- [ ] fail-open:未匹配任何注册 apiUrl → 放行
|
||
|
|
- [ ] 停用节点不生成规则(status=disabled 排除)
|
||
|
|
- [ ] 匹配到规则但用户无对应 perms → 403 + 清晰错误消息
|
||
|
|
- [ ] MVC 配置注册拦截器(JWT 过滤器之后)
|
||
|
|
- [ ] 与 @PreAuthorize 共存不冲突
|
||
|
|
- [ ] 单元测试:匹配放行、匹配拒绝、未注册放行、Ant 通配、停用节点不生成规则
|