[java-identity-provider] 01/01: IDP-1438 - Capture request parameters for use in Logout
Scott Cantor
cantor.2 at osu.edu
Thu Apr 16 16:35:22 EDT 2020
This is an automated email from the git hooks/post-receive script.
scantor pushed a commit to branch dev/IDP-1438
in repository java-identity-provider.
View the commit online:
http://git.shibboleth.net/view/?p=java-identity-provider.git;a=commit;h=3d0e4d33de6540c3388457b1d62f23778b487951
commit 3d0e4d33de6540c3388457b1d62f23778b487951
Author: Scott Cantor <cantor.2 at osu.edu>
AuthorDate: Thu Apr 16 16:33:33 2020 -0400
IDP-1438 - Capture request parameters for use in Logout
https://issues.shibboleth.net/jira/browse/IDP-1438
---
.../resources/system/flows/logout/logout-beans.xml | 4 ++-
.../impl/InitializeProfileRequestContext.java | 36 ++++++++++++++++++++--
2 files changed, 37 insertions(+), 3 deletions(-)
diff --git a/idp-conf/src/main/resources/system/flows/logout/logout-beans.xml b/idp-conf/src/main/resources/system/flows/logout/logout-beans.xml
index fb8b705..77da807 100644
--- a/idp-conf/src/main/resources/system/flows/logout/logout-beans.xml
+++ b/idp-conf/src/main/resources/system/flows/logout/logout-beans.xml
@@ -22,9 +22,11 @@
<bean id="InitializeProfileRequestContext"
class="net.shibboleth.idp.profile.impl.InitializeProfileRequestContext" scope="prototype"
+ p:httpServletRequest-ref="shibboleth.HttpServletRequest"
p:profileId="http://shibboleth.net/ns/profiles/logout"
p:loggingId="%{idp.service.logging.logout:Logout}"
- p:browserProfile="true" />
+ p:browserProfile="true"
+ p:captureQueryParameters="%{idp.logout.preserveQuery:false}" />
<bean id="FlowStartPopulateAuditContext" parent="shibboleth.AbstractPopulateAuditContext"
p:fieldExtractors="#{getObject('shibboleth.FlowStartAuditExtractors') ?: getObject('shibboleth.DefaultFlowStartAuditExtractors')}" />
diff --git a/idp-profile-impl/src/main/java/net/shibboleth/idp/profile/impl/InitializeProfileRequestContext.java b/idp-profile-impl/src/main/java/net/shibboleth/idp/profile/impl/InitializeProfileRequestContext.java
index 38d3f85..aaea986 100644
--- a/idp-profile-impl/src/main/java/net/shibboleth/idp/profile/impl/InitializeProfileRequestContext.java
+++ b/idp-profile-impl/src/main/java/net/shibboleth/idp/profile/impl/InitializeProfileRequestContext.java
@@ -17,13 +17,17 @@
package net.shibboleth.idp.profile.impl;
+import java.util.Map;
+
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import javax.annotation.concurrent.ThreadSafe;
+import javax.servlet.http.HttpServletRequest;
import net.shibboleth.idp.profile.AbstractProfileAction;
import net.shibboleth.idp.profile.ActionSupport;
+import org.opensaml.messaging.context.ScratchContext;
import org.opensaml.profile.context.ProfileRequestContext;
import net.shibboleth.utilities.java.support.component.ComponentSupport;
@@ -38,12 +42,14 @@ import org.springframework.webflow.execution.RequestContext;
*
* <p>This is a native SWF action in order to access conversation scope.</p>
*
+ * <p>Optionally saves off query parameters from request into a {@link ScratchContext}.</p>
+ *
* @event {@link org.opensaml.profile.action.EventIds#PROCEED_EVENT_ID}
* @post RequestContext.getConversationScope().get(ProfileRequestContext.BINDING_KEY) != null
*/
@ThreadSafe
public final class InitializeProfileRequestContext extends AbstractProfileAction {
-
+
/** The profile ID to initialize the context to. */
@Nullable private String profileId;
@@ -53,6 +59,9 @@ public final class InitializeProfileRequestContext extends AbstractProfileAction
/** Whether this is a browser-based profile request. */
private boolean browserProfile;
+ /** Whether to capture and store off query parameters. */
+ private boolean captureQueryParameters;
+
/**
* Set the profile ID to populate into the context.
*
@@ -78,16 +87,31 @@ public final class InitializeProfileRequestContext extends AbstractProfileAction
/**
* Set whether the request is browser-based, defaults to false.
*
- * @param browser true iff the request is browser based
+ * @param browser flag to set
*/
public void setBrowserProfile(final boolean browser) {
ComponentSupport.ifInitializedThrowUnmodifiabledComponentException(this);
browserProfile = browser;
}
+
+ /**
+ * Set whether to capture incoming query parameters in a {@link ScratchContext},
+ * defaults to false.
+ *
+ * @param flag flag to set
+ *
+ * @since 4.1.0
+ */
+ public void setCaptureQueryParameters(final boolean flag) {
+ ComponentSupport.ifInitializedThrowUnmodifiabledComponentException(this);
+
+ captureQueryParameters = flag;
+ }
/** {@inheritDoc} */
@Override
+ @SuppressWarnings("unchecked")
@Nonnull public Event execute(@Nonnull final RequestContext springRequestContext) {
// We have to override execute() because the profile request context doesn't exist yet.
@@ -106,6 +130,14 @@ public final class InitializeProfileRequestContext extends AbstractProfileAction
prc.setBrowserProfile(browserProfile);
springRequestContext.getConversationScope().put(ProfileRequestContext.BINDING_KEY, prc);
+
+ if (captureQueryParameters) {
+ final HttpServletRequest request = getHttpServletRequest();
+ if (request != null) {
+ ((Map<Object,Object>) prc.getSubcontext(ScratchContext.class, true).getMap()).putAll(
+ request.getParameterMap());
+ }
+ }
return ActionSupport.buildProceedEvent(this);
}
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the commits
mailing list