diff --git a/components/org.wso2.carbon.identity.application.authenticator.oidc/src/main/java/org/wso2/carbon/identity/application/authenticator/oidc/logout/idpinit/processor/FederatedIdpInitLogoutProcessor.java b/components/org.wso2.carbon.identity.application.authenticator.oidc/src/main/java/org/wso2/carbon/identity/application/authenticator/oidc/logout/idpinit/processor/FederatedIdpInitLogoutProcessor.java index 6c9e9cf1..522d5eb5 100644 --- a/components/org.wso2.carbon.identity.application.authenticator.oidc/src/main/java/org/wso2/carbon/identity/application/authenticator/oidc/logout/idpinit/processor/FederatedIdpInitLogoutProcessor.java +++ b/components/org.wso2.carbon.identity.application.authenticator.oidc/src/main/java/org/wso2/carbon/identity/application/authenticator/oidc/logout/idpinit/processor/FederatedIdpInitLogoutProcessor.java @@ -175,22 +175,25 @@ protected LogoutResponse.LogoutResponseBuilder logoutUsingSid(String sid) if (log.isDebugEnabled()) { log.debug(String.format("Trying federated IdP initiated logout using sid: %s.", sid)); } - FederatedUserSession federatedUserSession = getFederatedUserSessionFromSid(sid); + List federatedUserSessionList = getFederatedUserSessionsFromSid(sid); String sessionId = null; - if (federatedUserSession != null) { - sessionId = federatedUserSession.getSessionId(); - } - if (StringUtils.isBlank(sessionId)) { - return new LogoutResponse.LogoutResponseBuilder(HttpServletResponse.SC_OK, StringUtils.EMPTY); - } + for (FederatedUserSession federatedUserSession: federatedUserSessionList) { + if (federatedUserSession != null) { + sessionId = federatedUserSession.getSessionId(); + } + if (StringUtils.isBlank(sessionId)) { + return new LogoutResponse.LogoutResponseBuilder(HttpServletResponse.SC_OK, StringUtils.EMPTY); + } - ServerSessionManagementService serverSessionManagementService = - OpenIDConnectAuthenticatorDataHolder.getInstance().getServerSessionManagementService(); - serverSessionManagementService.removeSession(sessionId); - if (log.isDebugEnabled()) { - log.debug("Session terminated for session Id: " + sessionId); + ServerSessionManagementService serverSessionManagementService = + OpenIDConnectAuthenticatorDataHolder.getInstance().getServerSessionManagementService(); + serverSessionManagementService.removeSession(sessionId); + if (log.isDebugEnabled()) { + log.debug("Session terminated for session Id: " + sessionId); + } } + return new LogoutResponse.LogoutResponseBuilder(HttpServletResponse.SC_OK, OIDCAuthenticatorConstants.BackchannelLogout.LOGOUT_SUCCESS); } @@ -220,6 +223,24 @@ protected FederatedUserSession getFederatedUserSessionFromSid(String sid) throws } } + protected List getFederatedUserSessionsFromSid(String sid) throws LogoutServerException { + + try { + UserSessionDAO userSessionDAO = new UserSessionDAOImpl(); + List federatedUserSession = userSessionDAO.getFederatedAuthSessionsDetails(sid); + if (federatedUserSession == null) { + if (log.isDebugEnabled()) { + log.debug(String.format("No session information found for the sid: %s. ", sid) + "Probably the " + + "session was cleared by another mechanism."); + } + return null; + } + return federatedUserSession; + } catch (SessionManagementServerException e) { + throw handleLogoutServerException(ErrorMessages.RETRIEVING_SESSION_ID_MAPPING_FAILED, e, sid); + } + } + /** * Terminate all the sessions of the user related sub claim. * diff --git a/pom.xml b/pom.xml index 6ba36973..7bf3ae8f 100644 --- a/pom.xml +++ b/pom.xml @@ -304,7 +304,7 @@ ${project.version} - 7.0.93 + 7.1.33 1.0.0.wso2v3 2.4.7 3.0.0.wso2v4