From 5e3bfecd8bdb7e6d14fdfa4531c4589d56eab288 Mon Sep 17 00:00:00 2001 From: Enis Necipoglu Date: Mon, 20 Jun 2022 17:08:21 +0300 Subject: [PATCH 1/5] Update OpenIddictDataSeedContributor.cs --- .../OpenIddict/OpenIddictDataSeedContributor.cs | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) 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..9505c467c0 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) @@ -201,6 +202,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 +226,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)); From 36fae04f9fdf011d3eb4198c56ca3183f36c3143 Mon Sep 17 00:00:00 2001 From: Enis Necipoglu Date: Tue, 21 Jun 2022 10:50:07 +0300 Subject: [PATCH 2/5] Update OpenIddictDataSeedContributor.cs --- .../OpenIddict/OpenIddictDataSeedContributor.cs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) 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 9505c467c0..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 @@ -99,6 +99,7 @@ public class OpenIddictDataSeedContributor : IDataSeedContributor, ITransientDep }, scopes: commonScopes, redirectUri: $"{webClientRootUrl}signin-oidc", + clientUri: webClientRootUrl, postLogoutRedirectUri: $"{webClientRootUrl}signout-callback-oidc" ); } @@ -123,6 +124,7 @@ public class OpenIddictDataSeedContributor : IDataSeedContributor, ITransientDep }, scopes: commonScopes, redirectUri: consoleAndAngularClientRootUrl, + clientUri: consoleAndAngularClientRootUrl, postLogoutRedirectUri: consoleAndAngularClientRootUrl ); } @@ -145,6 +147,7 @@ public class OpenIddictDataSeedContributor : IDataSeedContributor, ITransientDep }, scopes: commonScopes, redirectUri: $"{blazorRootUrl}/authentication/login-callback", + clientUri: blazorRootUrl, postLogoutRedirectUri: $"{blazorRootUrl}/authentication/logout-callback" ); } @@ -168,6 +171,7 @@ public class OpenIddictDataSeedContributor : IDataSeedContributor, ITransientDep }, scopes: commonScopes, redirectUri: $"{blazorServerTieredRootUrl}signin-oidc", + clientUri: blazorServerTieredRootUrl, postLogoutRedirectUri: $"{blazorServerTieredRootUrl}signout-callback-oidc" ); } @@ -189,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 ); } } From d2f39facac4ca8ce3664c5fb2a7395d230a7d458 Mon Sep 17 00:00:00 2001 From: Enis Necipoglu Date: Tue, 21 Jun 2022 10:50:28 +0300 Subject: [PATCH 3/5] Update design for openIdDict AuthServer --- .../Pages/Index.cshtml | 135 ++++++++++++++---- .../Pages/Index.cshtml.cs | 29 +++- 2 files changed, 138 insertions(+), 26 deletions(-) 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..2bd2ff4677 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..f873648b3a 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,37 @@ +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() + { + var cts = new CancellationTokenSource(30); + Applications = await OpenIdApplicationRepository.GetListAsync(); + + Languages = await LanguageProvider.GetLanguagesAsync(); + CurrentLanguage = CultureInfo.CurrentCulture.DisplayName; } } From e96e7331b86dd6a6e4c6a32167da31a61e433f59 Mon Sep 17 00:00:00 2001 From: Enis Necipoglu Date: Tue, 21 Jun 2022 10:54:42 +0300 Subject: [PATCH 4/5] Update Index.cshtml --- .../Pages/Index.cshtml | 50 +++++++++---------- 1 file changed, 25 insertions(+), 25 deletions(-) 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 2bd2ff4677..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 @@ -40,29 +40,29 @@ -
-
- -
-
- @if (CurrentUser.IsAuthenticated) - { - - @L["Welcome"] @CurrentUser.UserName - - @CurrentUser.Email - - } - else - { - @L["Login"] - } -
+
+
+ +
+
+ @if (CurrentUser.IsAuthenticated) + { + + @L["Welcome"] @CurrentUser.UserName + + @CurrentUser.Email + + } + else + { + @L["Login"] + } +
-
+
@@ -77,7 +77,7 @@
- +

@@ -91,8 +91,8 @@ @if (!application.LogoUri.IsNullOrEmpty()) { -
- +
+
} From 9a19e6e3924548f0804b912de9615c5789ccc7b4 Mon Sep 17 00:00:00 2001 From: Enis Necipoglu Date: Tue, 21 Jun 2022 11:38:00 +0300 Subject: [PATCH 5/5] Remove unnecessary CancellationTokenSource from Index.cshtml.cs --- .../MyCompanyName.MyProjectName.AuthServer/Pages/Index.cshtml.cs | 1 - 1 file changed, 1 deletion(-) 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 f873648b3a..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 @@ -28,7 +28,6 @@ public class IndexModel : AbpPageModel public async Task OnGetAsync() { - var cts = new CancellationTokenSource(30); Applications = await OpenIdApplicationRepository.GetListAsync(); Languages = await LanguageProvider.GetLanguagesAsync();