diff --git a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Domain/IdentityServer/IdentityServerDataSeedContributor.cs b/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Domain/IdentityServer/IdentityServerDataSeedContributor.cs index da0b56a6d0..466f36658e 100644 --- a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Domain/IdentityServer/IdentityServerDataSeedContributor.cs +++ b/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Domain/IdentityServer/IdentityServerDataSeedContributor.cs @@ -152,6 +152,7 @@ public class IdentityServerDataSeedContributor : IDataSeedContributor, ITransien await CreateClientAsync( name: webClientId, + clientUri: webClientRootUrl, scopes: commonScopes, grantTypes: new[] { "hybrid" }, secret: (configurationSection["MyProjectName_Web:ClientSecret"] ?? "1q2w3e*").Sha256(), @@ -172,6 +173,7 @@ public class IdentityServerDataSeedContributor : IDataSeedContributor, ITransien await CreateClientAsync( name: consoleAndAngularClientId, + clientUri: webClientRootUrl, scopes: commonScopes, grantTypes: new[] { "password", "client_credentials", "authorization_code" }, secret: (configurationSection["MyProjectName_App:ClientSecret"] ?? "1q2w3e*").Sha256(), @@ -192,6 +194,7 @@ public class IdentityServerDataSeedContributor : IDataSeedContributor, ITransien await CreateClientAsync( name: blazorClientId, + clientUri: blazorRootUrl, scopes: commonScopes, grantTypes: new[] { "authorization_code" }, secret: configurationSection["MyProjectName_Blazor:ClientSecret"]?.Sha256(), @@ -217,6 +220,7 @@ public class IdentityServerDataSeedContributor : IDataSeedContributor, ITransien await CreateClientAsync( name: blazorServerTieredClientId, + clientUri: blazorServerTieredClientRootUrl, scopes: commonScopes, grantTypes: new[] { "hybrid" }, secret: (configurationSection["MyProjectName_BlazorServerTiered:ClientSecret"] ?? "1q2w3e*").Sha256(), @@ -237,6 +241,7 @@ public class IdentityServerDataSeedContributor : IDataSeedContributor, ITransien await CreateClientAsync( name: swaggerClientId, + clientUri: swaggerRootUrl, scopes: commonScopes, grantTypes: new[] { "authorization_code" }, secret: configurationSection["MyProjectName_Swagger:ClientSecret"]?.Sha256(), @@ -251,6 +256,7 @@ public class IdentityServerDataSeedContributor : IDataSeedContributor, ITransien string name, IEnumerable scopes, IEnumerable grantTypes, + string clientUri = null, string secret = null, string redirectUri = null, string postLogoutRedirectUri = null, @@ -270,6 +276,7 @@ public class IdentityServerDataSeedContributor : IDataSeedContributor, ITransien ) { ClientName = name, + ClientUri = clientUri, ProtocolType = "oidc", Description = name, AlwaysIncludeUserClaimsInIdToken = true, @@ -287,6 +294,11 @@ public class IdentityServerDataSeedContributor : IDataSeedContributor, ITransien ); } + if (client.ClientUri != clientUri) + { + client.ClientUri = clientUri; + } + foreach (var scope in scopes) { if (client.FindScope(scope) == null) diff --git a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.IdentityServer/Pages/Index.cshtml b/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.IdentityServer/Pages/Index.cshtml index db9f1f100a..c61632e453 100644 --- a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.IdentityServer/Pages/Index.cshtml +++ b/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.IdentityServer/Pages/Index.cshtml @@ -1,34 +1,103 @@ @page +@using Microsoft.AspNetCore.Mvc.Localization @using MyCompanyName.MyProjectName.Pages +@using MyCompanyName.MyProjectName.Localization @using Volo.Abp.Users +@using Volo.Abp.AspNetCore.Mvc.UI.Theming +@using Volo.Abp.Ui.Branding @model IndexModel +@inject IHtmlLocalizer L @inject ICurrentUser CurrentUser -@if (CurrentUser.IsAuthenticated) -{ -
+@inject IBrandingProvider BrandingProvider +@inject ITheme Theme + +@{ + Layout = Theme.GetEmptyLayout(); +} + +
+
- - - Logout - - -

@CurrentUser.UserName

-
@CurrentUser.Email
-
- Roles: @CurrentUser.Roles.JoinAsString(", ") -
- Claims:
- @Html.Raw(CurrentUser.GetAllClaims().Select(c => $"{c.Type}={c.Value}").JoinAsString("
")) + + -} + + + + +
+
+
+ +
+
+ @if (CurrentUser.IsAuthenticated) + { + + @L["Welcome"] @CurrentUser.UserName + + @CurrentUser.Email + + } + else + { + @L["Login"] + } +
+
-@if (!CurrentUser.IsAuthenticated) -{ -
-

- Login +
+ + + + @foreach (var client in Model.Clients.Where(x => x.RedirectUris.Count > 0)) + { + + + + + @if (!client.LogoUri.IsNullOrEmpty()) + { +
+ +
+ } + +

@client.ClientName

+ @{ + var redirectUri = new Uri(@client.RedirectUris.First().RedirectUri); + var url = @redirectUri.AbsoluteUri.RemovePostFix(redirectUri.AbsolutePath); + } + @url +
+ Visit +
+
+
+
+ } + +
+
+ + + + +
+ +
-} +
diff --git a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.IdentityServer/Pages/Index.cshtml.cs b/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.IdentityServer/Pages/Index.cshtml.cs index e8230ee00c..dee9e692d8 100644 --- a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.IdentityServer/Pages/Index.cshtml.cs +++ b/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.IdentityServer/Pages/Index.cshtml.cs @@ -1,10 +1,24 @@ using Volo.Abp.AspNetCore.Mvc.UI.RazorPages; +using IdentityServer4.Stores; +using Volo.Abp.IdentityServer.Clients; +using System.Threading.Tasks; +using System.Collections.Generic; namespace MyCompanyName.MyProjectName.Pages; public class IndexModel : AbpPageModel { - public void OnGet() + public List Clients { get; protected set; } + + protected IClientRepository ClientRepository { get; } + + public IndexModel(IClientRepository clientRepository) { + this.ClientRepository = clientRepository; } -} + + public async Task OnGetAsync() + { + Clients = await ClientRepository.GetListAsync(includeDetails: true); + } +} \ No newline at end of file