KEYCLOAK-8857 Update the Using Spring Boot Configuration section (#1347)

* update bean declaration example to explicitly show that it should be declared in a class separate to `KeycloakWebSecurityConfigurerAdapter`
* add explanation to possible `Circular References` problem in Spring Boot 2.6+
* remove unnecessary whitespace

Co-authored-by: Stian Thorgersen <stianst@gmail.com>
This commit is contained in:
little_pinecone 2023-03-15 14:11:47 +01:00 committed by GitHub
parent fa2daf53a4
commit 0237a4766d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -279,18 +279,24 @@ If you are using the Keycloak Spring Boot Starter to make use of the Spring Secu
====== Using Spring Boot Configuration
By Default, the Spring Security Adapter looks for a `keycloak.json` configuration file. You can make sure it looks at the configuration provided by the Spring Boot Adapter by adding this bean :
By Default, the Spring Security Adapter looks for a `keycloak.json` configuration file. You can make sure it looks at the configuration provided by the Spring Boot Adapter by adding this bean:
[source,java]
----
@Bean
public KeycloakConfigResolver keycloakConfigResolver() {
return new KeycloakSpringBootConfigResolver();
@Configuration
public class CustomKeycloakConfig {
@Bean
public KeycloakConfigResolver keycloakConfigResolver() {
return new KeycloakSpringBootConfigResolver();
}
}
----
Do not declare the `KeycloakConfigResolver` bean in a configuration class that extends `KeycloakWebSecurityConfigurerAdapter` as this will cause a `Circular References` problem in Spring Boot starting with version 2.6.0.
====== Avoid double bean registration
Spring Boot attempts to eagerly register filter beans with the web application context.