draw.io is a JavaScript, client-side editor for general diagramming.
fix: single tenant for OneDrive integrations
Krzysztof Cisło3a578988e42d
diff --git a/src/main/java/com/mxgraph/online/MSGraphAuth.java b/src/main/java/com/mxgraph/online/MSGraphAuth.javaindex 80e306bcc..a26301e69 100644--- a/src/main/java/com/mxgraph/online/MSGraphAuth.java+++ b/src/main/java/com/mxgraph/online/MSGraphAuth.java@@ -10,47 +10,52 @@ abstract public class MSGraphAuth extends AbsAuth{public static String CLIENT_SECRET_FILE_PATH = "msgraph_client_secret";public static String CLIENT_ID_FILE_PATH = "msgraph_client_id";-+ public static String TENANT_ID_FILE_PATH = "msgraph_tenant_id";+private static Config CONFIG = null;-+protected Config getConfig(){if (CONFIG == null){- String clientSerets = SecretFacade.getSecret(CLIENT_SECRET_FILE_PATH, getServletContext()),- clientIds = SecretFacade.getSecret(CLIENT_ID_FILE_PATH, getServletContext());-- CONFIG = new Config(clientIds, clientSerets);+ String clientSecrets = SecretFacade.getSecret(CLIENT_SECRET_FILE_PATH, getServletContext()),+ clientId = SecretFacade.getSecret(CLIENT_ID_FILE_PATH, getServletContext()),+ tenantId = SecretFacade.getSecret(TENANT_ID_FILE_PATH, getServletContext());++ CONFIG = new Config(clientId, clientSecrets);++ String tenantIdPathPart = (tenantId != null && !tenantId.isEmpty()) ? tenantId : "common";+ CONFIG.AUTH_SERVICE_URL = "https://login.microsoftonline.com/" + tenantIdPathPart + "/oauth2/v2.0/token";+CONFIG.REDIRECT_PATH = "/microsoft";- CONFIG.AUTH_SERVICE_URL = "https://login.microsoftonline.com/common/oauth2/v2.0/token";}-+return CONFIG;- }+ }- public MSGraphAuth()+ public MSGraphAuth(){super();cookiePath = "/microsoft";}-+protected String processAuthResponse(String authRes, boolean jsonResponse){StringBuffer res = new StringBuffer();-+//Call the opener callback function directly with the given jsonif (!jsonResponse){res.append("<!DOCTYPE html><html><head><script>");res.append("(function() { var authInfo = "); //The following is a json containing access_token}-+res.append(authRes);if (!jsonResponse){- res.append(";");- res.append("if (window.opener != null && window.opener.onOneDriveCallback != null)");+ res.append(";");+ res.append("if (window.opener != null && window.opener.onOneDriveCallback != null)");res.append("{");res.append(" window.opener.onOneDriveCallback(authInfo, window);");res.append("} else {");