EnableMfaFiltersConfiguration.mfaBeanPostProcessor() should be static to avoid BeanPostProcessorChecker warning
メンテナーはふだん 5 日以内に返信
まだ誰も着手していません。
評価
- 難易度
- 1/5
- 見積もり時間
- 1時間未満
- 初心者へのやさしさ
- 88/100
- issue の種類
- バグ
- 明瞭さ
- 明確に書かれている
- 活発さ
- 活発
- 技術スタック
- java, spring-boot
調査の方向性
ファクトリメソッド mfaBeanPostProcessor() は、パッケージ org.springframework.security.config.annotation.authorization の EnableMfaFiltersConfiguration で宣言されています。そのクラスを開き、返している内部クラス EnableMfaFiltersPostProcessor を確認してから、メソッドに static 修飾子を追加してください。メソッドが static になり、プロジェクトがコンパイルでき、既存の設定テストが起動ログに BeanPostProcessorChecker の警告を出さずに通れば完了です。
索引モデルが issue の本文から書いたものです。
説明
Describe the bug
When @EnableMultiFactorAuthentication is used, the following warning is logged on every application startup:
WARN o.s.c.s.PostProcessorRegistrationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.security.config.annotation.authorization.EnableMfaFiltersConfiguration' of type [org.springframework.security.config.annotation.authorization.EnableMfaFiltersConfiguration] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying). The currently created BeanPostProcessor [mfaBeanPostProcessor] is declared through a non-static factory method on that class; consider declaring it as static instead.
EnableMfaFiltersConfiguration declares its BeanPostProcessor through a non-static @Bean method:
@Bean
BeanPostProcessor mfaBeanPostProcessor() {
return new EnableMfaFiltersPostProcessor();
}
Because the factory method is non-static, the configuration class itself has to be instantiated early, while post-processors are still being registered. This triggers the warning. The same code is present on main, 7.1.x, and 7.0.x.
To Reproduce
- Create a Spring Boot application with Spring Security.
- Add
@EnableMultiFactorAuthentication(authorities = {FactorGrantedAuthority.PASSWORD_AUTHORITY, FactorGrantedAuthority.OTT_AUTHORITY})to a@Configurationclass. - Start the application and check the startup log.
Expected behavior
No BeanPostProcessorChecker warning is logged for Spring Security's own infrastructure configuration.
Suggested fix
Declare the factory method as static. EnableMfaFiltersPostProcessor is already a private static nested class and does not depend on the enclosing instance, so this should be a safe one-line change:
@Bean
static BeanPostProcessor mfaBeanPostProcessor() {
return new EnableMfaFiltersPostProcessor();
}
Similar warnings were fixed this way in the past (e.g. gh-14751, gh-9845).
Environment
- Spring Boot 4.2.0
- Spring Security 7.2.0
- Spring Framework 7.1.0
- Java 25
Workaround
Suppress the logger:
logging:
level:
"[org.springframework.context.support.PostProcessorRegistrationDelegate$BeanPostProcessorChecker]": error
- 主要言語
- Java
- スター
- 9.7k
- フォーク
- 6.4k
- 平均マージ
- 5日 35分
- マージ済み PR(30日)
- 19
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
spring-projects/spring-security のほかの issue
-
OidcUserInfo builder shoud accept Instant for the updateAt method対応中かも @KaranCodez が 22 日前に担当しました。 オープンstatus: waiting-for-triage type: bug
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
spring-projects/spring-security#20013 ·
メンテナーはふだん 5 日以内に返信
-
status: waiting-for-triage
難易度 2/5 1〜3時間 初心者へのやさしさ 62/100
spring-projects/spring-security#19996 ·
メンテナーはふだん 5 日以内に返信
-
Allow the HTTP QUERY method in the default firewalls対応中かも @Sudhakar7J が 21 日前に担当しました。 オープンstatus: waiting-for-triage type: enhancement
難易度 2/5 1〜3時間 初心者へのやさしさ 74/100
spring-projects/spring-security#19995 · リアクション 1 件 ·
メンテナーはふだん 5 日以内に返信
-
status: waiting-for-triage
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
spring-projects/spring-security#19984 ·
メンテナーはふだん 5 日以内に返信
-
Spring-security-7.1.xsd schema validates request-matcher incorrectly対応中かも @suryakant-source が 32 日前に担当しました。 オープンstatus: waiting-for-triage type: bug
難易度 2/5 1〜3時間 初心者へのやさしさ 66/100
spring-projects/spring-security#19981 · コメント 1 件 ·
メンテナーはふだん 5 日以内に返信
spring-projects/spring-security の issue をすべて見る