Skip to content

Commit

Permalink
IdentityService configured to properly work.
Browse files Browse the repository at this point in the history
  • Loading branch information
hikalkan committed Jan 17, 2019
1 parent 7c81844 commit 476c472
Show file tree
Hide file tree
Showing 7 changed files with 50 additions and 30 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@ public static int Main(string[] args)

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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ public IServiceProvider ConfigureServices(IServiceCollection services)

public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
{
//TODO: Need to this?
loggerFactory
.AddConsole()
.AddDebug()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand All @@ -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>
Expand Down
Original file line number Diff line number Diff line change
@@ -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)
Expand All @@ -20,9 +31,32 @@ public class IdentityServiceHostModule : AbpModule
{
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)
Expand All @@ -31,35 +65,14 @@ public override void OnApplicationInitialization(ApplicationInitializationContex

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();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ public IServiceProvider ConfigureServices(IServiceCollection services)
services.AddApplication<IdentityServiceHostModule>(options =>
{
options.UseAutofac();
options.Configuration.UserSecretsAssembly = typeof(Startup).Assembly;
});

return services.BuildServiceProviderFromFactory();
Expand Down

0 comments on commit 476c472

Please sign in to comment.