Browse Source

Make the AuthServer working.

pull/798/head
Halil ibrahim Kalkan 7 years ago
parent
commit
a3f0c11897
  1. 1
      .gitignore
  2. 2
      samples/MicroserviceDemo/applications/authserver/AuthServer.Host/AuthServer.Host.csproj
  3. 39
      samples/MicroserviceDemo/applications/authserver/AuthServer.Host/AuthServerHostModule.cs
  4. 23
      samples/MicroserviceDemo/applications/authserver/AuthServer.Host/Pages/Index.cshtml
  5. 11
      samples/MicroserviceDemo/applications/authserver/AuthServer.Host/Pages/Index.cshtml.cs
  6. 4
      samples/MicroserviceDemo/applications/authserver/AuthServer.Host/Pages/_ViewImports.cshtml

1
.gitignore

@ -285,3 +285,4 @@ framework/test/Volo\.Abp\.AspNetCore\.Mvc\.UI\.Bootstrap\.Demo/package-lock\.jso
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

2
samples/MicroserviceDemo/applications/authserver/AuthServer.Host/AuthServer.Host.csproj

@ -21,7 +21,7 @@
<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="..\..\..\..\..\framework\src\Volo.Abp.AspNetCore.Mvc.UI.Theme.Basic\Volo.Abp.AspNetCore.Mvc.UI.Theme.Basic.csproj" />
<ProjectReference Include="..\..\..\..\..\modules\identity\src\Volo.Abp.Identity.AspNetCore\Volo.Abp.Identity.AspNetCore.csproj" />
<ProjectReference Include="..\..\..\..\..\modules\identity\src\Volo.Abp.Identity.Application.Contracts\Volo.Abp.Identity.Application.Contracts.csproj" />
<ProjectReference Include="..\..\..\..\..\modules\identity\src\Volo.Abp.Identity.EntityFrameworkCore\Volo.Abp.Identity.EntityFrameworkCore.csproj" />
<ProjectReference Include="..\..\..\..\..\modules\identityserver\src\Volo.Abp.IdentityServer.EntityFrameworkCore\Volo.Abp.IdentityServer.EntityFrameworkCore.csproj" />
<ProjectReference Include="..\..\..\..\..\modules\account\src\Volo.Abp.Account.Web\Volo.Abp.Account.Web.csproj" />

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

@ -5,20 +5,29 @@ using Volo.Abp;
using Volo.Abp.Account.Web;
using Volo.Abp.AspNetCore.Modularity;
using Volo.Abp.AspNetCore.Mvc.UI.Theme.Basic;
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.AspNetCore;
using Volo.Abp.Identity.EntityFrameworkCore;
using Volo.Abp.IdentityServer.EntityFrameworkCore;
using Volo.Abp.Localization;
using Volo.Abp.Modularity;
using Volo.Abp.PermissionManagement.EntityFrameworkCore;
using Volo.Abp.SettingManagement.EntityFrameworkCore;
using Volo.Abp.Threading;
namespace AuthServer.Host
{
[DependsOn(
typeof(AbpAutofacModule),
typeof(AbpIdentityAspNetCoreModule),
typeof(AbpPermissionManagementEntityFrameworkCoreModule),
typeof(AbpAuditLoggingEntityFrameworkCoreModule),
typeof(AbpSettingManagementEntityFrameworkCoreModule),
typeof(AbpIdentityEntityFrameworkCoreModule),
typeof(AbpIdentityApplicationContractsModule),
typeof(AbpIdentityServerEntityFrameworkCoreModule),
typeof(AbpEntityFrameworkCoreSqlServerModule),
typeof(AbpAccountWebModule),
@ -33,13 +42,14 @@ namespace AuthServer.Host
options.AddDefaultRepositories();
});
context.Services.Configure<AbpDbContextOptions>(options =>
Configure<AbpDbContextOptions>(options =>
{
//Configures defaults for all EF Core DbContexts in this application
options.Configure(opts =>
{
opts.UseSqlServer();
});
options.UseSqlServer();
});
Configure<AbpLocalizationOptions>(options =>
{
options.Languages.Add(new LanguageInfo("en", "en", "English"));
});
}
@ -48,10 +58,21 @@ namespace AuthServer.Host
var app = context.GetApplicationBuilder();
app.UseVirtualFiles();
//app.UseIdentityServer(); //TODO: Enable
app.UseIdentityServer(); //TODO: Enable this and disable UseAuthentication
app.UseAbpRequestLocalization();
app.UseAuditing();
app.UseMvcWithDefaultRoute();
app.UseMvcWithDefaultRouteAndArea();
//TODO: Problem on a clustered environment
AsyncHelper.RunSync(async () =>
{
await context.ServiceProvider
.GetRequiredService<IIdentityDataSeeder>()
.SeedAsync(
"1q2w3E*",
IdentityPermissions.GetAll()
);
});
}
}
}

23
samples/MicroserviceDemo/applications/authserver/AuthServer.Host/Pages/Index.cshtml

@ -0,0 +1,23 @@
@page
@using Volo.Abp.Users
@model AuthServer.Host.Pages.IndexModel
@inject ICurrentUser CurrentUser
<h1>Running the <strong>AuthServer.Host</strong> application!</h1>
<h2>Current User</h2>
<ul>
<li>IsAuthenticated: @CurrentUser.IsAuthenticated</li>
<li>UserName: @CurrentUser.UserName</li>
<li>Email: @CurrentUser.Email</li>
<li>Roles: @CurrentUser.Roles.JoinAsString(", ")</li>
@*<li>Claims: @CurrentUser.GetAllClaims().Select(c => $"{c.Type}={c.Value}").JoinAsString(" | ")</li>*@
<li>TenantId: @CurrentUser.TenantId</li>
</ul>
@if (CurrentUser.IsAuthenticated)
{
<a abp-button="Primary" asp-controller="Logout" asp-action="Index" asp-area="Account">Logout</a>
}
else
{
<a abp-button="Primary" asp-page="/Account/Login">Login</a>
}

11
samples/MicroserviceDemo/applications/authserver/AuthServer.Host/Pages/Index.cshtml.cs

@ -0,0 +1,11 @@
using Microsoft.AspNetCore.Mvc.RazorPages;
namespace AuthServer.Host.Pages
{
public class IndexModel : PageModel
{
public void OnGet()
{
}
}
}

4
samples/MicroserviceDemo/applications/authserver/AuthServer.Host/Pages/_ViewImports.cshtml

@ -0,0 +1,4 @@
@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers
@addTagHelper *, Volo.Abp.AspNetCore.Mvc.UI
@addTagHelper *, Volo.Abp.AspNetCore.Mvc.UI.Bootstrap
@addTagHelper *, Volo.Abp.AspNetCore.Mvc.UI.Bundling
Loading…
Cancel
Save