Skip to content

Commit

Permalink
Make the AuthServer working.
Browse files Browse the repository at this point in the history
  • Loading branch information
hikalkan committed Jan 17, 2019
1 parent dd08c26 commit a3f0c11
Show file tree
Hide file tree
Showing 6 changed files with 70 additions and 10 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -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" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,29 @@
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),
Expand All @@ -33,13 +42,14 @@ public override void ConfigureServices(ServiceConfigurationContext context)
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"));
});
}

Expand All @@ -48,10 +58,21 @@ public override void OnApplicationInitialization(ApplicationInitializationContex
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()
);
});
}
}
}
Original file line number Diff line number Diff line change
@@ -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>
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
using Microsoft.AspNetCore.Mvc.RazorPages;

namespace AuthServer.Host.Pages
{
public class IndexModel : PageModel
{
public void OnGet()
{
}
}
}
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit a3f0c11

Please sign in to comment.