Skip to content

@EnableReactiveMethodSecurity causes premature initialization of the ObservationRegistry and prevents it from being post-processed #12780

@wilkinsona

Description

@wilkinsona

Describe the bug

@EnableReactiveMethodSecurity causes premature initialization of the ObservationRegistry and prevents it from being post-processed.

The preAuthorizeInterceptor bean defined in ReactiveAuthorizationManagerMethodSecurityConfiguration is an Advisor so it's created very early by the AOP infrastructure. It injects an ObjectProvider<ObservationRegistry> which should delay the creation of the ObservationRegistry. Unfortunately, this provider is passed into ReactiveAuthorizationManagerMethodSecurityConfiguration#manager which immediately calls getIfAvailable(). As a result the ObservationRegistry is created very early as part of setting up the AOP infrastructure and this prevents it from being post-processed.

To Reproduce

See the sample provided in spring-projects/spring-boot#34366.

Expected behavior

@EnableReactiveMethodSecurity does not prevent the ObservationRegistry from being post-processed.

Sample

See the sample provided in spring-projects/spring-boot#34366.

Metadata

Metadata

Assignees

Labels

in: configAn issue in spring-security-configtype: bugA general bug

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions