[Bug] PathMatchingFilterChainResolver.setPathMatcher() does not reach PathMatchingFilters
维护者通常 1 天内回复
评估
- 难度
- 3/5
- 预计耗时
- 半天
- 新手友好度
- 38/100
- Issue 类型
- 缺陷
- 描述清晰度
- 描述清楚
- 活跃度
- 活跃
- 技术栈
- java
调研方向
Start with PathMatchingFilterChainResolver.setPathMatcher, FilterChainManager.createChain, and PathMatchingFilter.preHandle; the mismatch is between the resolver's matcher and each filter's private AntPathMatcher. Compare with the Spring wiring in #2928. Exercise the resolver through an AbstractShiroFilter with the regex chain from the report; done means /secure/report without credentials returns 401 via authcBasic, while the literal /admin/panel chain still works.
由索引模型根据 Issue 内容生成。
描述
Search before asking
- I had searched in the issues, including closed issues, and found no similar issues.
Environment
Java 21, embedded Tomcat 11.0.13, plain servlet API (no Spring, no Guice, no INI).
Shiro version
3.0.2. main at ea33e99 has the same code.
What was the actual outcome?
PathMatchingFilterChainResolver.setPathMatcher() changes only the resolver's own matcher. Each PathMatchingFilter keeps its private AntPathMatcher and matches the path again in preHandle. With RegExPatternMatcher and the chain /secure/[^/]+ = authcBasic, the resolver selects the chain, the filter's Ant match fails, and preHandle returns true, so authcBasic does not run and the request goes through without credentials.
What was the expected outcome?
The filters in the selected chain use the same matcher as the resolver, as ShiroFilterFactoryBean already arranges for Spring (#2928), so authcBasic runs for /secure/report.
How to reproduce
var resolver = new PathMatchingFilterChainResolver();
resolver.setPathMatcher(new RegExPatternMatcher());
resolver.getFilterChainManager().createChain("/secure/[^/]+", "authcBasic");
// Install the resolver in an AbstractShiroFilter, then:
// GET /secure/report without credentials -> 200 (expected 401)
A literal chain such as /admin/panel = authcBasic answers 401 in the same setup, because both matchers read it alike. I have a pull request that applies the resolver's matcher to the PathMatchingFilters in its FilterChainManager.
- 主要语言
- Java
- 星标
- 4.5k
- 派生
- 2.3k
- 平均合并
- 1 天 5 分钟
- 30 天内合并 PR
- 27
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
apache/shiro 的其他 Issue
-
难度 2/5 1-3 小时 新手友好度 82/100
维护者通常 1 天内回复
-
[Bug] Jakarta EE: secure-session-cookie.disabled is ignored in Faces Production mode可能已有人在做 @AndrewG10i 于 5 天前认领。 未关闭java valid
apache/shiro#2962 · 2 条评论 · 已指派 1 人 ·
维护者通常 1 天内回复
-
Enable strict authorization configuration by default in 3.1可能已有人在做 @lprimak 于 11 天前认领。 未关闭java
难度 4/5 3-5 天 新手友好度 35/100
维护者通常 1 天内回复
-
help-wanted java valid
难度 5/5 一周以上 新手友好度 15/100
维护者通常 1 天内回复
-
valid
难度 4/5 3-5 天 新手友好度 35/100
维护者通常 1 天内回复
相似的 Issue
-
needs-area-label
难度 2/5 1-3 小时 新手友好度 68/100
维护者通常 1 天内回复
-
难度 1/5 1 小时以内 新手友好度 88/100
-
bug module: hybrid priority: high
难度 2/5 1-3 小时 新手友好度 72/100
bancolombia/bin-stash#92 ·
-
bug module:pubsub priority:P3
难度 2/5 1-3 小时 新手友好度 72/100
flink-gcp/flink-connector-gcp#2325 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 78/100
eclipse-dirigible/dirigible#8877 ·
维护者通常 1 天内回复