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

Đang mở
#2,969 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

@4n86rakam1 đang làm issue này rồi.

Từ ngày 23/11/2026.

  • #2970 của @4n86rakam1 — đang mở

Đánh giá

Độ khó
3/5
Thời gian dự kiến
Nửa ngày
Mức phù hợp với người mới
38/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
java
Lĩnh vực
authentication, security

Hướng nghiên cứu

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.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

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.

Ngôn ngữ chính
Java
Star
4.5k
Fork
2.3k
Merge trung bình
1 ngày 5 phút
Pull request đã merge (30 ngày)
27

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của apache/shiro

Tất cả issue của apache/shiro

Issue tương tự

Thêm issue về Java

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.