Browse Source

IdentityService configured to properly work.

pull/798/head
Halil ibrahim Kalkan 7 years ago
parent
commit
476c472e7e
  1. 1
      .gitignore
  2. 1
      samples/MicroserviceDemo/applications/authserver/AuthServer.Host/AuthServerHostModule.cs
  3. 4
      samples/MicroserviceDemo/applications/authserver/AuthServer.Host/Program.cs
  4. 1
      samples/MicroserviceDemo/applications/authserver/AuthServer.Host/Startup.cs
  5. 7
      samples/MicroserviceDemo/microservices/identity/IdentityService.Host/IdentityService.Host.csproj
  6. 65
      samples/MicroserviceDemo/microservices/identity/IdentityService.Host/IdentityServiceHostModule.cs
  7. 1
      samples/MicroserviceDemo/microservices/identity/IdentityService.Host/Startup.cs

1
.gitignore

@ -286,3 +286,4 @@ modules/blogging/app/Volo\.BloggingTestApp/package-lock\.json
templates/mvc/src/MyCompanyName\.MyProjectName\.Web/package-lock\.json
samples/MicroserviceDemo/applications/authserver/AuthServer.Host/Logs/logs.txt
samples/MicroserviceDemo/microservices/identity/IdentityService.Host/Logs/logs.txt

1
samples/MicroserviceDemo/applications/authserver/AuthServer.Host/AuthServerHostModule.cs

@ -10,7 +10,6 @@ using Volo.Abp.Autofac;
using Volo.Abp.EntityFrameworkCore;
using Volo.Abp.EntityFrameworkCore.SqlServer;
using Volo.Abp.Identity;
using Volo.Abp.Identity.AspNetCore;
using Volo.Abp.Identity.EntityFrameworkCore;
using Volo.Abp.IdentityServer.EntityFrameworkCore;
using Volo.Abp.Localization;

4
samples/MicroserviceDemo/applications/authserver/AuthServer.Host/Program.cs

@ -19,13 +19,13 @@ namespace AuthServer.Host
try
{
Log.Information("Starting MyCompanyName.MyProjectName.HttpApi.Host.");
Log.Information("Starting AuthServer.Host.");
BuildWebHostInternal(args).Run();
return 0;
}
catch (Exception ex)
{
Log.Fatal(ex, "Host terminated unexpectedly!");
Log.Fatal(ex, "AuthServer.Host terminated unexpectedly!");
return 1;
}
finally

1
samples/MicroserviceDemo/applications/authserver/AuthServer.Host/Startup.cs

@ -22,6 +22,7 @@ namespace AuthServer.Host
public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
{
//TODO: Need to this?
loggerFactory
.AddConsole()
.AddDebug()

7
samples/MicroserviceDemo/microservices/identity/IdentityService.Host/IdentityService.Host.csproj

@ -2,12 +2,13 @@
<PropertyGroup>
<TargetFramework>netcoreapp2.2</TargetFramework>
<AspNetCoreHostingModel>InProcess</AspNetCoreHostingModel>
<AssetTargetFallback>$(AssetTargetFallback);portable-net45+win8+wp8+wpa81;</AssetTargetFallback>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<GenerateBindingRedirectsOutputType>true</GenerateBindingRedirectsOutputType>
<GenerateRuntimeConfigurationFiles>true</GenerateRuntimeConfigurationFiles>
<PreserveCompilationContext>true</PreserveCompilationContext>
<MvcRazorExcludeRefAssembliesFromPublish>false</MvcRazorExcludeRefAssembliesFromPublish>
<MvcRazorCompileOnPublish>true</MvcRazorCompileOnPublish>
</PropertyGroup>
<ItemGroup>
@ -20,9 +21,13 @@
<ItemGroup>
<ProjectReference Include="..\..\..\..\..\framework\src\Volo.Abp.Autofac\Volo.Abp.Autofac.csproj" />
<ProjectReference Include="..\..\..\..\..\framework\src\Volo.Abp.EntityFrameworkCore.SqlServer\Volo.Abp.EntityFrameworkCore.SqlServer.csproj" />
<ProjectReference Include="..\..\..\..\..\modules\identity\src\Volo.Abp.Identity.HttpApi\Volo.Abp.Identity.HttpApi.csproj" />
<ProjectReference Include="..\..\..\..\..\modules\identity\src\Volo.Abp.Identity.EntityFrameworkCore\Volo.Abp.Identity.EntityFrameworkCore.csproj" />
<ProjectReference Include="..\..\..\..\..\modules\identity\src\Volo.Abp.Identity.Application\Volo.Abp.Identity.Application.csproj" />
<ProjectReference Include="..\..\..\..\..\modules\audit-logging\src\Volo.Abp.AuditLogging.EntityFrameworkCore\Volo.Abp.AuditLogging.EntityFrameworkCore.csproj" />
<ProjectReference Include="..\..\..\..\..\modules\permission-management\src\Volo.Abp.PermissionManagement.EntityFrameworkCore\Volo.Abp.PermissionManagement.EntityFrameworkCore.csproj" />
<ProjectReference Include="..\..\..\..\..\modules\setting-management\src\Volo.Abp.SettingManagement.EntityFrameworkCore\Volo.Abp.SettingManagement.EntityFrameworkCore.csproj" />
</ItemGroup>
<ItemGroup>

65
samples/MicroserviceDemo/microservices/identity/IdentityService.Host/IdentityServiceHostModule.cs

@ -1,17 +1,28 @@
using Microsoft.AspNetCore.Builder;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Swashbuckle.AspNetCore.Swagger;
using Volo.Abp;
using Volo.Abp.AspNetCore.Modularity;
using Volo.Abp.AuditLogging.EntityFrameworkCore;
using Volo.Abp.Autofac;
using Volo.Abp.EntityFrameworkCore;
using Volo.Abp.EntityFrameworkCore.SqlServer;
using Volo.Abp.Identity;
using Volo.Abp.Identity.EntityFrameworkCore;
using Volo.Abp.Localization;
using Volo.Abp.Modularity;
using Volo.Abp.PermissionManagement.EntityFrameworkCore;
using Volo.Abp.SettingManagement.EntityFrameworkCore;
namespace IdentityService.Host
{
[DependsOn(
typeof(AbpAutofacModule),
typeof(AbpEntityFrameworkCoreSqlServerModule),
typeof(AbpAuditLoggingEntityFrameworkCoreModule),
typeof(AbpPermissionManagementEntityFrameworkCoreModule),
typeof(AbpSettingManagementEntityFrameworkCoreModule),
typeof(AbpIdentityHttpApiModule),
typeof(AbpIdentityEntityFrameworkCoreModule),
typeof(AbpIdentityApplicationModule)
@ -20,9 +31,32 @@ namespace IdentityService.Host
{
public override void ConfigureServices(ServiceConfigurationContext context)
{
ConfigureAuthentication(context);
ConfigureSwagger(context);
//TODO: Configure localization?
var configuration = context.Services.GetConfiguration();
var x = configuration.GetConnectionString("Default");
context.Services.AddAuthentication("Bearer")
.AddIdentityServerAuthentication(options =>
{
options.Authority = "http://localhost:64999"; //TODO: Update
options.RequireHttpsMetadata = false;
options.ApiName = "IdentityService";
});
context.Services.AddSwaggerGen(options =>
{
options.SwaggerDoc("v1", new Info {Title = "Identity Service API", Version = "v1"});
options.DocInclusionPredicate((docName, description) => true);
});
Configure<AbpLocalizationOptions>(options =>
{
options.Languages.Add(new LanguageInfo("en", "en", "English"));
});
Configure<AbpDbContextOptions>(options =>
{
options.UseSqlServer();
});
}
public override void OnApplicationInitialization(ApplicationInitializationContext context)
@ -31,35 +65,14 @@ namespace IdentityService.Host
app.UseVirtualFiles();
app.UseAuthentication();
//app.UseAbpRequestLocalization(); //TODO: localization?
app.UseAbpRequestLocalization(); //TODO: localization?
app.UseSwagger();
app.UseSwaggerUI(options =>
{
options.SwaggerEndpoint("/swagger/v1/swagger.json", "Identity Service API");
});
app.UseAuditing();
app.UseMvcWithDefaultRoute();
}
private void ConfigureAuthentication(ServiceConfigurationContext context)
{
context.Services.AddAuthentication("Bearer")
.AddIdentityServerAuthentication(options =>
{
options.Authority = "http://localhost:9999"; //TODO: Update
options.RequireHttpsMetadata = false;
options.ApiName = "IdentityService";
});
}
private static void ConfigureSwagger(ServiceConfigurationContext context)
{
context.Services.AddSwaggerGen(
options =>
{
options.SwaggerDoc("v1", new Info { Title = "Identity Service API", Version = "v1" });
options.DocInclusionPredicate((docName, description) => true);
});
app.UseMvcWithDefaultRouteAndArea();
}
}
}

1
samples/MicroserviceDemo/microservices/identity/IdentityService.Host/Startup.cs

@ -15,6 +15,7 @@ namespace IdentityService.Host
services.AddApplication<IdentityServiceHostModule>(options =>
{
options.UseAutofac();
options.Configuration.UserSecretsAssembly = typeof(Startup).Assembly;
});
return services.BuildServiceProviderFromFactory();

Loading…
Cancel
Save