[Bug] PathMatchingFilterChainResolver.setPathMatcher() does not reach PathMatchingFilters

未关闭
#2,969 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

@4n86rakam1 已经在做这个了。

开始于 2026年11月23日。

  • #2970 来自 @4n86rakam1 —— 未关闭

评估

难度
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

环境准备

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

apache/shiro 的其他 Issue

查看 apache/shiro 的全部 Issue

相似的 Issue

更多 Java Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。