Merge pull request #4905 from krzysztof-cislo/dev

Takes a long time to explain. OK, we'll merge as-is. We don't use this code, so it has no impact on us, anyway.
This commit is contained in:
David Benson 2025-03-03 10:48:01 +00:00 committed by GitHub
commit bc64f18f74
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 23 additions and 18 deletions

View File

@ -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);
CONFIG.REDIRECT_PATH = "/microsoft";
CONFIG.AUTH_SERVICE_URL = "https://login.microsoftonline.com/common/oauth2/v2.0/token";
}
return CONFIG;
}
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());
public MSGraphAuth()
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";
}
return CONFIG;
}
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 json
if (!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 {");