|
50 | 50 | import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
51 | 51 | import org.springframework.context.ApplicationContext;
|
52 | 52 | import org.springframework.context.annotation.Bean;
|
| 53 | +import org.springframework.context.annotation.Lazy; |
53 | 54 | import org.springframework.core.env.Environment;
|
| 55 | +import org.springframework.security.authentication.AuthenticationManager; |
54 | 56 | import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder;
|
55 | 57 | import org.springframework.security.config.annotation.web.builders.HttpSecurity;
|
56 | 58 | import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
|
@@ -85,7 +87,11 @@ public class KeycloakAuthenticationBackend implements IAuthenticationBackend {
|
85 | 87 |
|
86 | 88 | @Inject
|
87 | 89 | ApplicationContext ctx;
|
88 |
| - |
| 90 | + |
| 91 | + @Inject |
| 92 | + @Lazy |
| 93 | + AuthenticationManager authenticationManager; |
| 94 | + |
89 | 95 | @Override
|
90 | 96 | public String getName() {
|
91 | 97 | return NAME;
|
@@ -126,14 +132,14 @@ protected KeycloakAuthenticationProcessingFilter keycloakAuthenticationProcessin
|
126 | 132 | // Possible solution for issue #21037, create a custom RequestMatcher that doesn't include a QueryParamPresenceRequestMatcher(OAuth2Constants.ACCESS_TOKEN) request matcher.
|
127 | 133 | // The QueryParamPresenceRequestMatcher(OAuth2Constants.ACCESS_TOKEN) caused the HTTP requests to be changed before they where processed.
|
128 | 134 | // Because the HTTP requests are adapted before they are processed, the requested failed to complete successfully and caused an io.undertow.server.TruncatedResponseException
|
129 |
| - // If in the future we need a RequestMatcher for het ACCESS_TOKEN, we can implement one ourself |
| 135 | + // If in the future we need a RequestMatcher for het ACCESS_TOKEN, we can implement one ourself |
130 | 136 | RequestMatcher requestMatcher =
|
131 | 137 | new OrRequestMatcher(
|
132 | 138 | new AntPathRequestMatcher(KeycloakAuthenticationProcessingFilter.DEFAULT_LOGIN_URL),
|
133 | 139 | new RequestHeaderRequestMatcher(KeycloakAuthenticationProcessingFilter.AUTHORIZATION_HEADER)
|
134 | 140 | );
|
135 |
| - |
136 |
| - KeycloakAuthenticationProcessingFilter filter = new KeycloakAuthenticationProcessingFilter(webSecurityConfigurerAdapter.authenticationManagerBean(), requestMatcher); |
| 141 | + |
| 142 | + KeycloakAuthenticationProcessingFilter filter = new KeycloakAuthenticationProcessingFilter(authenticationManager, requestMatcher); |
137 | 143 | filter.setSessionAuthenticationStrategy(sessionAuthenticationStrategy());
|
138 | 144 | // Fix: call afterPropertiesSet manually, because Spring doesn't invoke it for some reason.
|
139 | 145 | filter.setApplicationContext(ctx);
|
|
0 commit comments