From eb6971b50194f4785bcbe3a342ca31b0bfbba960 Mon Sep 17 00:00:00 2001 From: muhammedaltug Date: Tue, 20 Dec 2022 13:01:25 +0300 Subject: [PATCH 01/12] run change detection with queue manager in permission directive add simple queue manager resolves #15167 --- .../packages/core/src/lib/core.module.ts | 6 ++ .../lib/directives/permission.directive.ts | 6 +- .../packages/core/src/lib/tokens/index.ts | 1 + .../core/src/lib/tokens/queue.token.ts | 4 ++ .../packages/core/src/lib/utils/index.ts | 1 + .../packages/core/src/lib/utils/queue.ts | 48 ++++++++++++++++ .../appsettings.json | 56 +++++++++---------- .../appsettings.json | 34 +++++------ 8 files changed, 110 insertions(+), 46 deletions(-) create mode 100644 npm/ng-packs/packages/core/src/lib/tokens/queue.token.ts create mode 100644 npm/ng-packs/packages/core/src/lib/utils/queue.ts diff --git a/npm/ng-packs/packages/core/src/lib/core.module.ts b/npm/ng-packs/packages/core/src/lib/core.module.ts index 4bf3fae3a1..298e3c5352 100644 --- a/npm/ng-packs/packages/core/src/lib/core.module.ts +++ b/npm/ng-packs/packages/core/src/lib/core.module.ts @@ -38,6 +38,8 @@ import { ShortDateTimePipe } from './pipes/short-date-time.pipe'; import { ShortTimePipe } from './pipes/short-time.pipe'; import { ShortDatePipe } from './pipes/short-date.pipe'; import { TimeoutLimitedOAuthService } from './services/timeout-limited-oauth.service'; +import { QUEUE_MANAGER } from './tokens/queue.token'; +import { DefaultQueueManager } from './utils/queue'; export function storageFactory(): OAuthStorage { return oAuthStorage; @@ -193,6 +195,10 @@ export class CoreModule { useValue: localizationContributor(options.localizations), deps: [LocalizationService], }, + { + provide: QUEUE_MANAGER, + useClass: DefaultQueueManager, + }, ], }; } diff --git a/npm/ng-packs/packages/core/src/lib/directives/permission.directive.ts b/npm/ng-packs/packages/core/src/lib/directives/permission.directive.ts index e06c6d404c..f277bf50ee 100644 --- a/npm/ng-packs/packages/core/src/lib/directives/permission.directive.ts +++ b/npm/ng-packs/packages/core/src/lib/directives/permission.directive.ts @@ -2,6 +2,7 @@ import { AfterViewInit, ChangeDetectorRef, Directive, + Inject, Input, OnChanges, OnDestroy, @@ -12,6 +13,8 @@ import { import { ReplaySubject, Subscription } from 'rxjs'; import { distinctUntilChanged, take } from 'rxjs/operators'; import { PermissionService } from '../services/permission.service'; +import { QUEUE_MANAGER } from '../tokens/queue.token'; +import { QueueManager } from '../utils/queue'; @Directive({ selector: '[abpPermission]', @@ -32,6 +35,7 @@ export class PermissionDirective implements OnDestroy, OnChanges, AfterViewInit private vcRef: ViewContainerRef, private permissionService: PermissionService, private cdRef: ChangeDetectorRef, + @Inject(QUEUE_MANAGER) public queue: QueueManager, ) {} private check() { @@ -66,7 +70,7 @@ export class PermissionDirective implements OnDestroy, OnChanges, AfterViewInit } ngAfterViewInit() { - this.cdrSubject.pipe(take(1)).subscribe(() => this.cdRef.detectChanges()); + this.cdrSubject.pipe(take(1)).subscribe(() => this.queue.add(() => this.cdRef.detectChanges())); this.rendered = true; } } diff --git a/npm/ng-packs/packages/core/src/lib/tokens/index.ts b/npm/ng-packs/packages/core/src/lib/tokens/index.ts index da1ea9bdad..98985107f3 100644 --- a/npm/ng-packs/packages/core/src/lib/tokens/index.ts +++ b/npm/ng-packs/packages/core/src/lib/tokens/index.ts @@ -5,4 +5,5 @@ export * from './localization.token'; export * from './lodaer-delay.token'; export * from './manage-profile.token'; export * from './options.token'; +export * from './queue.token'; export * from './tenant-key.token'; diff --git a/npm/ng-packs/packages/core/src/lib/tokens/queue.token.ts b/npm/ng-packs/packages/core/src/lib/tokens/queue.token.ts new file mode 100644 index 0000000000..66c0efa7d6 --- /dev/null +++ b/npm/ng-packs/packages/core/src/lib/tokens/queue.token.ts @@ -0,0 +1,4 @@ +import { QueueManager } from "../utils/queue"; +import { InjectionToken } from "@angular/core"; + +export const QUEUE_MANAGER = new InjectionToken("QUEUE_MANAGER"); diff --git a/npm/ng-packs/packages/core/src/lib/utils/index.ts b/npm/ng-packs/packages/core/src/lib/utils/index.ts index 56378f664f..1e218e0619 100644 --- a/npm/ng-packs/packages/core/src/lib/utils/index.ts +++ b/npm/ng-packs/packages/core/src/lib/utils/index.ts @@ -15,6 +15,7 @@ export * from './localization-utils'; export * from './multi-tenancy-utils'; export * from './number-utils'; export * from './object-utils'; +export * from './queue'; export * from './route-utils'; export * from './string-utils'; export * from './tree-utils'; diff --git a/npm/ng-packs/packages/core/src/lib/utils/queue.ts b/npm/ng-packs/packages/core/src/lib/utils/queue.ts new file mode 100644 index 0000000000..33525d83e1 --- /dev/null +++ b/npm/ng-packs/packages/core/src/lib/utils/queue.ts @@ -0,0 +1,48 @@ +export interface QueueManager { + add(fn: () => void): void; + init(interval: number, stackSize: number): void; +} + +export class DefaultQueueManager implements QueueManager { + private queue: Array<() => void> = []; + private isRunning = false; + private stack = 0; + private interval = 0; + private stackSize = 100; + + public init(interval: number, stackSize: number) { + this.interval = interval; + this.stackSize = stackSize; + } + + public add(fn: () => void) { + this.queue.push(fn); + this.run(); + } + + private run() { + if (this.isRunning) return; + this.stack++; + + this.isRunning = true; + + const fn = this.queue.shift(); + + if (!fn) { + this.isRunning = false; + return; + } + + fn(); + if (this.stack > this.stackSize) { + setTimeout(() => { + this.isRunning = false; + this.run(); + this.stack = 0; + }, this.interval); + } else { + this.isRunning = false; + this.run(); + } + } +} diff --git a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.DbMigrator/appsettings.json b/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.DbMigrator/appsettings.json index 3d7dc2a8be..04f12e5484 100644 --- a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.DbMigrator/appsettings.json +++ b/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.DbMigrator/appsettings.json @@ -1,31 +1,31 @@ { - "ConnectionStrings": { - "Default": "Server=(LocalDb)\\MSSQLLocalDB;Database=MyProjectName;Trusted_Connection=True" - }, - "OpenIddict": { - "Applications": { - "MyProjectName_Web": { - "ClientId": "MyProjectName_Web", - "ClientSecret": "1q2w3e*", - "RootUrl": "https://localhost:44302" - }, - "MyProjectName_Blazor": { - "ClientId": "MyProjectName_Blazor", - "RootUrl": "https://localhost:44307" - }, - "MyProjectName_App": { - "ClientId": "MyProjectName_App", - "RootUrl": "http://localhost:4200" - }, - "MyProjectName_BlazorServerTiered": { - "ClientId": "MyProjectName_BlazorServerTiered", - "ClientSecret": "1q2w3e*", - "RootUrl": "https://localhost:44309" - }, - "MyProjectName_Swagger": { - "ClientId": "MyProjectName_Swagger", - "RootUrl": "https://localhost:44305" - } + "ConnectionStrings": { + "Default": "Server=localhost;Database=MyProjectNameHOossos;User Id=sa;password=myPassw0rd;MultipleActiveResultSets=true" + }, + "OpenIddict": { + "Applications": { + "MyProjectName_Web": { + "ClientId": "MyProjectName_Web", + "ClientSecret": "1q2w3e*", + "RootUrl": "https://localhost:44302" + }, + "MyProjectName_Blazor": { + "ClientId": "MyProjectName_Blazor", + "RootUrl": "https://localhost:44307" + }, + "MyProjectName_App": { + "ClientId": "MyProjectName_App", + "RootUrl": "http://localhost:4200" + }, + "MyProjectName_BlazorServerTiered": { + "ClientId": "MyProjectName_BlazorServerTiered", + "ClientSecret": "1q2w3e*", + "RootUrl": "https://localhost:44309" + }, + "MyProjectName_Swagger": { + "ClientId": "MyProjectName_Swagger", + "RootUrl": "https://localhost:44305" + } + } } - } } diff --git a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.HttpApi.HostWithIds/appsettings.json b/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.HttpApi.HostWithIds/appsettings.json index 3fc189b8ae..12c37d0cff 100644 --- a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.HttpApi.HostWithIds/appsettings.json +++ b/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.HttpApi.HostWithIds/appsettings.json @@ -1,19 +1,19 @@ { - "App": { - "SelfUrl": "https://localhost:44305", - "ClientUrl": "http://localhost:4200", - "CorsOrigins": "https://*.MyProjectName.com,http://localhost:4200,https://localhost:44307", - "RedirectAllowedUrls": "http://localhost:4200,https://localhost:44307" - }, - "ConnectionStrings": { - "Default": "Server=(LocalDb)\\MSSQLLocalDB;Database=MyProjectName;Trusted_Connection=True" - }, - "AuthServer": { - "Authority": "https://localhost:44305", - "RequireHttpsMetadata": "false", - "SwaggerClientId": "MyProjectName_Swagger" - }, - "StringEncryption": { - "DefaultPassPhrase": "gsKnGZ041HLL4IM8" - } + "App": { + "SelfUrl": "https://localhost:44305", + "ClientUrl": "http://localhost:4200", + "CorsOrigins": "https://*.MyProjectName.com,http://localhost:4200,https://localhost:44307", + "RedirectAllowedUrls": "http://localhost:4200,https://localhost:44307" + }, + "ConnectionStrings": { + "Default": "Server=localhost;Database=MyProjectNameHOossos;User Id=sa;password=myPassw0rd;MultipleActiveResultSets=true" + }, + "AuthServer": { + "Authority": "https://localhost:44305", + "RequireHttpsMetadata": "false", + "SwaggerClientId": "MyProjectName_Swagger" + }, + "StringEncryption": { + "DefaultPassPhrase": "gsKnGZ041HLL4IM8" + } } From 512759e550a4e4c0734b529cc8802f4530ce4475 Mon Sep 17 00:00:00 2001 From: muhammedaltug Date: Mon, 26 Dec 2022 14:08:59 +0300 Subject: [PATCH 02/12] revert app setting changes --- .../src/MyCompanyName.MyProjectName.DbMigrator/appsettings.json | 2 +- .../appsettings.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.DbMigrator/appsettings.json b/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.DbMigrator/appsettings.json index 04f12e5484..bec0d89991 100644 --- a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.DbMigrator/appsettings.json +++ b/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.DbMigrator/appsettings.json @@ -1,6 +1,6 @@ { "ConnectionStrings": { - "Default": "Server=localhost;Database=MyProjectNameHOossos;User Id=sa;password=myPassw0rd;MultipleActiveResultSets=true" + "Default": "Server=(LocalDb)\\MSSQLLocalDB;Database=MyProjectName;Trusted_Connection=True" }, "OpenIddict": { "Applications": { diff --git a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.HttpApi.HostWithIds/appsettings.json b/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.HttpApi.HostWithIds/appsettings.json index 12c37d0cff..3729acf852 100644 --- a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.HttpApi.HostWithIds/appsettings.json +++ b/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.HttpApi.HostWithIds/appsettings.json @@ -6,7 +6,7 @@ "RedirectAllowedUrls": "http://localhost:4200,https://localhost:44307" }, "ConnectionStrings": { - "Default": "Server=localhost;Database=MyProjectNameHOossos;User Id=sa;password=myPassw0rd;MultipleActiveResultSets=true" + "Default": "Server=(LocalDb)\\MSSQLLocalDB;Database=MyProjectName;Trusted_Connection=True" }, "AuthServer": { "Authority": "https://localhost:44305", From 124747cd0c667c491e16422399d7357ce88f0802 Mon Sep 17 00:00:00 2001 From: muhammedaltug Date: Tue, 27 Dec 2022 09:26:15 +0300 Subject: [PATCH 03/12] revert app setting changes --- .../appsettings.json | 56 +++++++++---------- .../appsettings.json | 34 +++++------ 2 files changed, 45 insertions(+), 45 deletions(-) diff --git a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.DbMigrator/appsettings.json b/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.DbMigrator/appsettings.json index bec0d89991..3d7dc2a8be 100644 --- a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.DbMigrator/appsettings.json +++ b/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.DbMigrator/appsettings.json @@ -1,31 +1,31 @@ { - "ConnectionStrings": { - "Default": "Server=(LocalDb)\\MSSQLLocalDB;Database=MyProjectName;Trusted_Connection=True" - }, - "OpenIddict": { - "Applications": { - "MyProjectName_Web": { - "ClientId": "MyProjectName_Web", - "ClientSecret": "1q2w3e*", - "RootUrl": "https://localhost:44302" - }, - "MyProjectName_Blazor": { - "ClientId": "MyProjectName_Blazor", - "RootUrl": "https://localhost:44307" - }, - "MyProjectName_App": { - "ClientId": "MyProjectName_App", - "RootUrl": "http://localhost:4200" - }, - "MyProjectName_BlazorServerTiered": { - "ClientId": "MyProjectName_BlazorServerTiered", - "ClientSecret": "1q2w3e*", - "RootUrl": "https://localhost:44309" - }, - "MyProjectName_Swagger": { - "ClientId": "MyProjectName_Swagger", - "RootUrl": "https://localhost:44305" - } - } + "ConnectionStrings": { + "Default": "Server=(LocalDb)\\MSSQLLocalDB;Database=MyProjectName;Trusted_Connection=True" + }, + "OpenIddict": { + "Applications": { + "MyProjectName_Web": { + "ClientId": "MyProjectName_Web", + "ClientSecret": "1q2w3e*", + "RootUrl": "https://localhost:44302" + }, + "MyProjectName_Blazor": { + "ClientId": "MyProjectName_Blazor", + "RootUrl": "https://localhost:44307" + }, + "MyProjectName_App": { + "ClientId": "MyProjectName_App", + "RootUrl": "http://localhost:4200" + }, + "MyProjectName_BlazorServerTiered": { + "ClientId": "MyProjectName_BlazorServerTiered", + "ClientSecret": "1q2w3e*", + "RootUrl": "https://localhost:44309" + }, + "MyProjectName_Swagger": { + "ClientId": "MyProjectName_Swagger", + "RootUrl": "https://localhost:44305" + } } + } } diff --git a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.HttpApi.HostWithIds/appsettings.json b/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.HttpApi.HostWithIds/appsettings.json index 3729acf852..3fc189b8ae 100644 --- a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.HttpApi.HostWithIds/appsettings.json +++ b/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.HttpApi.HostWithIds/appsettings.json @@ -1,19 +1,19 @@ { - "App": { - "SelfUrl": "https://localhost:44305", - "ClientUrl": "http://localhost:4200", - "CorsOrigins": "https://*.MyProjectName.com,http://localhost:4200,https://localhost:44307", - "RedirectAllowedUrls": "http://localhost:4200,https://localhost:44307" - }, - "ConnectionStrings": { - "Default": "Server=(LocalDb)\\MSSQLLocalDB;Database=MyProjectName;Trusted_Connection=True" - }, - "AuthServer": { - "Authority": "https://localhost:44305", - "RequireHttpsMetadata": "false", - "SwaggerClientId": "MyProjectName_Swagger" - }, - "StringEncryption": { - "DefaultPassPhrase": "gsKnGZ041HLL4IM8" - } + "App": { + "SelfUrl": "https://localhost:44305", + "ClientUrl": "http://localhost:4200", + "CorsOrigins": "https://*.MyProjectName.com,http://localhost:4200,https://localhost:44307", + "RedirectAllowedUrls": "http://localhost:4200,https://localhost:44307" + }, + "ConnectionStrings": { + "Default": "Server=(LocalDb)\\MSSQLLocalDB;Database=MyProjectName;Trusted_Connection=True" + }, + "AuthServer": { + "Authority": "https://localhost:44305", + "RequireHttpsMetadata": "false", + "SwaggerClientId": "MyProjectName_Swagger" + }, + "StringEncryption": { + "DefaultPassPhrase": "gsKnGZ041HLL4IM8" + } } From b9daa60341cc24efff9b1253d4d2bdbf2b2dccd4 Mon Sep 17 00:00:00 2001 From: malik masis Date: Tue, 27 Dec 2022 18:38:04 +0300 Subject: [PATCH 04/12] Moved the searching input to left --- .../Pages/Identity/UserManagement.razor | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/modules/identity/src/Volo.Abp.Identity.Blazor/Pages/Identity/UserManagement.razor b/modules/identity/src/Volo.Abp.Identity.Blazor/Pages/Identity/UserManagement.razor index f04df90856..a35493706a 100644 --- a/modules/identity/src/Volo.Abp.Identity.Blazor/Pages/Identity/UserManagement.razor +++ b/modules/identity/src/Volo.Abp.Identity.Blazor/Pages/Identity/UserManagement.razor @@ -16,15 +16,13 @@ BreadcrumbItems="@BreadcrumbItems" Toolbar="@Toolbar" /> - - + + + - - @L["Search"] - - + @L["Search"] + - @* ************************* DATA GRID ************************* *@ -} +} \ No newline at end of file From 79b55fb29838f85330dbabb4095b77421946e232 Mon Sep 17 00:00:00 2001 From: malik masis Date: Mon, 2 Jan 2023 11:23:24 +0300 Subject: [PATCH 05/12] Update UserManagement.razor --- .../Pages/Identity/UserManagement.razor | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/identity/src/Volo.Abp.Identity.Blazor/Pages/Identity/UserManagement.razor b/modules/identity/src/Volo.Abp.Identity.Blazor/Pages/Identity/UserManagement.razor index a35493706a..242436c643 100644 --- a/modules/identity/src/Volo.Abp.Identity.Blazor/Pages/Identity/UserManagement.razor +++ b/modules/identity/src/Volo.Abp.Identity.Blazor/Pages/Identity/UserManagement.razor @@ -20,7 +20,7 @@ - @L["Search"] +
@L["Search"]
@* ************************* DATA GRID ************************* *@ From de1484d3f93400dae3bc77fa846b5ac4f5e03215 Mon Sep 17 00:00:00 2001 From: malik masis Date: Tue, 3 Jan 2023 15:07:27 +0300 Subject: [PATCH 06/12] Made the search input responsive --- .../Pages/Identity/UserManagement.razor | 80 ++++++++++--------- 1 file changed, 42 insertions(+), 38 deletions(-) diff --git a/modules/identity/src/Volo.Abp.Identity.Blazor/Pages/Identity/UserManagement.razor b/modules/identity/src/Volo.Abp.Identity.Blazor/Pages/Identity/UserManagement.razor index 242436c643..c29bb25911 100644 --- a/modules/identity/src/Volo.Abp.Identity.Blazor/Pages/Identity/UserManagement.razor +++ b/modules/identity/src/Volo.Abp.Identity.Blazor/Pages/Identity/UserManagement.razor @@ -16,13 +16,17 @@ BreadcrumbItems="@BreadcrumbItems" Toolbar="@Toolbar" /> - - - - -
@L["Search"]
- -
+ + + + + + +
+ +
+
+ @* ************************* DATA GRID ************************* *@ @* ************************* CREATE MODAL ************************* *@ -@if ( HasCreatePermission ) +@if (HasCreatePermission) {
@L["NewUser"] - + @@ -60,7 +64,7 @@ @L["DisplayName:UserName"] - + @@ -70,7 +74,7 @@ @L["DisplayName:Name"] - + @@ -80,7 +84,7 @@ @L["DisplayName:Surname"] - + @@ -94,10 +98,10 @@ - + - + @@ -105,7 +109,7 @@ @L["DisplayName:Email"] - + @@ -115,7 +119,7 @@ @L["DisplayName:PhoneNumber"] - + @@ -126,15 +130,15 @@ @L["DisplayName:LockoutEnabled"] - + - @if ( NewUserRoles != null ) + @if (NewUserRoles != null) { - @foreach ( var role in NewUserRoles ) + @foreach (var role in NewUserRoles) { - + @role.Name } @@ -146,7 +150,7 @@ - +
@@ -154,18 +158,18 @@ } @* ************************* EDIT MODAL ************************* *@ -@if ( HasUpdatePermission ) +@if (HasUpdatePermission) {
@L["Edit"] - + - + @@ -179,7 +183,7 @@ @L["DisplayName:UserName"] - + @@ -189,7 +193,7 @@ @L["DisplayName:Name"] - + @@ -199,7 +203,7 @@ @L["DisplayName:Surname"] - + @@ -213,10 +217,10 @@ - + - + @@ -224,7 +228,7 @@ @L["DisplayName:Email"] - + @@ -234,7 +238,7 @@ @L["DisplayName:PhoneNumber"] - + @@ -245,15 +249,15 @@ @L["DisplayName:LockoutEnabled"] - + - @if ( EditUserRoles != null ) + @if (EditUserRoles != null) { - @foreach ( var role in EditUserRoles ) + @foreach (var role in EditUserRoles) { - + @role.Name } @@ -265,14 +269,14 @@ - +
} -@if ( HasManagePermissionsPermission ) +@if (HasManagePermissionsPermission) { - + } \ No newline at end of file From 3fa52a81419507fcddd141dc773eec79279e7615 Mon Sep 17 00:00:00 2001 From: maliming Date: Wed, 11 Jan 2023 20:18:05 +0800 Subject: [PATCH 07/12] Change `v6.0.0-rc1` to `v6.0.0`. --- docs/en/Migration-Guides/OpenIddict-Angular.md | 2 +- docs/en/Migration-Guides/OpenIddict-Blazor-Server.md | 2 +- docs/en/Migration-Guides/OpenIddict-Blazor.md | 2 +- docs/en/Migration-Guides/OpenIddict-Mvc.md | 2 +- docs/en/Migration-Guides/OpenIddict-Step-by-Step.md | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/docs/en/Migration-Guides/OpenIddict-Angular.md b/docs/en/Migration-Guides/OpenIddict-Angular.md index c3ca6a7fbb..fe0b3986ac 100644 --- a/docs/en/Migration-Guides/OpenIddict-Angular.md +++ b/docs/en/Migration-Guides/OpenIddict-Angular.md @@ -112,7 +112,7 @@ ## IdentityServer -This project is renamed to **AuthServer** after v6.0.0-rc1. You can also refactor and rename your project to *AuthServer* for easier updates in the future. +This project is renamed to **AuthServer** after v6.0.0. You can also refactor and rename your project to *AuthServer* for easier updates in the future. - In **MyApplication.IdentityServer.csproj** replace **project references**: diff --git a/docs/en/Migration-Guides/OpenIddict-Blazor-Server.md b/docs/en/Migration-Guides/OpenIddict-Blazor-Server.md index 65011f6124..93c9562a4d 100644 --- a/docs/en/Migration-Guides/OpenIddict-Blazor-Server.md +++ b/docs/en/Migration-Guides/OpenIddict-Blazor-Server.md @@ -103,7 +103,7 @@ ## IdentityServer -This project is renamed to **AuthServer** after v6.0.0-rc1. You can also refactor and rename your project to *AuthServer* for easier updates in the future. +This project is renamed to **AuthServer** after v6.0.0. You can also refactor and rename your project to *AuthServer* for easier updates in the future. - In **MyApplication.IdentityServer.csproj** replace **project references**: diff --git a/docs/en/Migration-Guides/OpenIddict-Blazor.md b/docs/en/Migration-Guides/OpenIddict-Blazor.md index 7db082808e..09e137a0a6 100644 --- a/docs/en/Migration-Guides/OpenIddict-Blazor.md +++ b/docs/en/Migration-Guides/OpenIddict-Blazor.md @@ -131,7 +131,7 @@ ## IdentityServer -This project is renamed to **AuthServer** after v6.0.0-rc1. You can also refactor and rename your project to *AuthServer* for easier updates in the future. +This project is renamed to **AuthServer** after v6.0.0. You can also refactor and rename your project to *AuthServer* for easier updates in the future. - In **MyApplication.IdentityServer.csproj** replace **project references**: diff --git a/docs/en/Migration-Guides/OpenIddict-Mvc.md b/docs/en/Migration-Guides/OpenIddict-Mvc.md index 7fd411155d..8dd5ec6c94 100644 --- a/docs/en/Migration-Guides/OpenIddict-Mvc.md +++ b/docs/en/Migration-Guides/OpenIddict-Mvc.md @@ -111,7 +111,7 @@ Replace role scope to **roles** and add **UsePkce** and **SignoutScheme** option ## IdentityServer -This project is renamed to **AuthServer** after v6.0.0-rc1. You can also refactor and rename your project to *AuthServer* for easier updates in the future. +This project is renamed to **AuthServer** after v6.0.0. You can also refactor and rename your project to *AuthServer* for easier updates in the future. - In **MyApplication.IdentityServer.csproj** replace **project references**: diff --git a/docs/en/Migration-Guides/OpenIddict-Step-by-Step.md b/docs/en/Migration-Guides/OpenIddict-Step-by-Step.md index ba6b264758..32b54b0fbb 100644 --- a/docs/en/Migration-Guides/OpenIddict-Step-by-Step.md +++ b/docs/en/Migration-Guides/OpenIddict-Step-by-Step.md @@ -1,6 +1,6 @@ # Migrating from IdentityServer to OpenIddict Step by Step Guide -This guide provides layer-by-layer guidance for migrating your existing application to [OpenIddict](https://github.com/openiddict/openiddict-core) from IdentityServer. ABP startup templates use `OpenIddict` OpenId provider from v6.0.0-rc1 by default and `IdentityServer` projects are renamed to `AuthServer` in tiered/separated solutions. Since OpenIddict is only available with ABP v6.0, you will need to update your existing application in order to apply OpenIddict changes. +This guide provides layer-by-layer guidance for migrating your existing application to [OpenIddict](https://github.com/openiddict/openiddict-core) from IdentityServer. ABP startup templates use `OpenIddict` OpenId provider from v6.0.0 by default and `IdentityServer` projects are renamed to `AuthServer` in tiered/separated solutions. Since OpenIddict is only available with ABP v6.0, you will need to update your existing application in order to apply OpenIddict changes. ## History We are not removing Identity Server packages and we will continue to release new versions of IdentityServer-related NuGet/NPM packages. That means you won't have an issue while upgrading to v6.0 when the stable version releases. We will continue to fix bugs in our packages for a while. ABP 7.0 will be based on .NET 7. If Identity Server continues to work with .NET 7, we will also continue to ship NuGet packages for our IDS integration. From 1b9a2878c67f30795d874e74adf5440c4a0eeec6 Mon Sep 17 00:00:00 2001 From: maliming Date: Fri, 13 Jan 2023 10:55:39 +0800 Subject: [PATCH 08/12] Update `GetPruneListAsync` of `IOpenIddictAuthorizationRepository` --- .../EfCoreOpenIddictAuthorizationRepository.cs | 17 +++++++++-------- .../MongoOpenIddictAuthorizationRepository.cs | 18 +++++++++--------- 2 files changed, 18 insertions(+), 17 deletions(-) diff --git a/modules/openiddict/src/Volo.Abp.OpenIddict.EntityFrameworkCore/Volo/Abp/OpenIddict/Authorizations/EfCoreOpenIddictAuthorizationRepository.cs b/modules/openiddict/src/Volo.Abp.OpenIddict.EntityFrameworkCore/Volo/Abp/OpenIddict/Authorizations/EfCoreOpenIddictAuthorizationRepository.cs index e9b4c4b3fb..fcd1aabed5 100644 --- a/modules/openiddict/src/Volo.Abp.OpenIddict.EntityFrameworkCore/Volo/Abp/OpenIddict/Authorizations/EfCoreOpenIddictAuthorizationRepository.cs +++ b/modules/openiddict/src/Volo.Abp.OpenIddict.EntityFrameworkCore/Volo/Abp/OpenIddict/Authorizations/EfCoreOpenIddictAuthorizationRepository.cs @@ -8,6 +8,7 @@ using OpenIddict.Abstractions; using Volo.Abp.Domain.Repositories.EntityFrameworkCore; using Volo.Abp.EntityFrameworkCore; using Volo.Abp.OpenIddict.EntityFrameworkCore; +using Volo.Abp.OpenIddict.Tokens; namespace Volo.Abp.OpenIddict.Authorizations; @@ -81,13 +82,13 @@ public class EfCoreOpenIddictAuthorizationRepository : EfCoreRepository> GetPruneListAsync(DateTime date, int count, CancellationToken cancellationToken = default) { - var tokenQueryable = (await GetDbContextAsync()).Tokens.AsQueryable(); - return await (await GetDbSetAsync()) - .Where(x => x.CreationDate < date) - .Where(x => x.Status != OpenIddictConstants.Statuses.Valid || - (x.Type == OpenIddictConstants.AuthorizationTypes.AdHoc && tokenQueryable.Any(t => t.AuthorizationId == x.Id))) - .OrderBy(x => x.Id) - .Take(count) - .ToListAsync(GetCancellationToken(cancellationToken)); + return await (from authorization in (await GetQueryableAsync()) + join token in (await GetDbContextAsync()).Set() + on authorization.Id equals token.AuthorizationId into authorizationTokens + from authorizationToken in authorizationTokens.DefaultIfEmpty() + where authorization.CreationDate < date + where authorization.Status != OpenIddictConstants.Statuses.Valid || + (authorization.Type == OpenIddictConstants.AuthorizationTypes.AdHoc && authorizationToken == null) + select authorization).ToListAsync(cancellationToken: cancellationToken); } } diff --git a/modules/openiddict/src/Volo.Abp.OpenIddict.MongoDB/Volo/Abp/OpenIddict/Authorizations/MongoOpenIddictAuthorizationRepository.cs b/modules/openiddict/src/Volo.Abp.OpenIddict.MongoDB/Volo/Abp/OpenIddict/Authorizations/MongoOpenIddictAuthorizationRepository.cs index fe0042e54c..2f96602f67 100644 --- a/modules/openiddict/src/Volo.Abp.OpenIddict.MongoDB/Volo/Abp/OpenIddict/Authorizations/MongoOpenIddictAuthorizationRepository.cs +++ b/modules/openiddict/src/Volo.Abp.OpenIddict.MongoDB/Volo/Abp/OpenIddict/Authorizations/MongoOpenIddictAuthorizationRepository.cs @@ -67,16 +67,16 @@ public class MongoOpenIddictAuthorizationRepository : MongoDbRepository> GetPruneListAsync(DateTime date, int count, CancellationToken cancellationToken = default) { - var tokenQueryable = await GetMongoQueryableAsync(GetCancellationToken(cancellationToken)); - - var authorizations = await (await GetMongoQueryableAsync(GetCancellationToken(cancellationToken))) + var tokens = await (await GetMongoQueryableAsync(cancellationToken)) + .Where(x => x.AuthorizationId != null) + .Select(x => x.AuthorizationId.Value) + .ToListAsync(GetCancellationToken(cancellationToken)); + + + return await (await GetMongoQueryableAsync(cancellationToken)) .Where(x => x.CreationDate < date) .Where(x => x.Status != OpenIddictConstants.Statuses.Valid || - (x.Type == OpenIddictConstants.AuthorizationTypes.AdHoc)) - .OrderBy(x => x.Id) - .Take(count) - .ToListAsync(GetCancellationToken(cancellationToken)); - - return authorizations.Where(x => tokenQueryable.Any(t => t.AuthorizationId == x.Id)).ToList(); + (x.Type == OpenIddictConstants.AuthorizationTypes.AdHoc && !tokens.Contains(x.Id))) + .ToListAsync(cancellationToken: cancellationToken); } } From 6253049066925388e40b15e69f95c7013fa41ec6 Mon Sep 17 00:00:00 2001 From: maliming Date: Fri, 13 Jan 2023 13:49:43 +0800 Subject: [PATCH 09/12] Add `orderby` and `take`. --- .../Authorizations/EfCoreOpenIddictAuthorizationRepository.cs | 2 +- .../Authorizations/MongoOpenIddictAuthorizationRepository.cs | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/modules/openiddict/src/Volo.Abp.OpenIddict.EntityFrameworkCore/Volo/Abp/OpenIddict/Authorizations/EfCoreOpenIddictAuthorizationRepository.cs b/modules/openiddict/src/Volo.Abp.OpenIddict.EntityFrameworkCore/Volo/Abp/OpenIddict/Authorizations/EfCoreOpenIddictAuthorizationRepository.cs index fcd1aabed5..9cd5397bb4 100644 --- a/modules/openiddict/src/Volo.Abp.OpenIddict.EntityFrameworkCore/Volo/Abp/OpenIddict/Authorizations/EfCoreOpenIddictAuthorizationRepository.cs +++ b/modules/openiddict/src/Volo.Abp.OpenIddict.EntityFrameworkCore/Volo/Abp/OpenIddict/Authorizations/EfCoreOpenIddictAuthorizationRepository.cs @@ -89,6 +89,6 @@ public class EfCoreOpenIddictAuthorizationRepository : EfCoreRepository x.Id).Take(count).ToListAsync(cancellationToken: cancellationToken); } } diff --git a/modules/openiddict/src/Volo.Abp.OpenIddict.MongoDB/Volo/Abp/OpenIddict/Authorizations/MongoOpenIddictAuthorizationRepository.cs b/modules/openiddict/src/Volo.Abp.OpenIddict.MongoDB/Volo/Abp/OpenIddict/Authorizations/MongoOpenIddictAuthorizationRepository.cs index 2f96602f67..5103d009c1 100644 --- a/modules/openiddict/src/Volo.Abp.OpenIddict.MongoDB/Volo/Abp/OpenIddict/Authorizations/MongoOpenIddictAuthorizationRepository.cs +++ b/modules/openiddict/src/Volo.Abp.OpenIddict.MongoDB/Volo/Abp/OpenIddict/Authorizations/MongoOpenIddictAuthorizationRepository.cs @@ -77,6 +77,8 @@ public class MongoOpenIddictAuthorizationRepository : MongoDbRepository x.CreationDate < date) .Where(x => x.Status != OpenIddictConstants.Statuses.Valid || (x.Type == OpenIddictConstants.AuthorizationTypes.AdHoc && !tokens.Contains(x.Id))) + .OrderBy(x => x.Id) + .Take(count) .ToListAsync(cancellationToken: cancellationToken); } } From 6917219db1e78acdd19c2d12bea09e34c030320a Mon Sep 17 00:00:00 2001 From: Mahmut Gundogdu Date: Fri, 13 Jan 2023 10:11:05 +0300 Subject: [PATCH 10/12] Remove duplicated storage factory --- npm/ng-packs/packages/core/src/lib/core.module.ts | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/npm/ng-packs/packages/core/src/lib/core.module.ts b/npm/ng-packs/packages/core/src/lib/core.module.ts index 9e07b098b3..e3cd895022 100644 --- a/npm/ng-packs/packages/core/src/lib/core.module.ts +++ b/npm/ng-packs/packages/core/src/lib/core.module.ts @@ -33,15 +33,9 @@ import { getInitialData, localeInitializer } from './utils/initial-utils'; import { ShortDateTimePipe } from './pipes/short-date-time.pipe'; import { ShortTimePipe } from './pipes/short-time.pipe'; import { ShortDatePipe } from './pipes/short-date.pipe'; -import { TimeoutLimitedOAuthService } from './services/timeout-limited-oauth.service'; import { QUEUE_MANAGER } from './tokens/queue.token'; import { DefaultQueueManager } from './utils/queue'; import { IncludeLocalizationResourcesProvider } from './providers/include-localization-resources.provider'; -import { AuthGuard } from './abstracts/auth.guard'; - -export function storageFactory(): OAuthStorage { - return oAuthStorage; -} /** * BaseCoreModule is the module that holds @@ -182,7 +176,7 @@ export class CoreModule { provide: QUEUE_MANAGER, useClass: DefaultQueueManager, }, - IncludeLocalizationResourcesProvider + IncludeLocalizationResourcesProvider, ], }; } From 9abfb49e4e01d2b82f26f8e68d98d2d671b3ca89 Mon Sep 17 00:00:00 2001 From: Mahmut Gundogdu Date: Mon, 16 Jan 2023 09:31:21 +0300 Subject: [PATCH 11/12] remove depreceted test --- .../core/src/lib/tests/initial-utils.spec.ts | 11 ++++++- .../oauth/src/lib/tests/initial-utils.spec.ts | 29 ------------------- 2 files changed, 10 insertions(+), 30 deletions(-) diff --git a/npm/ng-packs/packages/core/src/lib/tests/initial-utils.spec.ts b/npm/ng-packs/packages/core/src/lib/tests/initial-utils.spec.ts index b28447be99..90100d4613 100644 --- a/npm/ng-packs/packages/core/src/lib/tests/initial-utils.spec.ts +++ b/npm/ng-packs/packages/core/src/lib/tests/initial-utils.spec.ts @@ -12,6 +12,7 @@ import { getInitialData, localeInitializer } from '../utils/initial-utils'; import * as environmentUtils from '../utils/environment-utils'; import * as multiTenancyUtils from '../utils/multi-tenancy-utils'; import { RestService } from '../services/rest.service'; +import { CHECK_AUTHENTICATION_STATE_FN_KEY } from '../tokens/check-authentication-state'; const environment = { oAuthConfig: { issuer: 'test' } }; @@ -41,6 +42,10 @@ describe('InitialUtils', () => { registerLocaleFn: () => Promise.resolve(), }, }, + { + provide: CHECK_AUTHENTICATION_STATE_FN_KEY, + useValue: () => {}, + }, ], }); @@ -51,6 +56,9 @@ describe('InitialUtils', () => { const environmentService = spectator.inject(EnvironmentService); const configStateService = spectator.inject(ConfigStateService); const sessionStateService = spectator.inject(SessionStateService); + //const checkAuthenticationState = spectator.inject(CHECK_AUTHENTICATION_STATE_FN_KEY); + + const authService = spectator.inject(AuthService); const parseTenantFromUrlSpy = jest.spyOn(multiTenancyUtils, 'parseTenantFromUrl'); const getRemoteEnvSpy = jest.spyOn(environmentUtils, 'getRemoteEnv'); @@ -65,7 +73,7 @@ describe('InitialUtils', () => { const configRefreshAppStateSpy = jest.spyOn(configStateService, 'refreshAppState'); configRefreshAppStateSpy.mockReturnValue(of(appConfigRes)); const sessionSetTenantSpy = jest.spyOn(sessionStateService, 'setTenant'); - + const authServiceInitSpy = jest.spyOn(authService, 'init'); const configStateGetOneSpy = jest.spyOn(configStateService, 'getOne'); configStateGetOneSpy.mockReturnValue(appConfigRes.currentTenant); @@ -79,6 +87,7 @@ describe('InitialUtils', () => { expect(configRefreshAppStateSpy).toHaveBeenCalled(); expect(environmentSetStateSpy).toHaveBeenCalledWith(environment); expect(sessionSetTenantSpy).toHaveBeenCalledWith(appConfigRes.currentTenant); + expect(authServiceInitSpy).toHaveBeenCalled(); }); }); diff --git a/npm/ng-packs/packages/oauth/src/lib/tests/initial-utils.spec.ts b/npm/ng-packs/packages/oauth/src/lib/tests/initial-utils.spec.ts index 488c14113b..cd2dfbcac5 100644 --- a/npm/ng-packs/packages/oauth/src/lib/tests/initial-utils.spec.ts +++ b/npm/ng-packs/packages/oauth/src/lib/tests/initial-utils.spec.ts @@ -9,10 +9,8 @@ import { ConfigStateService, AbpApplicationConfigurationService, SessionStateService, - ApplicationConfigurationDto, } from '@abp/ng.core'; import * as clearOAuthStorageDefault from '../utils/clear-o-auth-storage'; -import { of } from 'rxjs'; import { checkAccessToken } from '../utils/check-access-token'; const environment = { oAuthConfig: { issuer: 'test' } }; @@ -49,33 +47,6 @@ describe('InitialUtils', () => { beforeEach(() => (spectator = createComponent())); - describe('#getInitialData', () => { - let mockInjector; - let configStateService; - let authService; - beforeEach(() => { - mockInjector = { - get: spectator.inject, - }; - configStateService = spectator.inject(ConfigStateService); - authService = spectator.inject(AuthService); - }); - - test('should called configStateService.refreshAppState', async () => { - const configRefreshAppStateSpy = jest.spyOn(configStateService, 'refreshAppState'); - const appConfigRes = { - currentTenant: { id: 'test', name: 'testing' }, - } as ApplicationConfigurationDto; - - configRefreshAppStateSpy.mockReturnValue(of(appConfigRes)); - - // Todo: refactor it - // await initFactory(mockInjector)(); - - expect(configRefreshAppStateSpy).toHaveBeenCalled(); - }); - }); - describe('#checkAccessToken', () => { let injector; let injectorSpy; From a589fbe930c9db39012251e72a27a9dfa2e3924e Mon Sep 17 00:00:00 2001 From: Mahmut Gundogdu Date: Mon, 16 Jan 2023 09:53:05 +0300 Subject: [PATCH 12/12] fix import reference of api.interceptor.spec.ts --- .../packages/oauth/src/lib/tests/api.interceptor.spec.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/npm/ng-packs/packages/oauth/src/lib/tests/api.interceptor.spec.ts b/npm/ng-packs/packages/oauth/src/lib/tests/api.interceptor.spec.ts index 97fa7035dd..1b102b8589 100644 --- a/npm/ng-packs/packages/oauth/src/lib/tests/api.interceptor.spec.ts +++ b/npm/ng-packs/packages/oauth/src/lib/tests/api.interceptor.spec.ts @@ -3,8 +3,7 @@ import { SpyObject } from '@ngneat/spectator'; import { createServiceFactory, SpectatorService } from '@ngneat/spectator/jest'; import { OAuthService } from 'angular-oauth2-oidc'; import { Subject, timer } from 'rxjs'; -import { ApiInterceptor } from '../interceptors/api.interceptor'; -import { HttpWaitService, SessionStateService, TENANT_KEY } from '@abp/ng.core'; +import { ApiInterceptor, HttpWaitService, SessionStateService, TENANT_KEY } from '@abp/ng.core'; describe('ApiInterceptor', () => { let spectator: SpectatorService;