diff --git a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.AuthServer/Pages/Index.cshtml b/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.AuthServer/Pages/Index.cshtml index db9f1f100a..48b2d8de02 100644 --- a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.AuthServer/Pages/Index.cshtml +++ b/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.AuthServer/Pages/Index.cshtml @@ -1,34 +1,119 @@ @page +@using Microsoft.AspNetCore.Http.Extensions +@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 language in Model.Languages) + { + @language.DisplayName + } + + +
+
+ + +
+ + + + @foreach (var application in Model.Applications) + { + + + + + @if (!application.LogoUri.IsNullOrEmpty()) + { +
+ +
+ } + +

@application.DisplayName

+ @application.ClientUri + +
+
+
+ } + +
+
+ + + + +
+ +
-} +
\ No newline at end of file diff --git a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.AuthServer/Pages/Index.cshtml.cs b/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.AuthServer/Pages/Index.cshtml.cs index e8230ee00c..8e31fb91f1 100644 --- a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.AuthServer/Pages/Index.cshtml.cs +++ b/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.AuthServer/Pages/Index.cshtml.cs @@ -1,10 +1,36 @@ +using System.Collections.Generic; +using System.Globalization; +using System.Threading; +using System.Threading.Tasks; using Volo.Abp.AspNetCore.Mvc.UI.RazorPages; +using Volo.Abp.Localization; +using Volo.Abp.OpenIddict.Applications; namespace MyCompanyName.MyProjectName.Pages; public class IndexModel : AbpPageModel { - public void OnGet() + public List Applications { get; protected set; } + + public IReadOnlyList Languages { get; protected set; } + + public string CurrentLanguage { get; protected set; } + + protected IOpenIddictApplicationRepository OpenIdApplicationRepository { get; } + + protected ILanguageProvider LanguageProvider { get; } + + public IndexModel(IOpenIddictApplicationRepository openIdApplicationmRepository, ILanguageProvider languageProvider) { + OpenIdApplicationRepository = openIdApplicationmRepository; + LanguageProvider = languageProvider; + } + + public async Task OnGetAsync() + { + Applications = await OpenIdApplicationRepository.GetListAsync(); + + Languages = await LanguageProvider.GetLanguagesAsync(); + CurrentLanguage = CultureInfo.CurrentCulture.DisplayName; } } diff --git a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Domain/OpenIddict/OpenIddictDataSeedContributor.cs b/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Domain/OpenIddict/OpenIddictDataSeedContributor.cs index add52f7437..9026bfaeaa 100644 --- a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Domain/OpenIddict/OpenIddictDataSeedContributor.cs +++ b/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Domain/OpenIddict/OpenIddictDataSeedContributor.cs @@ -10,6 +10,7 @@ using Volo.Abp; using Volo.Abp.Authorization.Permissions; using Volo.Abp.Data; using Volo.Abp.DependencyInjection; +using Volo.Abp.OpenIddict.Applications; using Volo.Abp.PermissionManagement; using Volo.Abp.Uow; @@ -21,14 +22,14 @@ namespace MyCompanyName.MyProjectName.OpenIddict; public class OpenIddictDataSeedContributor : IDataSeedContributor, ITransientDependency { private readonly IConfiguration _configuration; - private readonly IOpenIddictApplicationManager _applicationManager; + private readonly IAbpApplicationManager _applicationManager; private readonly IOpenIddictScopeManager _scopeManager; private readonly IPermissionDataSeeder _permissionDataSeeder; private readonly IStringLocalizer L; public OpenIddictDataSeedContributor( IConfiguration configuration, - IOpenIddictApplicationManager applicationManager, + IAbpApplicationManager applicationManager, IOpenIddictScopeManager scopeManager, IPermissionDataSeeder permissionDataSeeder, IStringLocalizer l) @@ -98,6 +99,7 @@ public class OpenIddictDataSeedContributor : IDataSeedContributor, ITransientDep }, scopes: commonScopes, redirectUri: $"{webClientRootUrl}signin-oidc", + clientUri: webClientRootUrl, postLogoutRedirectUri: $"{webClientRootUrl}signout-callback-oidc" ); } @@ -122,6 +124,7 @@ public class OpenIddictDataSeedContributor : IDataSeedContributor, ITransientDep }, scopes: commonScopes, redirectUri: consoleAndAngularClientRootUrl, + clientUri: consoleAndAngularClientRootUrl, postLogoutRedirectUri: consoleAndAngularClientRootUrl ); } @@ -144,6 +147,7 @@ public class OpenIddictDataSeedContributor : IDataSeedContributor, ITransientDep }, scopes: commonScopes, redirectUri: $"{blazorRootUrl}/authentication/login-callback", + clientUri: blazorRootUrl, postLogoutRedirectUri: $"{blazorRootUrl}/authentication/logout-callback" ); } @@ -167,6 +171,7 @@ public class OpenIddictDataSeedContributor : IDataSeedContributor, ITransientDep }, scopes: commonScopes, redirectUri: $"{blazorServerTieredRootUrl}signin-oidc", + clientUri: blazorServerTieredRootUrl, postLogoutRedirectUri: $"{blazorServerTieredRootUrl}signout-callback-oidc" ); } @@ -188,7 +193,8 @@ public class OpenIddictDataSeedContributor : IDataSeedContributor, ITransientDep OpenIddictConstants.GrantTypes.AuthorizationCode, }, scopes: commonScopes, - redirectUri: $"{swaggerRootUrl}/swagger/oauth2-redirect.html" + redirectUri: $"{swaggerRootUrl}/swagger/oauth2-redirect.html", + clientUri: swaggerRootUrl ); } } @@ -201,6 +207,7 @@ public class OpenIddictDataSeedContributor : IDataSeedContributor, ITransientDep string secret, List grantTypes, List scopes, + string clientUri = null, string redirectUri = null, string postLogoutRedirectUri = null, List permissions = null) @@ -224,13 +231,14 @@ public class OpenIddictDataSeedContributor : IDataSeedContributor, ITransientDep var client = await _applicationManager.FindByClientIdAsync(name); if (client == null) { - var application = new OpenIddictApplicationDescriptor + var application = new AbpApplicationDescriptor { ClientId = name, Type = type, ClientSecret = secret, ConsentType = consentType, - DisplayName = displayName + DisplayName = displayName, + ClientUri = clientUri, }; Check.NotNullOrEmpty(grantTypes, nameof(grantTypes));