From 2224743a6215764649dcf16dcfdb58dfbd68e9c0 Mon Sep 17 00:00:00 2001
From: Jacek Kowalski <Jacek@jacekk.info>
Date: Wed, 06 Oct 2021 21:45:13 +0000
Subject: [PATCH] Update README to mention the difference between CAS URL and login URL.

---
 src/main/java/org/keycloak/protocol/cas/CASLoginProtocol.java |   11 +++++++++--
 1 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/src/main/java/org/keycloak/protocol/cas/CASLoginProtocol.java b/src/main/java/org/keycloak/protocol/cas/CASLoginProtocol.java
index 4557c7a..14f276a 100644
--- a/src/main/java/org/keycloak/protocol/cas/CASLoginProtocol.java
+++ b/src/main/java/org/keycloak/protocol/cas/CASLoginProtocol.java
@@ -12,6 +12,7 @@
 import org.keycloak.protocol.cas.utils.LogoutHelper;
 import org.keycloak.protocol.oidc.utils.OAuth2Code;
 import org.keycloak.protocol.oidc.utils.OAuth2CodeParser;
+import org.keycloak.services.ErrorPage;
 import org.keycloak.services.managers.ResourceAdminManager;
 import org.keycloak.sessions.AuthenticationSessionModel;
 
@@ -111,11 +112,16 @@
 
     @Override
     public Response sendError(AuthenticationSessionModel authSession, Error error) {
-        return Response.serverError().entity(error).build();
+        if (authSession.getClientNotes().containsKey(CASLoginProtocol.GATEWAY_PARAM)) {
+            if (error == Error.PASSIVE_INTERACTION_REQUIRED || error == Error.PASSIVE_LOGIN_REQUIRED) {
+                return Response.status(302).location(URI.create(authSession.getRedirectUri())).build();
+            }
+        }
+        return ErrorPage.error(session, authSession, Response.Status.INTERNAL_SERVER_ERROR, error.name());
     }
 
     @Override
-    public void backchannelLogout(UserSessionModel userSession, AuthenticatedClientSessionModel clientSession) {
+    public Response backchannelLogout(UserSessionModel userSession, AuthenticatedClientSessionModel clientSession) {
         String logoutUrl = clientSession.getRedirectUri();
         String serviceTicket = clientSession.getNote(CASLoginProtocol.SESSION_SERVICE_TICKET);
         //check if session is fully authenticated (i.e. serviceValidate has been called)
@@ -124,6 +130,7 @@
         }
         ClientModel client = clientSession.getClient();
         new ResourceAdminManager(session).logoutClientSession(realm, client, clientSession);
+        return Response.ok().build();
     }
 
     private void sendSingleLogoutRequest(String logoutUrl, String serviceTicket) {

--
Gitblit v1.9.1