|
|
@ -82,16 +82,21 @@ public static class AbpSwaggerGenServiceCollectionExtensions |
|
|
public static IServiceCollection AddAbpSwaggerGenWithOidc( |
|
|
public static IServiceCollection AddAbpSwaggerGenWithOidc( |
|
|
this IServiceCollection services, |
|
|
this IServiceCollection services, |
|
|
[NotNull] string authority, |
|
|
[NotNull] string authority, |
|
|
Action<SwaggerGenOptions> setupAction = null, |
|
|
string[] scopes = null, |
|
|
List<string> flows = null, |
|
|
string[] flows = null, |
|
|
string openIdConnectDiscoveryEndpoint = "/.well-known/openid-configuration") |
|
|
string discoveryEndpoint = null, |
|
|
|
|
|
Action<SwaggerGenOptions> setupAction = null) |
|
|
{ |
|
|
{ |
|
|
var openIdConnectDiscoveryUrl = new Uri($"{authority.TrimEnd('/')}{openIdConnectDiscoveryEndpoint.EnsureStartsWith('/')}"); |
|
|
var discoveryUrl = discoveryEndpoint != null ? |
|
|
flows ??= new List<string> { "authorization_code"}; |
|
|
new Uri(discoveryEndpoint) : |
|
|
|
|
|
new Uri($"{authority.TrimEnd('/')}/.well-known/openid-configuration"); |
|
|
|
|
|
|
|
|
|
|
|
flows ??= new [] { "authorization_code" }; |
|
|
|
|
|
|
|
|
services.Configure<SwaggerUIOptions>(swaggerUiOptions => |
|
|
services.Configure<SwaggerUIOptions>(swaggerUiOptions => |
|
|
{ |
|
|
{ |
|
|
swaggerUiOptions.ConfigObject.AdditionalItems["oidcSupportedFlows"] = flows; |
|
|
swaggerUiOptions.ConfigObject.AdditionalItems["oidcSupportedFlows"] = flows; |
|
|
|
|
|
swaggerUiOptions.ConfigObject.AdditionalItems["oidcSupportedScopes"] = scopes; |
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
|
return services |
|
|
return services |
|
|
@ -102,8 +107,7 @@ public static class AbpSwaggerGenServiceCollectionExtensions |
|
|
options.AddSecurityDefinition("oidc", new OpenApiSecurityScheme |
|
|
options.AddSecurityDefinition("oidc", new OpenApiSecurityScheme |
|
|
{ |
|
|
{ |
|
|
Type = SecuritySchemeType.OpenIdConnect, |
|
|
Type = SecuritySchemeType.OpenIdConnect, |
|
|
OpenIdConnectUrl = openIdConnectDiscoveryUrl, |
|
|
OpenIdConnectUrl = discoveryUrl |
|
|
|
|
|
|
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
|
options.AddSecurityRequirement(new OpenApiSecurityRequirement |
|
|
options.AddSecurityRequirement(new OpenApiSecurityRequirement |
|
|
|