diff --git a/.gitignore b/.gitignore
index cd63ac2e6c..b6366f8011 100644
--- a/.gitignore
+++ b/.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
diff --git a/samples/MicroserviceDemo/applications/authserver/AuthServer.Host/AuthServer.Host.csproj b/samples/MicroserviceDemo/applications/authserver/AuthServer.Host/AuthServer.Host.csproj
index 62ef0be5f1..66a589c016 100644
--- a/samples/MicroserviceDemo/applications/authserver/AuthServer.Host/AuthServer.Host.csproj
+++ b/samples/MicroserviceDemo/applications/authserver/AuthServer.Host/AuthServer.Host.csproj
@@ -21,7 +21,7 @@
-
+
diff --git a/samples/MicroserviceDemo/applications/authserver/AuthServer.Host/AuthServerHostModule.cs b/samples/MicroserviceDemo/applications/authserver/AuthServer.Host/AuthServerHostModule.cs
index 7bff2ebd8a..1f153337c8 100644
--- a/samples/MicroserviceDemo/applications/authserver/AuthServer.Host/AuthServerHostModule.cs
+++ b/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(options =>
+ Configure(options =>
{
- //Configures defaults for all EF Core DbContexts in this application
- options.Configure(opts =>
- {
- opts.UseSqlServer();
- });
+ options.UseSqlServer();
+ });
+
+ Configure(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()
+ .SeedAsync(
+ "1q2w3E*",
+ IdentityPermissions.GetAll()
+ );
+ });
}
}
}
diff --git a/samples/MicroserviceDemo/applications/authserver/AuthServer.Host/Pages/Index.cshtml b/samples/MicroserviceDemo/applications/authserver/AuthServer.Host/Pages/Index.cshtml
new file mode 100644
index 0000000000..53bcfed077
--- /dev/null
+++ b/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
+Running the AuthServer.Host application!
+Current User
+
+ - IsAuthenticated: @CurrentUser.IsAuthenticated
+ - UserName: @CurrentUser.UserName
+ - Email: @CurrentUser.Email
+ - Roles: @CurrentUser.Roles.JoinAsString(", ")
+ @*- Claims: @CurrentUser.GetAllClaims().Select(c => $"{c.Type}={c.Value}").JoinAsString(" | ")
*@
+ - TenantId: @CurrentUser.TenantId
+
+
+@if (CurrentUser.IsAuthenticated)
+{
+ Logout
+}
+else
+{
+ Login
+}
\ No newline at end of file
diff --git a/samples/MicroserviceDemo/applications/authserver/AuthServer.Host/Pages/Index.cshtml.cs b/samples/MicroserviceDemo/applications/authserver/AuthServer.Host/Pages/Index.cshtml.cs
new file mode 100644
index 0000000000..0894e658dc
--- /dev/null
+++ b/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()
+ {
+ }
+ }
+}
\ No newline at end of file
diff --git a/samples/MicroserviceDemo/applications/authserver/AuthServer.Host/Pages/_ViewImports.cshtml b/samples/MicroserviceDemo/applications/authserver/AuthServer.Host/Pages/_ViewImports.cshtml
new file mode 100644
index 0000000000..c1da1f5f10
--- /dev/null
+++ b/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
\ No newline at end of file