|
43 | 43 | import org.springframework.security.oauth2.client.OAuth2AuthorizedClient; |
44 | 44 | import org.springframework.security.oauth2.client.oidc.userinfo.OidcUserRequest; |
45 | 45 | import org.springframework.security.oauth2.client.oidc.userinfo.OidcUserService; |
| 46 | +import org.springframework.security.oauth2.client.oidc.web.logout.OidcClientInitiatedLogoutSuccessHandler; |
46 | 47 | import org.springframework.security.oauth2.client.registration.ClientRegistration; |
47 | 48 | import org.springframework.security.oauth2.client.registration.ClientRegistrationRepository; |
48 | 49 | import org.springframework.security.oauth2.client.registration.InMemoryClientRegistrationRepository; |
|
57 | 58 | import org.springframework.security.oauth2.core.oidc.user.OidcUserAuthority; |
58 | 59 | import org.springframework.security.web.authentication.AuthenticationFailureHandler; |
59 | 60 | import org.springframework.security.web.authentication.logout.LogoutSuccessHandler; |
| 61 | +import org.springframework.security.web.authentication.logout.SimpleUrlLogoutSuccessHandler; |
60 | 62 | import org.springframework.web.context.request.RequestContextHolder; |
61 | 63 | import org.springframework.web.context.request.ServletRequestAttributes; |
62 | 64 | import org.springframework.web.servlet.support.ServletUriComponentsBuilder; |
@@ -159,9 +161,13 @@ public void customizeContainerEnv(Map<String, String> env) { |
159 | 161 |
|
160 | 162 | @Override |
161 | 163 | public LogoutSuccessHandler getLogoutSuccessHandler() { |
162 | | - return (request, response, authentication) -> { |
| 164 | + return (httpServletRequest, httpServletResponse, authentication) -> { |
163 | 165 | SpecExpressionContext context = SpecExpressionContext.create(authentication.getPrincipal(), authentication.getCredentials()); |
164 | | - response.sendRedirect(specExpressionResolver.evaluateToString(getLogoutSuccessURL(), context)); |
| 166 | + String resolvedLogoutUrl = specExpressionResolver.evaluateToString(getLogoutSuccessURL(), context); |
| 167 | + |
| 168 | + SimpleUrlLogoutSuccessHandler delegate = new SimpleUrlLogoutSuccessHandler(); |
| 169 | + delegate.setDefaultTargetUrl(resolvedLogoutUrl); |
| 170 | + delegate.onLogoutSuccess(httpServletRequest, httpServletResponse, authentication); |
165 | 171 | }; |
166 | 172 | } |
167 | 173 |
|
|
0 commit comments