diff --git a/framework/src/Volo.Abp.Swashbuckle/Microsoft/Extensions/DependencyInjection/AbpSwaggerGenServiceCollectionExtensions.cs b/framework/src/Volo.Abp.Swashbuckle/Microsoft/Extensions/DependencyInjection/AbpSwaggerGenServiceCollectionExtensions.cs index b012300c6f..b9fc9fb7bb 100644 --- a/framework/src/Volo.Abp.Swashbuckle/Microsoft/Extensions/DependencyInjection/AbpSwaggerGenServiceCollectionExtensions.cs +++ b/framework/src/Volo.Abp.Swashbuckle/Microsoft/Extensions/DependencyInjection/AbpSwaggerGenServiceCollectionExtensions.cs @@ -82,16 +82,21 @@ public static class AbpSwaggerGenServiceCollectionExtensions public static IServiceCollection AddAbpSwaggerGenWithOidc( this IServiceCollection services, [NotNull] string authority, - Action setupAction = null, - List flows = null, - string openIdConnectDiscoveryEndpoint = "/.well-known/openid-configuration") + string[] scopes = null, + string[] flows = null, + string discoveryEndpoint = null, + Action setupAction = null) { - var openIdConnectDiscoveryUrl = new Uri($"{authority.TrimEnd('/')}{openIdConnectDiscoveryEndpoint.EnsureStartsWith('/')}"); - flows ??= new List { "authorization_code"}; + var discoveryUrl = discoveryEndpoint != null ? + new Uri(discoveryEndpoint) : + new Uri($"{authority.TrimEnd('/')}/.well-known/openid-configuration"); + + flows ??= new [] { "authorization_code" }; services.Configure(swaggerUiOptions => { swaggerUiOptions.ConfigObject.AdditionalItems["oidcSupportedFlows"] = flows; + swaggerUiOptions.ConfigObject.AdditionalItems["oidcSupportedScopes"] = scopes; }); return services @@ -102,8 +107,7 @@ public static class AbpSwaggerGenServiceCollectionExtensions options.AddSecurityDefinition("oidc", new OpenApiSecurityScheme { Type = SecuritySchemeType.OpenIdConnect, - OpenIdConnectUrl = openIdConnectDiscoveryUrl, - + OpenIdConnectUrl = discoveryUrl }); options.AddSecurityRequirement(new OpenApiSecurityRequirement diff --git a/framework/src/Volo.Abp.Swashbuckle/wwwroot/swagger/ui/abp.swagger.js b/framework/src/Volo.Abp.Swashbuckle/wwwroot/swagger/ui/abp.swagger.js index fa0e27dd0c..8c1ef922d6 100644 --- a/framework/src/Volo.Abp.Swashbuckle/wwwroot/swagger/ui/abp.swagger.js +++ b/framework/src/Volo.Abp.Swashbuckle/wwwroot/swagger/ui/abp.swagger.js @@ -7,6 +7,7 @@ var abp = abp || {}; var excludeUrl = ["swagger.json", "connect/token"] var firstRequest = true; var oidcSupportedFlows = configObject.oidcSupportedFlows || []; + var oidcSupportedScopes = configObject.oidcSupportedScopes || []; abp.appPath = configObject.baseUrl || abp.appPath; var requestInterceptor = configObject.requestInterceptor; @@ -41,9 +42,17 @@ var abp = abp || {}; }; configObject.responseInterceptor = async function(response) { - if(response.url.endsWith(".well-known/openid-configuration") && response.status === 200 && oidcSupportedFlows.length > 0) { + if(response.url.endsWith(".well-known/openid-configuration") && response.status === 200) { var openIdConnectData = JSON.parse(response.text); - openIdConnectData.grant_types_supported = oidcSupportedFlows; + + if(oidcSupportedFlows.length > 0){ + openIdConnectData.grant_types_supported = oidcSupportedFlows; + } + + if(oidcSupportedScopes.length > 0) { + openIdConnectData.scopes_supported = oidcSupportedScopes; + } + response.text = JSON.stringify(openIdConnectData); }