Browse Source

Added swagger auth to identity service

pull/6/head
Galip Tolga Erdem 5 years ago
parent
commit
a3a736a365
  1. 1
      services/identity/src/EShopOnAbp.IdentityService.HttpApi.Host/EShopOnAbp.IdentityService.HttpApi.Host.csproj
  2. 40
      services/identity/src/EShopOnAbp.IdentityService.HttpApi.Host/IdentityServiceHttpApiHostModule.cs

1
services/identity/src/EShopOnAbp.IdentityService.HttpApi.Host/EShopOnAbp.IdentityService.HttpApi.Host.csproj

@ -13,6 +13,7 @@
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\..\..\shared\EShopOnAbp.Shared.Hosting.Gateways\EShopOnAbp.Shared.Hosting.Gateways.csproj" />
<ProjectReference Include="..\..\..\..\shared\EShopOnAbp.Shared.Hosting.Microservices\EShopOnAbp.Shared.Hosting.Microservices.csproj" />
<ProjectReference Include="..\EShopOnAbp.IdentityService.Application\EShopOnAbp.IdentityService.Application.csproj" />
<ProjectReference Include="..\EShopOnAbp.IdentityService.EntityFrameworkCore\EShopOnAbp.IdentityService.EntityFrameworkCore.csproj" />

40
services/identity/src/EShopOnAbp.IdentityService.HttpApi.Host/IdentityServiceHttpApiHostModule.cs

@ -1,7 +1,13 @@
using System;
using System.Collections.Generic;
using System.Linq;
using EShopOnAbp.IdentityService.DbMigrations;
using EShopOnAbp.IdentityService.EntityFrameworkCore;
using EShopOnAbp.Shared.Hosting.AspNetCore;
using EShopOnAbp.Shared.Hosting.Gateways;
using EShopOnAbp.Shared.Hosting.Microservices;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Cors;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using Volo.Abp;
@ -15,7 +21,8 @@ namespace EShopOnAbp.IdentityService
typeof(EShopOnAbpSharedHostingMicroservicesModule),
typeof(IdentityServiceHttpApiModule),
typeof(IdentityServiceApplicationModule),
typeof(IdentityServiceEntityFrameworkCoreModule)
typeof(IdentityServiceEntityFrameworkCoreModule),
typeof(EShopOnAbpSharedHostingGatewaysModule)
)]
public class IdentityServiceHttpApiHostModule : AbpModule
{
@ -25,7 +32,35 @@ namespace EShopOnAbp.IdentityService
var hostingEnvironment = context.Services.GetHostingEnvironment();
JwtBearerConfigurationHelper.Configure(context, "IdentityService");
SwaggerConfigurationHelper.Configure(context, "Identity Service API");
// SwaggerConfigurationHelper.Configure(context, "Identity Service API");
context.Services.AddCors(options =>
{
options.AddDefaultPolicy(builder =>
{
builder
.WithOrigins(
configuration["App:CorsOrigins"]
.Split(",", StringSplitOptions.RemoveEmptyEntries)
.Select(o => o.Trim().RemovePostFix("/"))
.ToArray()
)
.WithAbpExposedHeaders()
.SetIsOriginAllowedToAllowWildcardSubdomains()
.AllowAnyHeader()
.AllowAnyMethod()
.AllowCredentials();
});
});
SwaggerWithAuthConfigurationHelper.Configure(
context: context,
authority: configuration["AuthServer:Authority"],
scopes: new Dictionary<string, string> /* Requested scopes for authorization code request and descriptions for swagger UI only */
{
{"IdentityService", "Identity Service API"}
},
apiTitle: "IdentityService Gateway API"
);
}
public override void OnApplicationInitialization(ApplicationInitializationContext context)
@ -39,6 +74,7 @@ namespace EShopOnAbp.IdentityService
}
app.UseCorrelationId();
app.UseCors();
app.UseAbpRequestLocalization();
app.UseStaticFiles();
app.UseRouting();

Loading…
Cancel
Save