Skip to content

Commit 1ebd663

Browse files
Patrick Schmidtmarcusdacoregio
Patrick Schmidt
authored andcommitted
doc: added hint to declare GrantedAuthorityDefaults as infrastructure bean
Closes gh-14779
1 parent 0919844 commit 1ebd663

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

docs/modules/ROOT/pages/reactive/authorization/method.adoc

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@ Java::
105105
[source,java,role="primary"]
106106
----
107107
@Bean
108+
@Role(BeanDefinition.ROLE_INFRASTRUCTURE)
108109
static GrantedAuthorityDefaults grantedAuthorityDefaults() {
109110
return new GrantedAuthorityDefaults("MYPREFIX_");
110111
}
@@ -113,7 +114,8 @@ static GrantedAuthorityDefaults grantedAuthorityDefaults() {
113114

114115
[TIP]
115116
====
116-
We expose `GrantedAuthorityDefaults` using a `static` method to ensure that Spring publishes it before it initializes Spring Security's method security `@Configuration` classes
117+
We expose `GrantedAuthorityDefaults` using a `static` method to ensure that Spring publishes it before it initializes Spring Security's method security `@Configuration` classes.
118+
Since the `GrantedAuthorityDefaults` bean is part of internal workings of Spring Security, we should also expose it as an infrastructural bean effectively avoiding some warnings related to bean post-processing (see https://github.com/spring-projects/spring-security/issues/14751[gh-14751]).
117119
====
118120

119121
[[jc-reactive-method-security-custom-authorization-manager]]

docs/modules/ROOT/pages/servlet/authorization/method-security.adoc

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,7 @@ Java::
234234
[source,java,role="primary"]
235235
----
236236
@Bean
237+
@Role(BeanDefinition.ROLE_INFRASTRUCTURE)
237238
static GrantedAuthorityDefaults grantedAuthorityDefaults() {
238239
return new GrantedAuthorityDefaults("MYPREFIX_");
239240
}
@@ -245,6 +246,7 @@ Kotlin::
245246
----
246247
companion object {
247248
@Bean
249+
@Role(BeanDefinition.ROLE_INFRASTRUCTURE)
248250
fun grantedAuthorityDefaults() : GrantedAuthorityDefaults {
249251
return GrantedAuthorityDefaults("MYPREFIX_");
250252
}
@@ -265,7 +267,8 @@ Xml::
265267

266268
[TIP]
267269
====
268-
We expose `GrantedAuthorityDefaults` using a `static` method to ensure that Spring publishes it before it initializes Spring Security's method security `@Configuration` classes
270+
We expose `GrantedAuthorityDefaults` using a `static` method to ensure that Spring publishes it before it initializes Spring Security's method security `@Configuration` classes.
271+
Since the `GrantedAuthorityDefaults` bean is part of internal workings of Spring Security, we should also expose it as an infrastructural bean effectively avoiding some warnings related to bean post-processing (see https://github.com/spring-projects/spring-security/issues/14751[gh-14751]).
269272
====
270273

271274
[[jc-method-security-custom-authorization-manager]]

0 commit comments

Comments
 (0)