From 4dcf2f5870ebee2a49222ae5ce5af4b3ef74b369 Mon Sep 17 00:00:00 2001 From: Ludy87 Date: Sat, 25 May 2024 18:25:13 +0200 Subject: [PATCH] Update CustomOAuth2LogoutSuccessHandler.java --- .../CustomOAuth2LogoutSuccessHandler.java | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/src/main/java/stirling/software/SPDF/config/security/oauth2/CustomOAuth2LogoutSuccessHandler.java b/src/main/java/stirling/software/SPDF/config/security/oauth2/CustomOAuth2LogoutSuccessHandler.java index 1dca2df9..f8b76ab9 100644 --- a/src/main/java/stirling/software/SPDF/config/security/oauth2/CustomOAuth2LogoutSuccessHandler.java +++ b/src/main/java/stirling/software/SPDF/config/security/oauth2/CustomOAuth2LogoutSuccessHandler.java @@ -37,7 +37,7 @@ public class CustomOAuth2LogoutSuccessHandler extends SimpleUrlLogoutSuccessHand HttpServletRequest request, HttpServletResponse response, Authentication authentication) throws IOException, ServletException { String param = "logout=true"; - String provider = null; + String registrationId = null; String issuer = null; String clientId = null; @@ -45,21 +45,18 @@ public class CustomOAuth2LogoutSuccessHandler extends SimpleUrlLogoutSuccessHand if (authentication instanceof OAuth2AuthenticationToken) { OAuth2AuthenticationToken oauthToken = (OAuth2AuthenticationToken) authentication; - String registrationId = oauthToken.getAuthorizedClientRegistrationId(); + registrationId = oauthToken.getAuthorizedClientRegistrationId(); - provider = registrationId; - logger.info(registrationId); - Provider pro; try { - pro = oauth.getClient().get(registrationId); - issuer = pro.getIssuer(); - clientId = pro.getClientId(); + Provider provider = oauth.getClient().get(registrationId); + issuer = provider.getIssuer(); + clientId = provider.getClientId(); } catch (Exception e) { e.printStackTrace(); } } else { - provider = oauth.getProvider() != null ? oauth.getProvider() : ""; + registrationId = oauth.getProvider() != null ? oauth.getProvider() : ""; issuer = oauth.getIssuer(); clientId = oauth.getClientId(); } @@ -84,7 +81,7 @@ public class CustomOAuth2LogoutSuccessHandler extends SimpleUrlLogoutSuccessHand logger.info("Session invalidated: " + sessionId); } - switch (provider) { + switch (registrationId) { case "keycloak": // Add Keycloak specific logout URL if needed String logoutUrl =