diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index f4e8d467ee..712da3988e 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -67,6 +67,17 @@ jobs: npx playwright test --reporter=list env: OPENIDM_URL: http://localhost:8080 + - name: UI Smoke Tests with /myidm context path (Playwright) + if: runner.os == 'Linux' + run: | + openidm/shutdown.sh || true + JAVA_OPTS="-Dopenidm.context.path=/myidm" openidm/startup.sh & + timeout 3m bash -c 'until grep -q "OpenIDM ready" openidm/logs/openidm0.log.0 ; do sleep 5; done' || cat openidm/logs/openidm0.log.0 + cd e2e + npx playwright test --reporter=list + env: + OPENIDM_URL: http://localhost:8080 + OPENIDM_CONTEXT_PATH: /myidm - name: Test on Windows if: runner.os == 'Windows' run: | diff --git a/e2e/ui-smoke-test.spec.mjs b/e2e/ui-smoke-test.spec.mjs index 7d95d8689b..658b55cfe4 100644 --- a/e2e/ui-smoke-test.spec.mjs +++ b/e2e/ui-smoke-test.spec.mjs @@ -20,6 +20,7 @@ import { test, expect } from "@playwright/test"; const BASE_URL = process.env.OPENIDM_URL || "http://localhost:8080"; const ADMIN_USER = process.env.OPENIDM_ADMIN_USER || "openidm-admin"; const ADMIN_PASS = process.env.OPENIDM_ADMIN_PASS || "openidm-admin"; +const CONTEXT_PATH = process.env.OPENIDM_CONTEXT_PATH || "/openidm"; /** Log in to the Admin UI and wait for the navigation bar to appear. */ async function loginToAdmin(page) { @@ -119,7 +120,7 @@ test.describe("OpenIDM UI Smoke Tests", () => { }); test("REST API ping is accessible", async ({ request }) => { - const response = await request.get(`${BASE_URL}/openidm/info/ping`, { + const response = await request.get(`${BASE_URL}${CONTEXT_PATH}/info/ping`, { headers: { "X-OpenIDM-Username": ADMIN_USER, "X-OpenIDM-Password": ADMIN_PASS, @@ -131,7 +132,7 @@ test.describe("OpenIDM UI Smoke Tests", () => { }); test("REST API config endpoint is accessible", async ({ request }) => { - const response = await request.get(`${BASE_URL}/openidm/config/ui/configuration`, { + const response = await request.get(`${BASE_URL}${CONTEXT_PATH}/config/ui/configuration`, { headers: { "X-OpenIDM-Username": ADMIN_USER, "X-OpenIDM-Password": ADMIN_PASS, diff --git a/openidm-servlet/src/main/java/org/forgerock/openidm/ui/internal/service/ResourceServlet.java b/openidm-servlet/src/main/java/org/forgerock/openidm/ui/internal/service/ResourceServlet.java index c9702b57ca..2150845934 100644 --- a/openidm-servlet/src/main/java/org/forgerock/openidm/ui/internal/service/ResourceServlet.java +++ b/openidm-servlet/src/main/java/org/forgerock/openidm/ui/internal/service/ResourceServlet.java @@ -19,12 +19,14 @@ */ package org.forgerock.openidm.ui.internal.service; +import java.io.ByteArrayOutputStream; import java.io.File; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.net.URL; import java.net.URLConnection; +import java.nio.charset.StandardCharsets; import java.util.Dictionary; import java.util.Hashtable; import java.util.Map; @@ -228,6 +230,8 @@ private void handle(HttpServletRequest req, HttpServletResponse res, URL url, St if (!resourceModified(lastModified, req.getDateHeader("If-Modified-Since"))) { res.setStatus(HttpServletResponse.SC_NOT_MODIFIED); + } else if (resName.equals("/index.html")) { + copyIndexHtml(url, res); } else { copyResource(url, res); } @@ -277,6 +281,37 @@ private boolean resourceModified(long resTimestamp, long modSince) { return resTimestamp == 0 || modSince == -1 || resTimestamp > modSince; } + private void copyIndexHtml(URL url, HttpServletResponse res) + throws IOException { + String contextPath = IdentityServer.getInstance().getProperty("openidm.context.path", "/openidm"); + if (contextPath.startsWith("/")) { + contextPath = contextPath.substring(1); + } + // Sanitize to prevent injection: allow only alphanumeric, hyphens and dots + contextPath = contextPath.replaceAll("[^a-zA-Z0-9\\-.]", ""); + + InputStream is = null; + try { + is = url.openStream(); + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + byte[] buf = new byte[1024]; + int n; + while ((n = is.read(buf, 0, buf.length)) >= 0) { + baos.write(buf, 0, n); + } + String html = baos.toString(StandardCharsets.UTF_8); + String injection = ""; + html = html.replaceFirst("", injection + ""); + byte[] htmlBytes = html.getBytes(StandardCharsets.UTF_8); + res.setContentLength(htmlBytes.length); + res.getOutputStream().write(htmlBytes); + } finally { + if (is != null) { + is.close(); + } + } + } + private void copyResource(URL url, HttpServletResponse res) throws IOException { OutputStream os = null; diff --git a/openidm-ui/openidm-ui-admin/src/main/js/org/forgerock/openidm/ui/admin/delegates/AuditDelegate.js b/openidm-ui/openidm-ui-admin/src/main/js/org/forgerock/openidm/ui/admin/delegates/AuditDelegate.js index 854fdfc5d4..01cfcd1605 100644 --- a/openidm-ui/openidm-ui-admin/src/main/js/org/forgerock/openidm/ui/admin/delegates/AuditDelegate.js +++ b/openidm-ui/openidm-ui-admin/src/main/js/org/forgerock/openidm/ui/admin/delegates/AuditDelegate.js @@ -20,7 +20,7 @@ define([ "org/forgerock/commons/ui/common/main/AbstractDelegate" ], function($, constants, AbstractDelegate) { - var obj = new AbstractDelegate(constants.host + "/openidm/audit/"); + var obj = new AbstractDelegate(constants.host + "/" + constants.context + "/audit/"); obj.availableHandlers = function() { return obj.serviceCall({ diff --git a/openidm-ui/openidm-ui-admin/src/main/js/org/forgerock/openidm/ui/admin/delegates/ConnectorDelegate.js b/openidm-ui/openidm-ui-admin/src/main/js/org/forgerock/openidm/ui/admin/delegates/ConnectorDelegate.js index 74de9cc5e9..dde5cb05f4 100644 --- a/openidm-ui/openidm-ui-admin/src/main/js/org/forgerock/openidm/ui/admin/delegates/ConnectorDelegate.js +++ b/openidm-ui/openidm-ui-admin/src/main/js/org/forgerock/openidm/ui/admin/delegates/ConnectorDelegate.js @@ -22,7 +22,7 @@ define([ "org/forgerock/commons/ui/common/main/EventManager" ], function($, _, constants, AbstractDelegate, eventManager) { - var obj = new AbstractDelegate(constants.host + "/openidm/system"); + var obj = new AbstractDelegate(constants.host + "/" + constants.context + "/system"); obj.connectorDelegateCache = {}; diff --git a/openidm-ui/openidm-ui-admin/src/main/js/org/forgerock/openidm/ui/admin/delegates/ExternalAccessDelegate.js b/openidm-ui/openidm-ui-admin/src/main/js/org/forgerock/openidm/ui/admin/delegates/ExternalAccessDelegate.js index ef5dca25e2..fbf6c1a013 100644 --- a/openidm-ui/openidm-ui-admin/src/main/js/org/forgerock/openidm/ui/admin/delegates/ExternalAccessDelegate.js +++ b/openidm-ui/openidm-ui-admin/src/main/js/org/forgerock/openidm/ui/admin/delegates/ExternalAccessDelegate.js @@ -19,7 +19,7 @@ define([ "org/forgerock/commons/ui/common/main/AbstractDelegate" ], function(constants, AbstractDelegate) { - var obj = new AbstractDelegate(constants.host + "/openidm/endpoint/oauthproxy"); + var obj = new AbstractDelegate(constants.host + "/" + constants.context + "/endpoint/oauthproxy"); obj.getToken = function(id, authCode, redirectUri, tokenUrl, connectorLocation) { var googleDetails = "grant_type=authorization_code&code=" +authCode +"&client_id=" +id +"&redirect_uri=" +redirectUri, @@ -48,7 +48,7 @@ define([ obj.externalRestRequest = (url, method, body, headers) => { method = method || "GET"; return obj.serviceCall({ - serviceUrl: constants.host + "/openidm/external/rest", + serviceUrl: constants.host + "/" + constants.context + "/external/rest", url: "?_action=call", type: "POST", data: JSON.stringify({ diff --git a/openidm-ui/openidm-ui-admin/src/main/js/org/forgerock/openidm/ui/admin/delegates/MaintenanceDelegate.js b/openidm-ui/openidm-ui-admin/src/main/js/org/forgerock/openidm/ui/admin/delegates/MaintenanceDelegate.js index 09e542c215..77037fecbd 100644 --- a/openidm-ui/openidm-ui-admin/src/main/js/org/forgerock/openidm/ui/admin/delegates/MaintenanceDelegate.js +++ b/openidm-ui/openidm-ui-admin/src/main/js/org/forgerock/openidm/ui/admin/delegates/MaintenanceDelegate.js @@ -21,7 +21,7 @@ define([ "org/forgerock/commons/ui/common/main/AbstractDelegate" ], function($, _, constants, AbstractDelegate) { - var obj = new AbstractDelegate(constants.host + "/openidm/maintenance"); + var obj = new AbstractDelegate(constants.host + "/" + constants.context + "/maintenance"); obj.getStatus = function () { return obj.serviceCall({ diff --git a/openidm-ui/openidm-ui-admin/src/main/js/org/forgerock/openidm/ui/admin/delegates/ReconDelegate.js b/openidm-ui/openidm-ui-admin/src/main/js/org/forgerock/openidm/ui/admin/delegates/ReconDelegate.js index fcc08fa8b9..90d6f31ec8 100644 --- a/openidm-ui/openidm-ui-admin/src/main/js/org/forgerock/openidm/ui/admin/delegates/ReconDelegate.js +++ b/openidm-ui/openidm-ui-admin/src/main/js/org/forgerock/openidm/ui/admin/delegates/ReconDelegate.js @@ -25,7 +25,7 @@ define([ "org/forgerock/commons/ui/common/main/Router" ], function($, _, constants, AbstractDelegate, configuration, eventManager, spinner, router) { - var obj = new AbstractDelegate(constants.host + "/openidm/recon"); + var obj = new AbstractDelegate(constants.host + "/" + constants.context + "/recon"); obj.waitForAll = function (reconIds, suppressSpinner, progressCallback, delayTime) { var resultPromise = $.Deferred(), @@ -149,7 +149,7 @@ define([ obj.stopRecon = function (id, suppressSpinner) { return obj.serviceCall({ "suppressSpinner": suppressSpinner, - "serviceUrl": "/openidm/recon/" + id, + "serviceUrl": "/" + constants.context + "/recon/" + id, "url": "?_action=cancel", "type": "POST" }); @@ -163,7 +163,7 @@ define([ getTargetObj = _.bind(function(link){ return this.serviceCall({ "type": "GET", - "serviceUrl": "/openidm/" + link.targetObjectId, + "serviceUrl": "/" + constants.context + "/" + link.targetObjectId, "url": "" }).then(function(targetObject){ newLinks.push({ sourceObjectId: link.sourceObjectId , targetObject: targetObject }); @@ -181,7 +181,7 @@ define([ } else { this.serviceCall({ "type": "GET", - "serviceUrl": "/openidm/audit/recon", + "serviceUrl": "/" + constants.context + "/audit/recon", "url": "?_queryFilter=" + encodeURIComponent(queryFilter) }).then(function(qry){ if(qry.result.length){ @@ -205,7 +205,7 @@ define([ var queryFilter = 'reconId eq "' + reconId + '" and ' + objectIdType + ' eq "' + objectId + '"'; return obj.serviceCall({ "type": "GET", - "serviceUrl": "/openidm/audit/recon", + "serviceUrl": "/" + constants.context + "/audit/recon", "url": "?_queryFilter=" + encodeURIComponent(queryFilter) }); }; diff --git a/openidm-ui/openidm-ui-admin/src/main/js/org/forgerock/openidm/ui/admin/delegates/SchedulerDelegate.js b/openidm-ui/openidm-ui-admin/src/main/js/org/forgerock/openidm/ui/admin/delegates/SchedulerDelegate.js index c3198ec872..5f645f55fb 100644 --- a/openidm-ui/openidm-ui-admin/src/main/js/org/forgerock/openidm/ui/admin/delegates/SchedulerDelegate.js +++ b/openidm-ui/openidm-ui-admin/src/main/js/org/forgerock/openidm/ui/admin/delegates/SchedulerDelegate.js @@ -21,7 +21,7 @@ define([ "org/forgerock/commons/ui/common/main/AbstractDelegate" ], function(_, $, constants, AbstractDelegate) { - var obj = new AbstractDelegate(constants.host + "/openidm/scheduler/job"); + var obj = new AbstractDelegate(constants.host + "/" + constants.context + "/scheduler/job"); obj.availableSchedules = function() { return obj.serviceCall({ diff --git a/openidm-ui/openidm-ui-admin/src/main/js/org/forgerock/openidm/ui/admin/delegates/ScriptDelegate.js b/openidm-ui/openidm-ui-admin/src/main/js/org/forgerock/openidm/ui/admin/delegates/ScriptDelegate.js index a41be33b44..a95a067967 100644 --- a/openidm-ui/openidm-ui-admin/src/main/js/org/forgerock/openidm/ui/admin/delegates/ScriptDelegate.js +++ b/openidm-ui/openidm-ui-admin/src/main/js/org/forgerock/openidm/ui/admin/delegates/ScriptDelegate.js @@ -20,7 +20,7 @@ define([ "org/forgerock/commons/ui/common/main/AbstractDelegate" ], function(_, constants, AbstractDelegate) { - var obj = new AbstractDelegate(constants.host + "/openidm/script"); + var obj = new AbstractDelegate(constants.host + "/" + constants.context + "/script"); obj.evalScript = function(script, additionalGlobals) { var scriptDetails = _.cloneDeep(script); diff --git a/openidm-ui/openidm-ui-admin/src/main/js/org/forgerock/openidm/ui/admin/delegates/SecurityDelegate.js b/openidm-ui/openidm-ui-admin/src/main/js/org/forgerock/openidm/ui/admin/delegates/SecurityDelegate.js index 0a663f0fc1..1c49f4b555 100644 --- a/openidm-ui/openidm-ui-admin/src/main/js/org/forgerock/openidm/ui/admin/delegates/SecurityDelegate.js +++ b/openidm-ui/openidm-ui-admin/src/main/js/org/forgerock/openidm/ui/admin/delegates/SecurityDelegate.js @@ -20,7 +20,7 @@ define([ "org/forgerock/commons/ui/common/main/AbstractDelegate" ], function($, constants, AbstractDelegate) { - var obj = new AbstractDelegate(constants.host + "/openidm/security"); + var obj = new AbstractDelegate(constants.host + "/" + constants.context + "/security"); obj.getPublicKeyCert = function (storeType, alias) { var promise = $.Deferred(); diff --git a/openidm-ui/openidm-ui-admin/src/main/js/org/forgerock/openidm/ui/admin/delegates/SyncDelegate.js b/openidm-ui/openidm-ui-admin/src/main/js/org/forgerock/openidm/ui/admin/delegates/SyncDelegate.js index 41a2016b67..2045c28772 100644 --- a/openidm-ui/openidm-ui-admin/src/main/js/org/forgerock/openidm/ui/admin/delegates/SyncDelegate.js +++ b/openidm-ui/openidm-ui-admin/src/main/js/org/forgerock/openidm/ui/admin/delegates/SyncDelegate.js @@ -26,7 +26,7 @@ define([ "org/forgerock/openidm/ui/common/delegates/ConfigDelegate" ], function($, _, constants, AbstractDelegate, configuration, eventManager, configDelegate) { - var obj = new AbstractDelegate(constants.host + "/openidm/sync"); + var obj = new AbstractDelegate(constants.host + "/" + constants.context + "/sync"); obj.performAction = function (reconId, mapping, action, sourceId, targetId, linkType) { var params = { @@ -69,13 +69,13 @@ define([ } else { return obj.serviceCall({ - "serviceUrl": constants.host + "/openidm/repo/link", + "serviceUrl": constants.host + "/" + constants.context + "/repo/link", "url": "?_queryId=links-for-" + ordinal + "&linkType=" + linkType + "&" + ordinal + "=" + encodeURIComponent(id) }).then(function (qry) { var i, deletePromises = []; for (i=0;i { return resourceDelegate.serviceCall({ "type": "POST", - "serviceUrl": "/openidm/repo/links", + "serviceUrl": "/" + constants.context + "/repo/links", "url": "?_action=command&commandId=delete-mapping-links&mapping=" + mappingName }); }); diff --git a/openidm-ui/openidm-ui-admin/src/main/js/org/forgerock/openidm/ui/admin/user/EditUserView.js b/openidm-ui/openidm-ui-admin/src/main/js/org/forgerock/openidm/ui/admin/user/EditUserView.js index 45becb35d8..64f99e7f94 100644 --- a/openidm-ui/openidm-ui-admin/src/main/js/org/forgerock/openidm/ui/admin/user/EditUserView.js +++ b/openidm-ui/openidm-ui-admin/src/main/js/org/forgerock/openidm/ui/admin/user/EditUserView.js @@ -69,7 +69,7 @@ function ($, _, if ($(e.currentTarget).attr("disabled") !== "disabled") { ResourceDelegate.serviceCall({ - serviceUrl: "/openidm/managed/user", + serviceUrl: "/" + Constants.context + "/managed/user", url: "/" + this.objectId + "?_action=resetPassword", type: "POST", success: (e) => { diff --git a/openidm-ui/openidm-ui-admin/src/main/js/org/forgerock/openidm/ui/admin/workflow/ActiveProcessesView.js b/openidm-ui/openidm-ui-admin/src/main/js/org/forgerock/openidm/ui/admin/workflow/ActiveProcessesView.js index b5121dc42c..556a44b310 100644 --- a/openidm-ui/openidm-ui-admin/src/main/js/org/forgerock/openidm/ui/admin/workflow/ActiveProcessesView.js +++ b/openidm-ui/openidm-ui-admin/src/main/js/org/forgerock/openidm/ui/admin/workflow/ActiveProcessesView.js @@ -53,7 +53,7 @@ define([ this.parentRender(_.bind(function() { var processGrid, - ProcessModel = AbstractModel.extend({ "url": "/openidm/workflow/processinstance" }), + ProcessModel = AbstractModel.extend({ "url": "/" + constants.context + "/workflow/processinstance" }), Process = AbstractCollection.extend({ model: ProcessModel }); this.model.processes = new Process(); @@ -69,7 +69,7 @@ define([ }); }); - this.model.processes.url = "/openidm/workflow/processinstance?_queryId=filtered-query"; + this.model.processes.url = "/" + constants.context + "/workflow/processinstance?_queryId=filtered-query"; this.model.processes.state.pageSize = null; this.model.processes.state.sortKey = "-startTime"; @@ -228,9 +228,9 @@ define([ } if(filterString.length > 0) { - this.model.processes.url = "/openidm/workflow/processinstance?" + filterString; + this.model.processes.url = "/" + constants.context + "/workflow/processinstance?" + filterString; } else { - this.model.processes.url = "/openidm/workflow/processinstance?_queryId=query-all-ids"; + this.model.processes.url = "/" + constants.context + "/workflow/processinstance?_queryId=query-all-ids"; } this.model.processes.getFirstPage(); diff --git a/openidm-ui/openidm-ui-admin/src/main/js/org/forgerock/openidm/ui/admin/workflow/ProcessDefinitionView.js b/openidm-ui/openidm-ui-admin/src/main/js/org/forgerock/openidm/ui/admin/workflow/ProcessDefinitionView.js index 5ff664d3ff..a45c15e4a0 100644 --- a/openidm-ui/openidm-ui-admin/src/main/js/org/forgerock/openidm/ui/admin/workflow/ProcessDefinitionView.js +++ b/openidm-ui/openidm-ui-admin/src/main/js/org/forgerock/openidm/ui/admin/workflow/ProcessDefinitionView.js @@ -23,7 +23,7 @@ define([ "org/forgerock/commons/ui/common/main/AbstractModel", "org/forgerock/openidm/ui/admin/util/WorkflowUtils" ], function(_, AbstractView, eventManager, constants, UIUtils, AbstractModel, WorkflowUtils) { - var ProcessModel = AbstractModel.extend({ url: "/openidm/workflow/processdefinition" }), + var ProcessModel = AbstractModel.extend({ url: "/" + constants.context + "/workflow/processdefinition" }), ProcessDefinitionView = AbstractView.extend({ template: "templates/admin/workflow/ProcessDefinitionViewTemplate.html", @@ -39,7 +39,7 @@ define([ this.data.processDefinition = this.model.toJSON(); - this.data.diagramUrl = "/openidm/workflow/processdefinition/" + this.model.id + "?_fields=/diagram&_mimeType=image/png"; + this.data.diagramUrl = "/" + constants.context + "/workflow/processdefinition/" + this.model.id + "?_fields=/diagram&_mimeType=image/png"; this.parentRender(_.bind(function(){ diff --git a/openidm-ui/openidm-ui-admin/src/main/js/org/forgerock/openidm/ui/admin/workflow/ProcessDefinitionsView.js b/openidm-ui/openidm-ui-admin/src/main/js/org/forgerock/openidm/ui/admin/workflow/ProcessDefinitionsView.js index e53fc45a28..3d07cd6f81 100644 --- a/openidm-ui/openidm-ui-admin/src/main/js/org/forgerock/openidm/ui/admin/workflow/ProcessDefinitionsView.js +++ b/openidm-ui/openidm-ui-admin/src/main/js/org/forgerock/openidm/ui/admin/workflow/ProcessDefinitionsView.js @@ -21,13 +21,15 @@ define([ "org/forgerock/commons/ui/common/main/AbstractModel", "org/forgerock/commons/ui/common/main/AbstractCollection", "backgrid", - "org/forgerock/openidm/ui/admin/util/BackgridUtils" + "org/forgerock/openidm/ui/admin/util/BackgridUtils", + "org/forgerock/commons/ui/common/util/Constants" ], function($, _, AdminAbstractView, AbstractModel, AbstractCollection, Backgrid, - BackgridUtils) { + BackgridUtils, + Constants) { var ProcessDefinitionsView = AdminAbstractView.extend({ template: "templates/admin/workflow/ProcessDefinitionsViewTemplate.html", events: { @@ -40,11 +42,11 @@ define([ this.parentRender(_.bind(function(){ this.parentRender(_.bind(function() { var processDefinitionGrid, - ProcessDefinitionModel = AbstractModel.extend({ "url": "/openidm/workflow/processdefinition" }), + ProcessDefinitionModel = AbstractModel.extend({ "url": "/" + Constants.context + "/workflow/processdefinition" }), Process = AbstractCollection.extend({ model: ProcessDefinitionModel }); this.model.processes = new Process(); - this.model.processes.url = "/openidm/workflow/processdefinition?_queryId=filtered-query"; + this.model.processes.url = "/" + Constants.context + "/workflow/processdefinition?_queryId=filtered-query"; this.model.processes.state.pageSize = null; processDefinitionGrid = new Backgrid.Grid({ diff --git a/openidm-ui/openidm-ui-admin/src/main/js/org/forgerock/openidm/ui/admin/workflow/ProcessHistoryView.js b/openidm-ui/openidm-ui-admin/src/main/js/org/forgerock/openidm/ui/admin/workflow/ProcessHistoryView.js index 4e9ef0aa91..8ff66ced74 100644 --- a/openidm-ui/openidm-ui-admin/src/main/js/org/forgerock/openidm/ui/admin/workflow/ProcessHistoryView.js +++ b/openidm-ui/openidm-ui-admin/src/main/js/org/forgerock/openidm/ui/admin/workflow/ProcessHistoryView.js @@ -53,7 +53,7 @@ define([ this.parentRender(_.bind(function() { var processGrid, - ProcessModel = AbstractModel.extend({ "url": "/openidm/workflow/processinstance/history" }), + ProcessModel = AbstractModel.extend({ "url": "/" + constants.context + "/workflow/processinstance/history" }), Process = AbstractCollection.extend({ model: ProcessModel }); this.model.processes = new Process(); @@ -69,7 +69,7 @@ define([ }); }); - this.model.processes.url = "/openidm/workflow/processinstance/history?_queryId=filtered-query&finished=true"; + this.model.processes.url = "/" + constants.context + "/workflow/processinstance/history?_queryId=filtered-query&finished=true"; this.model.processes.state.pageSize = null; this.model.processes.state.sortKey = "-startTime"; @@ -221,7 +221,7 @@ define([ filterString = filterString + "&processDefinitionKey=" + this.model.processTypeFilter; } - this.model.processes.url = "/openidm/workflow/processinstance/history?" + filterString; + this.model.processes.url = "/" + constants.context + "/workflow/processinstance/history?" + filterString; this.model.processes.getFirstPage(); } diff --git a/openidm-ui/openidm-ui-admin/src/main/js/org/forgerock/openidm/ui/admin/workflow/ProcessInstanceView.js b/openidm-ui/openidm-ui-admin/src/main/js/org/forgerock/openidm/ui/admin/workflow/ProcessInstanceView.js index d96c715935..ceec43865a 100644 --- a/openidm-ui/openidm-ui-admin/src/main/js/org/forgerock/openidm/ui/admin/workflow/ProcessInstanceView.js +++ b/openidm-ui/openidm-ui-admin/src/main/js/org/forgerock/openidm/ui/admin/workflow/ProcessInstanceView.js @@ -39,9 +39,9 @@ define([ BackgridUtils, UIUtils) { - var ProcessInstanceModel = AbstractModel.extend({ url: "/openidm/workflow/processinstance" }), - ProcessDefinitionModel = AbstractModel.extend({ url: "/openidm/workflow/processdefinition" }), - UserModel = AbstractModel.extend({ url: "/openidm/managed/user" }), + var ProcessInstanceModel = AbstractModel.extend({ url: "/" + constants.context + "/workflow/processinstance" }), + ProcessDefinitionModel = AbstractModel.extend({ url: "/" + constants.context + "/workflow/processdefinition" }), + UserModel = AbstractModel.extend({ url: "/" + constants.context + "/managed/user" }), TaskInstanceCollection = AbstractCollection.extend({ mode: "client" }), @@ -97,9 +97,9 @@ define([ if (this.data.processDefinition.processDiagramResourceName) { this.data.showDiagram = true; if (!this.model.get("endTime")) { - this.data.diagramUrl = "/openidm/workflow/processinstance/" + this.model.id + "?_fields=/diagram&_mimeType=image/png"; + this.data.diagramUrl = "/" + constants.context + "/workflow/processinstance/" + this.model.id + "?_fields=/diagram&_mimeType=image/png"; } else { - this.data.diagramUrl = "/openidm/workflow/processdefinition/" + this.data.processDefinition._id + "?_fields=/diagram&_mimeType=image/png"; + this.data.diagramUrl = "/" + constants.context + "/workflow/processdefinition/" + this.data.processDefinition._id + "?_fields=/diagram&_mimeType=image/png"; } } diff --git a/openidm-ui/openidm-ui-admin/src/main/js/org/forgerock/openidm/ui/admin/workflow/ProcessListView.js b/openidm-ui/openidm-ui-admin/src/main/js/org/forgerock/openidm/ui/admin/workflow/ProcessListView.js index 7050b1888d..f563e96918 100644 --- a/openidm-ui/openidm-ui-admin/src/main/js/org/forgerock/openidm/ui/admin/workflow/ProcessListView.js +++ b/openidm-ui/openidm-ui-admin/src/main/js/org/forgerock/openidm/ui/admin/workflow/ProcessListView.js @@ -20,13 +20,15 @@ define([ "org/forgerock/openidm/ui/admin/workflow/ActiveProcessesView", "org/forgerock/openidm/ui/admin/workflow/ProcessDefinitionsView", "org/forgerock/openidm/ui/admin/workflow/ProcessHistoryView", - "org/forgerock/commons/ui/common/main/AbstractCollection" + "org/forgerock/commons/ui/common/main/AbstractCollection", + "org/forgerock/commons/ui/common/util/Constants" ], function(_, AdminAbstractView, ActiveProcessesView, ProcessDefinitionsView, ProcessHistoryView, - AbstractCollection) { + AbstractCollection, + Constants) { var ProcessListView = AdminAbstractView.extend({ template: "templates/admin/workflow/ProcessListViewTemplate.html", events: { @@ -40,7 +42,7 @@ define([ this.parentRender(_.bind(function(){ this.model.processDefinitions = new AbstractCollection(); - this.model.processDefinitions.url = "/openidm/workflow/processdefinition?_queryId=filtered-query"; + this.model.processDefinitions.url = "/" + Constants.context + "/workflow/processdefinition?_queryId=filtered-query"; this.model.processDefinitions.getFirstPage().then(function(processDefinitions){ processDefinition = _.chain(processDefinitions.result) diff --git a/openidm-ui/openidm-ui-admin/src/main/js/org/forgerock/openidm/ui/admin/workflow/TaskInstanceView.js b/openidm-ui/openidm-ui-admin/src/main/js/org/forgerock/openidm/ui/admin/workflow/TaskInstanceView.js index 20b1ddcf78..ecb3815103 100644 --- a/openidm-ui/openidm-ui-admin/src/main/js/org/forgerock/openidm/ui/admin/workflow/TaskInstanceView.js +++ b/openidm-ui/openidm-ui-admin/src/main/js/org/forgerock/openidm/ui/admin/workflow/TaskInstanceView.js @@ -25,9 +25,9 @@ define([ "org/forgerock/commons/ui/common/main/AbstractModel", "org/forgerock/openidm/ui/admin/util/WorkflowUtils" ], function($, _, Handlebars, AbstractView, eventManager, constants, UIUtils, AbstractModel, WorkflowUtils) { - var TaskModel = AbstractModel.extend({ url: "/openidm/workflow/taskinstance" }), - ProcessModel = AbstractModel.extend({ url: "/openidm/workflow/processdefinition" }), - UserModel = AbstractModel.extend({ url: "/openidm/managed/user" }), + var TaskModel = AbstractModel.extend({ url: "/" + constants.context + "/workflow/taskinstance" }), + ProcessModel = AbstractModel.extend({ url: "/" + constants.context + "/workflow/processdefinition" }), + UserModel = AbstractModel.extend({ url: "/" + constants.context + "/managed/user" }), TaskInstanceView = AbstractView.extend({ template: "templates/admin/workflow/TaskInstanceViewTemplate.html", diff --git a/openidm-ui/openidm-ui-admin/src/main/js/org/forgerock/openidm/ui/admin/workflow/TaskListView.js b/openidm-ui/openidm-ui-admin/src/main/js/org/forgerock/openidm/ui/admin/workflow/TaskListView.js index 3ef0b10d46..b3d96e0ded 100644 --- a/openidm-ui/openidm-ui-admin/src/main/js/org/forgerock/openidm/ui/admin/workflow/TaskListView.js +++ b/openidm-ui/openidm-ui-admin/src/main/js/org/forgerock/openidm/ui/admin/workflow/TaskListView.js @@ -50,16 +50,16 @@ define([ render: function(args, callback) { this.parentRender(_.bind(function() { var tasksGrid, - TaskInstanceModel = AbstractModel.extend({ url: "/openidm/workflow/taskinstance" }), + TaskInstanceModel = AbstractModel.extend({ url: "/" + Constants.context + "/workflow/taskinstance" }), TaskModel = AbstractCollection.extend({ model: TaskInstanceModel, - url: "/openidm/workflow/taskinstance?_queryId=filtered-query" + url: "/" + Constants.context + "/workflow/taskinstance?_queryId=filtered-query" }), Tasks = new TaskModel(); this.model = new TaskInstanceModel(); - Tasks.url = "/openidm/workflow/taskinstance?_queryId=filtered-query"; + Tasks.url = "/" + Constants.context + "/workflow/taskinstance?_queryId=filtered-query"; Tasks.setSorting("-createTime"); Tasks.state.pageSize = null; @@ -146,11 +146,11 @@ define([ preload: true, onChange: _.bind(function(value) { if(value === "anyone") { - Tasks.url = "/openidm/workflow/taskinstance?_queryId=filtered-query"; + Tasks.url = "/" + Constants.context + "/workflow/taskinstance?_queryId=filtered-query"; } else if(value === "unassigned") { - Tasks.url = "/openidm/workflow/taskinstance?_queryId=filtered-query&unassigned=true"; + Tasks.url = "/" + Constants.context + "/workflow/taskinstance?_queryId=filtered-query&unassigned=true"; } else { - Tasks.url = "/openidm/workflow/taskinstance?_queryId=filtered-query&assignee=" + value; + Tasks.url = "/" + Constants.context + "/workflow/taskinstance?_queryId=filtered-query&assignee=" + value; } Tasks.getFirstPage(); diff --git a/openidm-ui/openidm-ui-api/src/main/resources/index.html b/openidm-ui/openidm-ui-api/src/main/resources/index.html index bfa7a784c8..1cf706cbab 100755 --- a/openidm-ui/openidm-ui-api/src/main/resources/index.html +++ b/openidm-ui/openidm-ui-api/src/main/resources/index.html @@ -51,7 +51,7 @@ url = decodeURIComponent(url[1]); } else { // default Swagger JSON URL - url = "/openidm/?_api"; + url = "/" + (window.__openidm_context || "openidm") + "/?_api"; } if (window.SwaggerTranslator) { diff --git a/openidm-ui/openidm-ui-common/src/main/js/org/forgerock/openidm/ui/common/delegates/ConfigDelegate.js b/openidm-ui/openidm-ui-common/src/main/js/org/forgerock/openidm/ui/common/delegates/ConfigDelegate.js index 57e89eccbb..eed5dd55a6 100644 --- a/openidm-ui/openidm-ui-common/src/main/js/org/forgerock/openidm/ui/common/delegates/ConfigDelegate.js +++ b/openidm-ui/openidm-ui-common/src/main/js/org/forgerock/openidm/ui/common/delegates/ConfigDelegate.js @@ -23,7 +23,7 @@ define([ "org/forgerock/commons/ui/common/main/EventManager" ], function($, _, constants, AbstractDelegate, conf, eventManager) { - var obj = new AbstractDelegate(constants.host + "/openidm/config"); + var obj = new AbstractDelegate(constants.host + "/" + constants.context + "/config"); obj.serviceCall = function (callParams) { diff --git a/openidm-ui/openidm-ui-common/src/main/js/org/forgerock/openidm/ui/common/delegates/InfoDelegate.js b/openidm-ui/openidm-ui-common/src/main/js/org/forgerock/openidm/ui/common/delegates/InfoDelegate.js index 841c3bcc67..83e9ecb9dc 100644 --- a/openidm-ui/openidm-ui-common/src/main/js/org/forgerock/openidm/ui/common/delegates/InfoDelegate.js +++ b/openidm-ui/openidm-ui-common/src/main/js/org/forgerock/openidm/ui/common/delegates/InfoDelegate.js @@ -19,7 +19,7 @@ define([ "org/forgerock/commons/ui/common/main/AbstractDelegate" ], function(constants, AbstractDelegate) { - var obj = new AbstractDelegate(constants.host + "/openidm/info/"); + var obj = new AbstractDelegate(constants.host + "/" + constants.context + "/info/"); obj.getVersion = function() { return obj.serviceCall({ diff --git a/openidm-ui/openidm-ui-common/src/main/js/org/forgerock/openidm/ui/common/delegates/InternalUserDelegate.js b/openidm-ui/openidm-ui-common/src/main/js/org/forgerock/openidm/ui/common/delegates/InternalUserDelegate.js index 79ccf2e8a5..4a0d019ed0 100644 --- a/openidm-ui/openidm-ui-common/src/main/js/org/forgerock/openidm/ui/common/delegates/InternalUserDelegate.js +++ b/openidm-ui/openidm-ui-common/src/main/js/org/forgerock/openidm/ui/common/delegates/InternalUserDelegate.js @@ -21,7 +21,7 @@ define([ "org/forgerock/commons/ui/common/main/EventManager" ], function(constants, AbstractDelegate, configuration, eventManager) { - var obj = new AbstractDelegate(constants.host + "/openidm/repo/internal/user"); + var obj = new AbstractDelegate(constants.host + "/" + constants.context + "/repo/internal/user"); obj.patchSelectedUserAttributes = function(id, rev, patchDefinitionObject, successCallback, errorCallback, noChangesCallback) { //PATCH for repo is unsupported diff --git a/openidm-ui/openidm-ui-common/src/main/js/org/forgerock/openidm/ui/common/delegates/PolicyDelegate.js b/openidm-ui/openidm-ui-common/src/main/js/org/forgerock/openidm/ui/common/delegates/PolicyDelegate.js index 26c6e983f6..0729821739 100644 --- a/openidm-ui/openidm-ui-common/src/main/js/org/forgerock/openidm/ui/common/delegates/PolicyDelegate.js +++ b/openidm-ui/openidm-ui-common/src/main/js/org/forgerock/openidm/ui/common/delegates/PolicyDelegate.js @@ -22,7 +22,7 @@ define([ "org/forgerock/commons/ui/common/main/EventManager" ], function(_, constants, AbstractDelegate, configuration, eventManager) { - var obj = new AbstractDelegate(constants.host + "/openidm/policy"); + var obj = new AbstractDelegate(constants.host + "/" + constants.context + "/policy"); obj.readEntity = function (baseEntity) { if (baseEntity === "selfservice/registration") { diff --git a/openidm-ui/openidm-ui-common/src/main/js/org/forgerock/openidm/ui/common/delegates/ResourceDelegate.js b/openidm-ui/openidm-ui-common/src/main/js/org/forgerock/openidm/ui/common/delegates/ResourceDelegate.js index 7b1ca5cff7..15022a45b4 100644 --- a/openidm-ui/openidm-ui-common/src/main/js/org/forgerock/openidm/ui/common/delegates/ResourceDelegate.js +++ b/openidm-ui/openidm-ui-common/src/main/js/org/forgerock/openidm/ui/common/delegates/ResourceDelegate.js @@ -24,7 +24,7 @@ define([ "org/forgerock/commons/ui/common/util/ObjectUtil" ], function($, _, constants, AbstractDelegate, configDelegate, messagesManager, ObjectUtil) { - var obj = new AbstractDelegate(constants.host + "/openidm/"); + var obj = new AbstractDelegate(constants.host + "/" + constants.context + "/"); obj.getSchema = function(args){ var objectType = args[0], @@ -145,7 +145,7 @@ define([ obj.linkedView = function(id, resourcePath) { return obj.serviceCall({ - serviceUrl: constants.host + "/openidm/endpoint/linkedView/" + resourcePath, + serviceUrl: constants.host + "/" + constants.context + "/endpoint/linkedView/" + resourcePath, url: id, type: "GET" }); diff --git a/openidm-ui/openidm-ui-common/src/main/js/org/forgerock/openidm/ui/common/delegates/SocialDelegate.js b/openidm-ui/openidm-ui-common/src/main/js/org/forgerock/openidm/ui/common/delegates/SocialDelegate.js index e78e1d6549..b46d96b45a 100644 --- a/openidm-ui/openidm-ui-common/src/main/js/org/forgerock/openidm/ui/common/delegates/SocialDelegate.js +++ b/openidm-ui/openidm-ui-common/src/main/js/org/forgerock/openidm/ui/common/delegates/SocialDelegate.js @@ -27,7 +27,7 @@ define([ Constants, OAuth) { - var obj = new AbstractDelegate(Constants.host + "/openidm/identityProviders"); + var obj = new AbstractDelegate(Constants.host + "/" + Constants.context + "/identityProviders"); obj.loginProviders = function () { var headers = {}, @@ -38,7 +38,7 @@ define([ return obj.serviceCall({ url: "", - serviceUrl: "/openidm/authentication", + serviceUrl: "/" + Constants.context + "/authentication", type: "get", headers: headers }).then((results) => { @@ -82,7 +82,7 @@ define([ obj.getAuthToken = function (provider, code, redirect_uri) { return this.serviceCall({ "type": "POST", - "serviceUrl": "/openidm/authentication", + "serviceUrl": "/" + Constants.context + "/authentication", "url": "?_action=getAuthToken", "data": JSON.stringify({ provider: provider, diff --git a/openidm-ui/openidm-ui-common/src/main/js/org/forgerock/openidm/ui/common/delegates/SystemHealthDelegate.js b/openidm-ui/openidm-ui-common/src/main/js/org/forgerock/openidm/ui/common/delegates/SystemHealthDelegate.js index 64a9b3ea9d..32012a29a2 100644 --- a/openidm-ui/openidm-ui-common/src/main/js/org/forgerock/openidm/ui/common/delegates/SystemHealthDelegate.js +++ b/openidm-ui/openidm-ui-common/src/main/js/org/forgerock/openidm/ui/common/delegates/SystemHealthDelegate.js @@ -20,7 +20,7 @@ define([ "org/forgerock/commons/ui/common/main/EventManager" ], function(constants, AbstractDelegate, eventManager) { - var obj = new AbstractDelegate(constants.host + "/openidm/health"); + var obj = new AbstractDelegate(constants.host + "/" + constants.context + "/health"); obj.connectorDelegateCache = {}; diff --git a/openidm-ui/openidm-ui-common/src/main/js/org/forgerock/openidm/ui/common/notifications/NotificationDelegate.js b/openidm-ui/openidm-ui-common/src/main/js/org/forgerock/openidm/ui/common/notifications/NotificationDelegate.js index 7994d3734f..e4439b9b3f 100644 --- a/openidm-ui/openidm-ui-common/src/main/js/org/forgerock/openidm/ui/common/notifications/NotificationDelegate.js +++ b/openidm-ui/openidm-ui-common/src/main/js/org/forgerock/openidm/ui/common/notifications/NotificationDelegate.js @@ -21,7 +21,7 @@ define([ "org/forgerock/commons/ui/common/main/EventManager" ], function(constants, AbstractDelegate, configuration, eventManager) { - var obj = new AbstractDelegate(constants.host + "/openidm/endpoint/usernotifications"); + var obj = new AbstractDelegate(constants.host + "/" + constants.context + "/endpoint/usernotifications"); obj.getNotificationsForUser = function(successCallback, errorCallback) { obj.serviceCall({ diff --git a/openidm-ui/openidm-ui-common/src/main/js/org/forgerock/openidm/ui/common/util/Constants.js b/openidm-ui/openidm-ui-common/src/main/js/org/forgerock/openidm/ui/common/util/Constants.js index db45bdb12a..eb25cf1d46 100644 --- a/openidm-ui/openidm-ui-common/src/main/js/org/forgerock/openidm/ui/common/util/Constants.js +++ b/openidm-ui/openidm-ui-common/src/main/js/org/forgerock/openidm/ui/common/util/Constants.js @@ -17,7 +17,7 @@ define([ "org/forgerock/commons/ui/common/util/Constants" ], function (commonConstants) { - commonConstants.context = "openidm"; + commonConstants.context = window.__openidm_context || "openidm"; commonConstants.HEADER_PARAM_PASSWORD = "X-OpenIDM-Password"; commonConstants.HEADER_PARAM_USERNAME = "X-OpenIDM-Username"; diff --git a/openidm-ui/openidm-ui-common/src/main/js/org/forgerock/openidm/ui/common/workflow/WorkflowDelegate.js b/openidm-ui/openidm-ui-common/src/main/js/org/forgerock/openidm/ui/common/workflow/WorkflowDelegate.js index 0db80b9660..8904bdca65 100644 --- a/openidm-ui/openidm-ui-common/src/main/js/org/forgerock/openidm/ui/common/workflow/WorkflowDelegate.js +++ b/openidm-ui/openidm-ui-common/src/main/js/org/forgerock/openidm/ui/common/workflow/WorkflowDelegate.js @@ -22,11 +22,11 @@ define([ var obj = {}, taskManagementUrl, processManagementUrl, taskDefinitionUrl, processDefinitionUrl, endpointUrl, processDefinitionsEndpointUrl; - taskManagementUrl = "/openidm/workflow/taskinstance"; - processManagementUrl = "/openidm/workflow/processinstance"; - processDefinitionUrl = "/openidm/workflow/processdefinition"; - endpointUrl = "/openidm/endpoint/gettasksview"; - processDefinitionsEndpointUrl = "/openidm/endpoint/getprocessesforuser"; + taskManagementUrl = "/" + constants.context + "/workflow/taskinstance"; + processManagementUrl = "/" + constants.context + "/workflow/processinstance"; + processDefinitionUrl = "/" + constants.context + "/workflow/processdefinition"; + endpointUrl = "/" + constants.context + "/endpoint/gettasksview"; + processDefinitionsEndpointUrl = "/" + constants.context + "/endpoint/getprocessesforuser"; obj.startProccess = function(proccessNameKey, params, successCallback, errorCallback) {