From df7a50d1ec7f48eb42f12603727fe831882d9256 Mon Sep 17 00:00:00 2001 From: Lubos Palisek Date: Fri, 6 Apr 2018 08:09:02 +0200 Subject: [PATCH] Update documentation of spring security adapter registering Filters twice. Two new Keycloak filters were introduced since last update of the documentation. I'm adding them to documentation to be consistent with the code. (#340) --- .../oidc/java/spring-security-adapter.adoc | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/securing_apps/topics/oidc/java/spring-security-adapter.adoc b/securing_apps/topics/oidc/java/spring-security-adapter.adoc index c10d36098b..d61c9ac45a 100644 --- a/securing_apps/topics/oidc/java/spring-security-adapter.adoc +++ b/securing_apps/topics/oidc/java/spring-security-adapter.adoc @@ -261,7 +261,7 @@ public KeycloakConfigResolver KeycloakConfigResolver() { ====== Avoid double Filter bean registration Spring Boot attempts to eagerly register filter beans with the web application context. -Therefore, when running the Keycloak Spring Security adapter in a Spring Boot environment, it may be necessary to add two ``FilterRegistrationBean``s to your security configuration to prevent the Keycloak filters from being registered twice. +Therefore, when running the Keycloak Spring Security adapter in a Spring Boot environment, it may be necessary to add ``FilterRegistrationBean``s to your security configuration to prevent the Keycloak filters from being registered twice. [source,java] @@ -290,6 +290,22 @@ public class SecurityConfig extends KeycloakWebSecurityConfigurerAdapter return registrationBean; } + @Bean + public FilterRegistrationBean keycloakAuthenticatedActionsFilterBean( + KeycloakAuthenticatedActionsFilter filter) { + FilterRegistrationBean registrationBean = new FilterRegistrationBean(filter); + registrationBean.setEnabled(false); + return registrationBean; + } + + @Bean + public FilterRegistrationBean keycloakSecurityContextRequestFilterBean( + KeycloakSecurityContextRequestFilter filter) { + FilterRegistrationBean registrationBean = new FilterRegistrationBean(filter); + registrationBean.setEnabled(false); + return registrationBean; + } + ... } ----