Two files need to be patched. Here’s the patches against v5.3.7 of the CAS source vs versions we copied into our overlay:
*** ../cas-server/support/cas-server-support-surrogate-webflow/src/main/java/org/apereo/cas/web/flow/action/SurrogateInitialAuthenticationAction.java
2019-01-21 18:02:29.000000000 -0800
--- src/main/java/org/apereo/cas/web/flow/action/SurrogateInitialAuthenticationAction.java
2019-04-11 21:14:39.000000000 -0700
***************
*** 70,75 ****
}
WebUtils.putRequestSurrogateAuthentication(context, Boolean.FALSE);
LOGGER.debug("Converted credential to surrogate for username [{}] and assigned it to webflow", realUsername);
! WebUtils.putCredential(context, sc);
}
}
--- 70,77 ----
}
WebUtils.putRequestSurrogateAuthentication(context, Boolean.FALSE);
LOGGER.debug("Converted credential to surrogate for username [{}] and assigned it to webflow", realUsername);
! // SFU Addition : change to call new replaceCredential method, which will only replace the Username credential
! // with the Surrogate credential in scopes where the Username credential previously existed
! WebUtils.replaceCredential(context, sc, UsernamePasswordCredential.class);
}
}
-------------------
*** ../cas-server/core/cas-server-core-web-api/src/main/java/org/apereo/cas/web/support/WebUtils.java
2019-01-21 18:36:37.000000000 -0800
--- src/main/java/org/apereo/cas/web/support/WebUtils.java
2019-04-11 21:14:39.000000000 -0700
***************
*** 398,403 ****
--- 398,431 ----
}
}
+ // SFU Addition
+ /**
+ * Replaces credential in the context
+ * Only instances of credential in the context that are of type clazz will be replaced
+ * @param context the content
+ * @param c the credential
+ * @param clazz Class type to replace
+ */
+ public static void replaceCredential(final RequestContext context, final Credential c, @NonNull final Class clazz) {
+ if (c == null) {
+ // We don't remove - only replace
+ return;
+ }
+ final Credential cFromRequest = (Credential) context.getRequestScope().get(PARAMETER_CREDENTIAL, clazz);
+ final Credential cFromFlow = (Credential) context.getFlowScope().get(PARAMETER_CREDENTIAL, clazz);
+ final Credential cFromConversation = (Credential) context.getConversationScope().get(PARAMETER_CREDENTIAL, clazz);
+
+ if (cFromRequest != null) {
+ context.getRequestScope().put(PARAMETER_CREDENTIAL, c);
+ }
+ if (cFromFlow != null) {
+ context.getFlowScope().put(PARAMETER_CREDENTIAL, c);
+ }
+ if (cFromConversation != null) {
+ context.getConversationScope().put(PARAMETER_CREDENTIAL, c);
+ }
+ }
+ //
/**
* Is authenticating at a public workstation?