Browse Source

Merge pull request #18875 from abpframework/swaggerpatch

Fix AddAbpSwaggerGenWithOidc tenant replacement issue
pull/18885/head
Galip Tolga Erdem 2 years ago
committed by GitHub
parent
commit
7456c037cb
No known key found for this signature in database GPG Key ID: B5690EEEBB952194
  1. 16
      framework/src/Volo.Abp.Swashbuckle/wwwroot/swagger/ui/abp.swagger.js

16
framework/src/Volo.Abp.Swashbuckle/wwwroot/swagger/ui/abp.swagger.js

@ -14,8 +14,6 @@ var abp = abp || {};
var requestInterceptor = configObject.requestInterceptor;
var responseInterceptor = configObject.responseInterceptor;
getAbpApplicationConfiguration();
configObject.requestInterceptor = async function (request) {
@ -29,17 +27,19 @@ 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 = replaceTenantPlaceHolder(oidcDiscoveryEndpoint);
request.url = await replaceTenantPlaceHolder(oidcDiscoveryEndpoint);
console.log(request.url);
return;
}
if (!oidcDiscoveryEndpoint.endsWith("/")) {
oidcDiscoveryEndpoint += "/"
}
request.url = replaceTenantPlaceHolder(oidcDiscoveryEndpoint) + ".well-known/openid-configuration";
request.url = await replaceTenantPlaceHolder(oidcDiscoveryEndpoint) + ".well-known/openid-configuration";
console.log(request.url);
}
@ -84,7 +84,11 @@ var abp = abp || {};
return response;
};
function replaceTenantPlaceHolder(url) {
async function replaceTenantPlaceHolder(url) {
if(!abp.currentTenant){
await getAbpApplicationConfiguration();
}
url.replace(tenantPlaceHolders[0], abp.currentTenant.id);
url.replace(tenantPlaceHolders[1], abp.currentTenant.name);
@ -99,7 +103,7 @@ var abp = abp || {};
}
function getAbpApplicationConfiguration() {
fetch(`${abp.appPath}api/abp/application-configuration`).then(response => response.json()).then(data => {
return fetch(`${abp.appPath}api/abp/application-configuration`).then(response => response.json()).then(data => {
abp.currentTenant = data.currentTenant;
});
}

Loading…
Cancel
Save