From ce9053f1bb9b741d0caadc673cc5f1ea7f149430 Mon Sep 17 00:00:00 2001 From: Martin Perina Date: Fri, 26 Jan 2024 15:32:38 +0100 Subject: [PATCH] Disable execution of CreateUserSession from GWT code CreateUserSesssion should be executed only as a part of login flow, so explicitly disable execution from GWT code. Signed-off-by: Martin Perina --- .../server/gwt/GenericApiGWTServiceImpl.java | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/frontend/webadmin/modules/frontend/src/main/java/org/ovirt/engine/ui/frontend/server/gwt/GenericApiGWTServiceImpl.java b/frontend/webadmin/modules/frontend/src/main/java/org/ovirt/engine/ui/frontend/server/gwt/GenericApiGWTServiceImpl.java index 476a018d7dd..07059d3739f 100644 --- a/frontend/webadmin/modules/frontend/src/main/java/org/ovirt/engine/ui/frontend/server/gwt/GenericApiGWTServiceImpl.java +++ b/frontend/webadmin/modules/frontend/src/main/java/org/ovirt/engine/ui/frontend/server/gwt/GenericApiGWTServiceImpl.java @@ -2,6 +2,7 @@ import java.io.IOException; import java.util.ArrayList; +import java.util.Arrays; import java.util.List; import java.util.UUID; import java.util.regex.Pattern; @@ -17,6 +18,7 @@ import org.ovirt.engine.core.common.action.ActionReturnValue; import org.ovirt.engine.core.common.action.ActionType; import org.ovirt.engine.core.common.constants.SessionConstants; +import org.ovirt.engine.core.common.errors.EngineFault; import org.ovirt.engine.core.common.interfaces.BackendLocal; import org.ovirt.engine.core.common.queries.QueryParametersBase; import org.ovirt.engine.core.common.queries.QueryReturnValue; @@ -149,12 +151,21 @@ public List runMultipleActions(ActionType actionType, ArrayList multipleParams, boolean isRunOnlyIfAllValidationPass, boolean isWaitForResult) { log.debug("Server: RunMultipleAction invoked! [amount of actions: {}]", multipleParams.size()); //$NON-NLS-1$ + // CreateUserSession should never be invoked from GWT code + if (actionType == ActionType.CreateUserSession) { + ActionReturnValue error = new ActionReturnValue(); + error.setSucceeded(false); + error.setFault(new EngineFault(new RuntimeException("Command cannot be executed from client"))); //$NON-NLS-1$ + return Arrays.asList(error); + } + String correlationId = CorrelationIdTracker.getCorrelationId(); for (ActionParametersBase params : multipleParams) { params.setSessionId(getEngineSessionId()); if (params.getCorrelationId() == null) { params.setCorrelationId(correlationId); } + } List returnValues = @@ -168,6 +179,15 @@ public ActionReturnValue runAction(ActionType actionType, ActionParametersBase params) { log.debug("Server: RunAction invoked!"); //$NON-NLS-1$ debugAction(actionType, params); + + // CreateUserSession should never be invoked from GWT code + if (actionType == ActionType.CreateUserSession) { + ActionReturnValue error = new ActionReturnValue(); + error.setSucceeded(false); + error.setFault(new EngineFault(new RuntimeException("Command cannot be executed from client"))); //$NON-NLS-1$ + return error; + } + params.setSessionId(getEngineSessionId()); if (params.getCorrelationId() == null) { params.setCorrelationId(CorrelationIdTracker.getCorrelationId());