From 2b35c926bf402a750ca43a9c5aefa215fd2e9961 Mon Sep 17 00:00:00 2001 From: Updater Bot <updater@travis-ci.org> Date: Wed, 19 Dec 2018 18:11:26 +0000 Subject: [PATCH] Update to Keycloak 4.8.0.Final --- src/main/java/org/keycloak/protocol/cas/CASLoginProtocol.java | 17 ++++++++++------- 1 files changed, 10 insertions(+), 7 deletions(-) diff --git a/src/main/java/org/keycloak/protocol/cas/CASLoginProtocol.java b/src/main/java/org/keycloak/protocol/cas/CASLoginProtocol.java index cbcf1d0..fecd557 100644 --- a/src/main/java/org/keycloak/protocol/cas/CASLoginProtocol.java +++ b/src/main/java/org/keycloak/protocol/cas/CASLoginProtocol.java @@ -12,7 +12,6 @@ import org.keycloak.services.managers.ClientSessionCode; import org.keycloak.services.managers.ResourceAdminManager; import org.keycloak.sessions.AuthenticationSessionModel; -import org.keycloak.sessions.CommonClientSessionModel; import javax.ws.rs.core.HttpHeaders; import javax.ws.rs.core.Response; @@ -26,6 +25,7 @@ public static final String LOGIN_PROTOCOL = "cas"; public static final String SERVICE_PARAM = "service"; + public static final String TARGET_PARAM = "TARGET"; public static final String RENEW_PARAM = "renew"; public static final String GATEWAY_PARAM = "gateway"; public static final String TICKET_PARAM = "ticket"; @@ -86,14 +86,16 @@ } @Override - public Response authenticated(UserSessionModel userSession, AuthenticatedClientSessionModel clientSession) { + public Response authenticated(UserSessionModel userSession, ClientSessionContext clientSessionCtx) { + AuthenticatedClientSessionModel clientSession = clientSessionCtx.getClientSession(); ClientSessionCode<AuthenticatedClientSessionModel> accessCode = new ClientSessionCode<>(session, realm, clientSession); String service = clientSession.getRedirectUri(); //TODO validate service - accessCode.setAction(CommonClientSessionModel.Action.CODE_TO_TOKEN.name()); + + String code = accessCode.getOrGenerateCode(); KeycloakUriBuilder uriBuilder = KeycloakUriBuilder.fromUri(service); - uriBuilder.queryParam(TICKET_RESPONSE_PARAM, SERVICE_TICKET_PREFIX + accessCode.getCode()); + uriBuilder.queryParam(TICKET_RESPONSE_PARAM, SERVICE_TICKET_PREFIX + code); URI redirectUri = uriBuilder.build(); @@ -140,13 +142,14 @@ event.event(EventType.LOGOUT); event.user(userSession.getUser()).session(userSession).success(); - LoginFormsProvider infoPage = session.getProvider(LoginFormsProvider.class).setSuccess("Logout successful"); + if (redirectUri != null) { - infoPage.setAttribute("pageRedirectUri", redirectUri); + return Response.status(302).location(URI.create(redirectUri)).build(); } else { + LoginFormsProvider infoPage = session.getProvider(LoginFormsProvider.class).setSuccess("Logout successful"); infoPage.setAttribute("skipLink", true); + return infoPage.createInfoPage(); } - return infoPage.createInfoPage(); } @Override -- Gitblit v1.9.1