|
|
|
@ -9,12 +9,12 @@ var abp = abp || {}; |
|
|
|
var oidcSupportedFlows = configObject.oidcSupportedFlows || []; |
|
|
|
var oidcSupportedScopes = configObject.oidcSupportedScopes || []; |
|
|
|
var oidcDiscoveryEndpoint = configObject.oidcDiscoveryEndpoint || []; |
|
|
|
var tenantPlaceHolders = ["{{tenantId}}", "{{tenantName}}" , "{0}"] |
|
|
|
var tenantPlaceHolders = ["{{tenantId}}", "{{tenantName}}", "{0}"] |
|
|
|
abp.appPath = configObject.baseUrl || abp.appPath; |
|
|
|
|
|
|
|
var requestInterceptor = configObject.requestInterceptor; |
|
|
|
var responseInterceptor = configObject.responseInterceptor; |
|
|
|
|
|
|
|
|
|
|
|
configObject.requestInterceptor = async function (request) { |
|
|
|
|
|
|
|
if (request.url.includes(excludeUrl[1])) { |
|
|
|
@ -27,22 +27,6 @@ var abp = abp || {}; |
|
|
|
}); |
|
|
|
firstRequest = false; |
|
|
|
} |
|
|
|
|
|
|
|
// Intercept .well-known request when the discoveryEndpoint is provided
|
|
|
|
if (!firstRequest && oidcDiscoveryEndpoint.length !== 0 && request.url.includes(".well-known/openid-configuration")) { |
|
|
|
|
|
|
|
if (oidcDiscoveryEndpoint.endsWith(".well-known/openid-configuration")) { |
|
|
|
request.url = await replaceTenantPlaceHolder(oidcDiscoveryEndpoint); |
|
|
|
console.log(request.url); |
|
|
|
return; |
|
|
|
} |
|
|
|
if (!oidcDiscoveryEndpoint.endsWith("/")) { |
|
|
|
oidcDiscoveryEndpoint += "/" |
|
|
|
} |
|
|
|
request.url = await replaceTenantPlaceHolder(oidcDiscoveryEndpoint) + ".well-known/openid-configuration"; |
|
|
|
|
|
|
|
console.log(request.url); |
|
|
|
} |
|
|
|
|
|
|
|
var antiForgeryToken = abp.security.antiForgery.getToken(); |
|
|
|
if (antiForgeryToken) { |
|
|
|
@ -78,33 +62,50 @@ var abp = abp || {}; |
|
|
|
response.text = JSON.stringify(openIdConnectData); |
|
|
|
} |
|
|
|
|
|
|
|
// Intercept .well-known request when the discoveryEndpoint is provided
|
|
|
|
if (response.url.endsWith("swagger.json") && response.status === 200 && oidcDiscoveryEndpoint.length !== 0) { |
|
|
|
var swaggerData = JSON.parse(response.text); |
|
|
|
|
|
|
|
if (swaggerData.components.securitySchemes && swaggerData.components.securitySchemes.oidc) { |
|
|
|
swaggerData.components.securitySchemes.oidc.openIdConnectUrl = await replaceTenantPlaceHolder(oidcDiscoveryEndpoint); |
|
|
|
} |
|
|
|
|
|
|
|
response.text = JSON.stringify(swaggerData); |
|
|
|
} |
|
|
|
|
|
|
|
if (responseInterceptor) { |
|
|
|
responseInterceptor(response); |
|
|
|
} |
|
|
|
return response; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
async function replaceTenantPlaceHolder(url) { |
|
|
|
|
|
|
|
if(!abp.currentTenant){ |
|
|
|
|
|
|
|
if (!abp.currentTenant) { |
|
|
|
await getAbpApplicationConfiguration(); |
|
|
|
} |
|
|
|
|
|
|
|
url.replace(tenantPlaceHolders[0], abp.currentTenant.id); |
|
|
|
url.replace(tenantPlaceHolders[1], abp.currentTenant.name); |
|
|
|
|
|
|
|
if(abp.currentTenant.name != null){ |
|
|
|
url.replace(tenantPlaceHolders[2], abp.currentTenant.name); |
|
|
|
}else if (abp.currentTenant.id != null){ |
|
|
|
url.replace(tenantPlaceHolders[2], abp.currentTenant.id); |
|
|
|
|
|
|
|
if (abp.currentTenant.id == null && abp.currentTenant.name == null) { |
|
|
|
return url |
|
|
|
.replace(tenantPlaceHolders[0] + ".", "") |
|
|
|
.replace(tenantPlaceHolders[1] + ".", "") |
|
|
|
.replace(tenantPlaceHolders[2] + ".", ""); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
url = url.replace(tenantPlaceHolders[0], abp.currentTenant.id).replace(tenantPlaceHolders[1], abp.currentTenant.name); |
|
|
|
|
|
|
|
if (abp.currentTenant.name != null) { |
|
|
|
url = url.replace(tenantPlaceHolders[2], abp.currentTenant.name); |
|
|
|
} else if (abp.currentTenant.id != null) { |
|
|
|
url = url.replace(tenantPlaceHolders[2], abp.currentTenant.id); |
|
|
|
} |
|
|
|
|
|
|
|
return url; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
function getAbpApplicationConfiguration() { |
|
|
|
return fetch(`${abp.appPath}api/abp/application-configuration`).then(response => response.json()).then(data => { |
|
|
|
abp.currentTenant = data.currentTenant; |
|
|
|
abp.currentTenant = data.currentTenant; |
|
|
|
}); |
|
|
|
} |
|
|
|
|
|
|
|
|