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

オープン
#2,969 コメント 0 件 リアクション 0 件 担当者 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分
マージ済み PR(30日)
27

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

apache/shiro のほかの issue

apache/shiro の issue をすべて見る

似ている issue

Java の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。