From e277a6a8f945e4cfc2a9085907752f7bb217fc77 Mon Sep 17 00:00:00 2001 From: Yaser Moradi Date: Wed, 22 Nov 2023 01:39:52 +0100 Subject: [PATCH] feat(templates): add support for refresh token #6071 (#6072) --- .../.azure-devops/workflows/cd.yml | 4 +- .../Bit.BlazorWeb/.github/workflows/cd.yml | 9 +- .../BlazorWeb.Client/BlazorWeb.Client.csproj | 2 - ...Extensions.cs => ICollectionExtensions.cs} | 12 +- .../Extensions/IJSRuntimeExtension.cs | 73 +++ .../IServiceCollectionExtensions.cs | 13 +- .../Extensions/JsRuntimeExtension.cs | 22 - .../Categories/AddOrEditCategoryPage.razor | 4 +- .../Pages/Categories/CategoriesPage.razor.cs | 2 +- .../DeleteAccountConfirmModal.razor.cs | 4 +- .../Pages/Identity/EditProfilePage.razor | 26 +- .../Pages/Identity/EditProfilePage.razor.cs | 9 +- .../Identity/EmailConfirmationPage.razor | 10 +- .../Identity/EmailConfirmationPage.razor.cs | 25 +- .../Pages/Identity/ForgotPasswordPage.razor | 8 +- .../Identity/ForgotPasswordPage.razor.cs | 2 +- .../Pages/Identity/ResetPasswordPage.razor | 8 +- .../Pages/Identity/ResetPasswordPage.razor.cs | 12 +- .../Pages/Identity/SignInPage.razor | 24 +- .../Pages/Identity/SignInPage.razor.cs | 13 +- .../Pages/Identity/SignUpPage.razor | 20 +- .../Pages/Identity/SignUpPage.razor.cs | 6 +- .../Pages/NotAuthorizedPage.razor | 4 +- .../Pages/NotAuthorizedPage.razor.cs | 46 +- .../BlazorWeb.Client/Pages/NotFoundPage.razor | 2 - .../Pages/Products/ProductsPage.razor | 2 +- .../Pages/Products/ProductsPage.razor.cs | 2 +- .../BlazorWeb.Client/Pages/TermsPage.razor | 18 +- .../Pages/Todo/TodoPage.razor | 20 +- .../src/BlazorWeb.Client/Program.cs | 3 +- .../src/BlazorWeb.Client/Scripts/app.ts | 8 +- .../AppAuthenticationStateProvider.cs | 27 +- .../Services/AuthenticationService.cs | 30 -- .../Services/ClientSideAuthTokenProvider.cs | 4 +- .../Contracts/IAuthenticationService.cs | 10 - .../Services/Contracts/IPubSubService.cs | 2 +- .../Services/ExceptionHandler.cs | 38 +- .../AuthDelegatingHandler.cs | 72 +-- .../ExceptionDelegatingHandler.cs | 29 +- ....cs => RequestHeadersDelegationHandler.cs} | 18 +- .../RetryDelegatingHandler.cs | 15 +- .../Services/PrerenderStateService.cs | 12 +- .../Services/PubSubService.cs | 14 +- .../Services/RenderModeProvider.cs | 10 +- .../Shared/AppComponentBase.cs | 6 +- .../Shared/AppDataAnnotationsValidator.cs | 28 +- .../ChangePrerenderResponseStatusCode.cs | 35 -- .../BlazorWeb.Client/Shared/Footer.razor.cs | 6 +- .../src/BlazorWeb.Client/Shared/Header.razor | 2 +- .../BlazorWeb.Client/Shared/Header.razor.cs | 4 +- .../Shared/MainLayout.razor.cs | 8 +- .../BlazorWeb.Client/Shared/NavMenu.razor.cs | 4 +- .../Shared/PageNotFound.razor | 8 - .../Shared/PageNotFound.razor.scss | 30 -- .../Shared/SignOutConfirmModal.razor.cs | 4 +- .../src/BlazorWeb.Client/appsettings.json | 9 - .../src/BlazorWeb.Client/compilerconfig.json | 60 +-- .../src/BlazorWeb.Infra/BlazorWeb.Iac.csproj | 2 - .../src/BlazorWeb.Infra/BwStack.cs | 2 +- .../src/BlazorWeb.Server/AppSettings.cs | 16 +- .../BlazorWeb.Server/BlazorWeb.Server.csproj | 5 +- .../Components/ResetPasswordTemplate.razor | 2 +- .../Controllers/AppControllerBase.cs | 2 - .../Controllers/AttachmentController.cs | 14 +- .../Categories/CategoryController.cs | 8 +- ...uthController.cs => IdentityController.cs} | 123 +++-- .../Controllers/Identity/UserController.cs | 10 +- .../Controllers/Products/ProductController.cs | 6 +- .../Controllers/Todo/TodoItemController.cs | 6 +- .../src/BlazorWeb.Server/Data/AppDbContext.cs | 12 +- .../Identity/UserConfiguration.cs | 1 + ...231118003945_InitialMigration.Designer.cs} | 29 +- ....cs => 20231118003945_InitialMigration.cs} | 24 +- .../Migrations/AppDbContextModelSnapshot.cs | 27 +- .../IServiceCollectionExtensions.cs | 132 +++--- .../Extensions/ODataOperationFilter.cs | 5 +- .../BlazorWeb.Server/Mappers/TodoMapper.cs | 4 +- .../Services/ApiExceptionHandler.cs | 6 +- .../Services/AppIdentityErrorDescriber.cs | 61 +++ .../Services/AppSecureJwtDataFormat.cs | 56 +++ .../Services/Contracts/IJwtService.cs | 9 - .../Contracts/IUserInformationProvider.cs | 14 - .../BlazorWeb.Server/Services/JwtService.cs | 49 -- .../Services/ServerSideAuthTokenProvider.cs | 10 +- .../Services/UserInformationProvider.cs | 57 --- .../BlazorWeb.Server/Startup/Middlewares.cs | 75 +++- .../src/BlazorWeb.Server/Startup/Services.cs | 9 +- .../src/BlazorWeb.Server/appsettings.json | 14 +- .../wwwroot/swagger/swagger-utils.js | 12 +- .../BlazorWeb.Shared/Dtos/AppJsonContext.cs | 7 +- .../Dtos/Identity/RefreshRequestDto.cs | 8 + .../Dtos/Identity/SignInRequestDto.cs | 6 +- .../Dtos/Identity/SignUpRequestDto.cs | 2 +- ...gnInResponseDto.cs => TokenResponseDto.cs} | 7 +- .../BlazorWeb.Shared/Dtos/PagedResultDto.cs | 4 +- .../Extensions/ClaimsPrincipalExtensions.cs | 9 +- .../IServiceCollectionExtensions.cs | 2 +- .../src/BlazorWeb.Shared/Mapper.cs | 6 - .../Resources/AppStrings.Designer.cs | 11 +- .../Resources/AppStrings.fr.resx | 10 +- .../Resources/AppStrings.resx | 424 +++++++++--------- .../Resources/IdentityStrings.Designer.cs | 252 ----------- .../Resources/IdentityStrings.fr.resx | 84 ---- .../Resources/IdentityStrings.resx | 271 ++++------- .../Services/Contracts/IAuthTokenProvider.cs | 1 + .../Bit.BlazorWeb/src/Directory.Build.props | 8 +- .../.azure-devops/workflows/cd.yml | 2 +- .../Bit.Boilerplate/.github/workflows/cd.yml | 2 +- .../Bit.Boilerplate/Boilerplate.slnLaunch | 57 +++ .../Client/App/Boilerplate.Client.App.csproj | 1 - .../IServiceCollectionExtensions.cs | 4 +- .../src/Client/App/MauiProgram.cs | 4 +- .../src/Client/Core/App.razor.cs | 2 +- .../Core/Boilerplate.Client.Core.csproj | 2 - ...Extensions.cs => ICollectionExtensions.cs} | 12 +- .../Extensions/IJSRuntimeExtensions.Hybrid.cs | 60 +++ .../Core/Extensions/IJSRuntimeExtensions.cs | 76 ++++ .../IServiceCollectionExtensions.cs | 48 +- .../Core/Extensions/JsRuntimeExtension.cs | 22 - .../Categories/AddOrEditCategoryPage.razor | 4 +- .../Pages/Categories/CategoriesPage.razor.cs | 2 +- .../DeleteAccountConfirmModal.razor.cs | 7 +- .../Core/Pages/Identity/EditProfilePage.razor | 26 +- .../Pages/Identity/EditProfilePage.razor.cs | 9 +- .../Identity/EmailConfirmationPage.razor | 10 +- .../Identity/EmailConfirmationPage.razor.cs | 25 +- .../Pages/Identity/ForgotPasswordPage.razor | 8 +- .../Identity/ForgotPasswordPage.razor.cs | 2 +- .../Pages/Identity/ResetPasswordPage.razor | 8 +- .../Pages/Identity/ResetPasswordPage.razor.cs | 20 +- .../Core/Pages/Identity/SignInPage.razor | 24 +- .../Core/Pages/Identity/SignInPage.razor.cs | 13 +- .../Core/Pages/Identity/SignUpPage.razor | 20 +- .../Core/Pages/Identity/SignUpPage.razor.cs | 6 +- .../Core/Pages/Products/ProductsPage.razor | 2 +- .../Core/Pages/Products/ProductsPage.razor.cs | 2 +- .../src/Client/Core/Pages/TermsPage.razor | 18 +- .../src/Client/Core/Pages/Todo/TodoPage.razor | 20 +- .../src/Client/Core/Scripts/app.ts | 8 +- .../AppAuthenticationStateProvider.cs | 27 +- .../Core/Services/AuthenticationService.cs | 38 -- .../Services/ClientSideAuthTokenProvider.cs | 8 +- .../Contracts/IAuthenticationService.cs | 10 - .../Core/Services/Contracts/IPubSubService.cs | 2 +- .../Core/Services/ExceptionHandlerBase.cs | 38 +- .../AuthDelegatingHandler.cs | 69 +-- .../ExceptionDelegatingHandler.cs | 29 +- ....cs => RequestHeadersDelegationHandler.cs} | 22 +- .../RetryDelegatingHandler.cs | 14 +- .../Core/Services/PrerenderStateService.cs | 10 +- .../src/Client/Core/Services/PubSubService.cs | 14 +- .../Client/Core/Shared/AppComponentBase.cs | 4 +- .../Shared/AppDataAnnotationsValidator.cs | 28 +- .../ChangePrerenderResponseStatusCode.cs | 6 +- .../src/Client/Core/Shared/Footer.razor.cs | 6 +- .../src/Client/Core/Shared/Header.razor | 2 +- .../src/Client/Core/Shared/Header.razor.cs | 4 +- .../Client/Core/Shared/MainLayout.razor.cs | 8 +- .../src/Client/Core/Shared/NavMenu.razor.cs | 4 +- .../Shared/NotAuthorizedComponent.razor.cs | 41 +- .../Core/Shared/SignOutConfirmModal.razor.cs | 7 +- .../src/Client/Core/compilerconfig.json | 62 +-- .../IServiceCollectionExtensions.cs | 4 +- .../Client/Web/Program.BlazorWebAssembly.cs | 7 +- .../Services/ServerSideAuthTokenProvider.cs | 12 +- .../src/Client/Web/Startup/Services.cs | 4 +- .../src/Infra/Iac/Boilerplate.Iac.csproj | 2 - .../Bit.Boilerplate/src/Infra/Iac/BpStack.cs | 2 +- .../src/Server/Api/AppSettings.cs | 16 +- .../Server/Api/Boilerplate.Server.Api.csproj | 3 +- .../Api/Controllers/AppControllerBase.cs | 2 - .../Api/Controllers/AttachmentController.cs | 14 +- .../Categories/CategoryController.cs | 8 +- ...uthController.cs => IdentityController.cs} | 133 +++--- .../Controllers/Identity/UserController.cs | 10 +- .../Controllers/Products/ProductController.cs | 6 +- .../Controllers/Todo/TodoItemController.cs | 6 +- .../src/Server/Api/Data/AppDbContext.cs | 4 +- .../Identity/UserConfiguration.cs | 1 + ...231121162004_InitialMigration.Designer.cs} | 29 +- ....cs => 20231121162004_InitialMigration.cs} | 24 +- .../Migrations/AppDbContextModelSnapshot.cs | 27 +- .../IServiceCollectionExtensions.cs | 90 ++-- .../Api/Extensions/ODataOperationFilter.cs | 5 +- .../Api/Resources/ResetPasswordTemplate.razor | 2 +- .../Api/Services/ApiExceptionHandler.cs | 6 +- .../Api/Services/AppIdentityErrorDescriber.cs | 61 +++ .../Api/Services/AppSecureJwtDataFormat.cs | 56 +++ .../Api/Services/Contracts/IJwtService.cs | 9 - .../Contracts/IUserInformationProvider.cs | 14 - .../src/Server/Api/Services/JwtService.cs | 49 -- .../Api/Services/UserInformationProvider.cs | 57 --- .../src/Server/Api/Startup/Services.cs | 42 +- .../src/Server/Api/appsettings.json | 14 +- .../Api/wwwroot/swagger/swagger-utils.js | 12 +- .../src/Shared/Dtos/AppJsonContext.cs | 3 +- .../Shared/Dtos/Identity/RefreshRequestDto.cs | 8 + .../Shared/Dtos/Identity/SignInRequestDto.cs | 6 +- .../{SignInResponseDto.cs => TokenDto.cs} | 8 +- .../src/Shared/Dtos/PagedResultDto.cs | 4 +- .../Extensions/ClaimsPrincipalExtensions.cs | 9 +- .../IServiceCollectionExtensions.cs | 2 +- .../Bit.Boilerplate/src/Shared/Mapper.cs | 6 - .../Shared/Resources/AppStrings.Designer.cs | 22 +- .../src/Shared/Resources/AppStrings.fr.resx | 10 +- .../src/Shared/Resources/AppStrings.resx | 424 +++++++++--------- .../Shared/Resources/IdentityStrings.fr.resx | 84 ---- .../src/Shared/Resources/IdentityStrings.resx | 271 ++++------- .../Services/Contracts/IAuthTokenProvider.cs | 1 + .../Bit.Websites.Careers.Client.csproj | 2 - .../Extensions/IJSRuntimeExtension.cs} | 2 +- .../Extensions/IListExtensions.cs | 2 +- .../IServiceCollectionExtensions.cs | 7 +- .../Bit.Websites.Careers.Client/Program.cs | 1 - .../Bit.Websites.Careers.Client/Routes.razor | 5 +- .../Routes.razor.cs | 14 - .../Services/Contracts/IPubSubService.cs | 2 +- .../ExceptionDelegatingHandler.cs | 19 +- .../RequestHeadersDelegationHandler.cs | 15 + .../RetryDelegatingHandler.cs | 14 +- .../Services/PrerenderStateService.cs | 10 +- .../Services/PubSubService.cs | 14 +- .../Services/RenderModeProvider.cs | 10 +- .../Shared/AppComponentBase.cs | 2 +- .../ChangePrerenderResponseStatusCode.cs | 35 -- .../appsettings.json | 9 - .../compilerconfig.json | 34 +- .../Bit.Websites.Careers.Server.csproj | 2 - .../IServiceCollectionExtensions.cs | 32 +- .../Startup/Middlewares.cs | 55 ++- .../Startup/Services.cs | 2 +- .../IServiceCollectionExtensions.cs | 2 +- .../Careers/src/Directory.Build.props | 6 +- .../Bit.Websites.Platform.Client.csproj | 2 - .../Extensions/IJSRuntimeExtension.cs} | 2 +- .../Extensions/IListExtensions.cs | 2 +- .../IServiceCollectionExtensions.cs | 7 +- .../Pages/ContactUsPage.razor | 4 +- .../Pages/HomePage.razor | 40 +- .../Pages/HomePage.razor.cs | 2 - .../Pages/PricingPage.razor | 64 +-- .../Pages/Templates/DeploymentTypePage.razor | 6 +- .../Pages/Templates/DevOpsPage.razor | 14 +- .../Pages/Templates/HostingModelsPage.razor | 2 +- .../Pages/Templates/OverviewPage.razor | 2 +- .../Pages/Templates/SettingsPage.razor | 6 +- .../Bit.Websites.Platform.Client/Program.cs | 1 - .../Bit.Websites.Platform.Client/Routes.razor | 3 +- .../Routes.razor.cs | 14 - .../Services/Contracts/IPubSubService.cs | 2 +- .../ExceptionDelegatingHandler.cs | 15 +- .../RequestHeadersDelegationHandler.cs | 15 + .../RetryDelegatingHandler.cs | 14 +- .../Services/PrerenderStateService.cs | 10 +- .../Services/PubSubService.cs | 14 +- .../Services/RenderModeProvider.cs | 10 +- .../Shared/AppComponentBase.cs | 2 +- .../ChangePrerenderResponseStatusCode.cs | 35 -- .../Shared/Header.razor.cs | 4 +- .../Shared/PageNotFound.razor | 15 - .../Shared/PageNotFound.razor.cs | 11 - .../Shared/PageNotFound.razor.scss | 168 ------- .../appsettings.json | 9 - .../compilerconfig.json | 114 +++-- .../Bit.Websites.Platform.Server.csproj | 2 - .../Controllers/ContactUsController.cs | 4 +- .../Controllers/SupportPackageController.cs | 4 +- .../IServiceCollectionExtensions.cs | 32 +- .../Services/TelegramBotApiClient.cs | 12 +- .../Services/TelegramBotService.cs | 6 +- .../Startup/Middlewares.cs | 53 ++- .../Startup/Services.cs | 2 +- .../IServiceCollectionExtensions.cs | 2 +- .../Platform/src/Directory.Build.props | 6 +- .../Bit.Websites.Sales.Client.csproj | 2 - .../Extensions/IJSRuntimeExtension.cs} | 2 +- .../Extensions/IListExtensions.cs | 2 +- .../IServiceCollectionExtensions.cs | 7 +- .../Pages/AboutPage.razor | 6 +- .../Pages/HomePage.razor | 16 +- .../Pages/ServicesPage.razor | 48 +- .../src/Bit.Websites.Sales.Client/Program.cs | 1 - .../Bit.Websites.Sales.Client/Routes.razor | 3 +- .../Bit.Websites.Sales.Client/Routes.razor.cs | 14 - .../Bit.Websites.Sales.Client/Scripts/app.ts | 23 - .../Services/Contracts/IPubSubService.cs | 2 +- .../ExceptionDelegatingHandler.cs | 15 +- .../RequestHeadersDelegationHandler.cs | 15 + .../RetryDelegatingHandler.cs | 14 +- .../Services/PrerenderStateService.cs | 10 +- .../Services/PubSubService.cs | 14 +- .../Services/RenderModeProvider.cs | 10 +- .../Shared/AppComponentBase.cs | 2 +- .../ChangePrerenderResponseStatusCode.cs | 35 -- .../Shared/MainLayout.razor.cs | 2 +- .../Shared/PageNotFound.razor.cs | 4 +- .../appsettings.json | 9 - .../compilerconfig.json | 52 +-- .../Bit.Websites.Sales.Server.csproj | 2 - .../Components/App.razor | 19 - .../Controllers/ContactUsController.cs | 4 +- .../IServiceCollectionExtensions.cs | 32 +- .../Services/TelegramBotApiClient.cs | 12 +- .../Services/TelegramBotService.cs | 4 +- .../Startup/Middlewares.cs | 53 ++- .../Startup/Services.cs | 2 +- .../IServiceCollectionExtensions.cs | 2 +- src/Websites/Sales/src/Directory.Build.props | 6 +- 308 files changed, 3077 insertions(+), 3775 deletions(-) rename src/Templates/BlazorWeb/Bit.BlazorWeb/src/BlazorWeb.Client/Extensions/{IListExtensions.cs => ICollectionExtensions.cs} (59%) create mode 100644 src/Templates/BlazorWeb/Bit.BlazorWeb/src/BlazorWeb.Client/Extensions/IJSRuntimeExtension.cs delete mode 100644 src/Templates/BlazorWeb/Bit.BlazorWeb/src/BlazorWeb.Client/Extensions/JsRuntimeExtension.cs delete mode 100644 src/Templates/BlazorWeb/Bit.BlazorWeb/src/BlazorWeb.Client/Services/AuthenticationService.cs delete mode 100644 src/Templates/BlazorWeb/Bit.BlazorWeb/src/BlazorWeb.Client/Services/Contracts/IAuthenticationService.cs rename src/Templates/BlazorWeb/Bit.BlazorWeb/src/BlazorWeb.Client/Services/HttpMessageHandlers/{LocalizationDelegatingHandler.cs => RequestHeadersDelegationHandler.cs} (65%) delete mode 100644 src/Templates/BlazorWeb/Bit.BlazorWeb/src/BlazorWeb.Client/Shared/ChangePrerenderResponseStatusCode.cs delete mode 100644 src/Templates/BlazorWeb/Bit.BlazorWeb/src/BlazorWeb.Client/Shared/PageNotFound.razor delete mode 100644 src/Templates/BlazorWeb/Bit.BlazorWeb/src/BlazorWeb.Client/Shared/PageNotFound.razor.scss rename src/Templates/BlazorWeb/Bit.BlazorWeb/src/BlazorWeb.Server/Controllers/Identity/{AuthController.cs => IdentityController.cs} (71%) rename src/Templates/BlazorWeb/Bit.BlazorWeb/src/BlazorWeb.Server/Data/Migrations/{20231114012959_InitialMigration.Designer.cs => 20231118003945_InitialMigration.Designer.cs} (96%) rename src/Templates/BlazorWeb/Bit.BlazorWeb/src/BlazorWeb.Server/Data/Migrations/{20231114012959_InitialMigration.cs => 20231118003945_InitialMigration.cs} (94%) create mode 100644 src/Templates/BlazorWeb/Bit.BlazorWeb/src/BlazorWeb.Server/Services/AppIdentityErrorDescriber.cs create mode 100644 src/Templates/BlazorWeb/Bit.BlazorWeb/src/BlazorWeb.Server/Services/AppSecureJwtDataFormat.cs delete mode 100644 src/Templates/BlazorWeb/Bit.BlazorWeb/src/BlazorWeb.Server/Services/Contracts/IJwtService.cs delete mode 100644 src/Templates/BlazorWeb/Bit.BlazorWeb/src/BlazorWeb.Server/Services/Contracts/IUserInformationProvider.cs delete mode 100644 src/Templates/BlazorWeb/Bit.BlazorWeb/src/BlazorWeb.Server/Services/JwtService.cs delete mode 100644 src/Templates/BlazorWeb/Bit.BlazorWeb/src/BlazorWeb.Server/Services/UserInformationProvider.cs create mode 100644 src/Templates/BlazorWeb/Bit.BlazorWeb/src/BlazorWeb.Shared/Dtos/Identity/RefreshRequestDto.cs rename src/Templates/BlazorWeb/Bit.BlazorWeb/src/BlazorWeb.Shared/Dtos/Identity/{SignInResponseDto.cs => TokenResponseDto.cs} (53%) create mode 100644 src/Templates/Boilerplate/Bit.Boilerplate/Boilerplate.slnLaunch rename src/Templates/Boilerplate/Bit.Boilerplate/src/Client/Core/Extensions/{IListExtensions.cs => ICollectionExtensions.cs} (59%) create mode 100644 src/Templates/Boilerplate/Bit.Boilerplate/src/Client/Core/Extensions/IJSRuntimeExtensions.Hybrid.cs create mode 100644 src/Templates/Boilerplate/Bit.Boilerplate/src/Client/Core/Extensions/IJSRuntimeExtensions.cs delete mode 100644 src/Templates/Boilerplate/Bit.Boilerplate/src/Client/Core/Extensions/JsRuntimeExtension.cs delete mode 100644 src/Templates/Boilerplate/Bit.Boilerplate/src/Client/Core/Services/AuthenticationService.cs delete mode 100644 src/Templates/Boilerplate/Bit.Boilerplate/src/Client/Core/Services/Contracts/IAuthenticationService.cs rename src/Templates/Boilerplate/Bit.Boilerplate/src/Client/Core/Services/HttpMessageHandlers/{LocalizationDelegatingHandler.cs => RequestHeadersDelegationHandler.cs} (61%) rename src/Templates/Boilerplate/Bit.Boilerplate/src/Server/Api/Controllers/Identity/{AuthController.cs => IdentityController.cs} (71%) rename src/Templates/Boilerplate/Bit.Boilerplate/src/Server/Api/Data/Migrations/{20231113190400_InitialMigration.Designer.cs => 20231121162004_InitialMigration.Designer.cs} (96%) rename src/Templates/Boilerplate/Bit.Boilerplate/src/Server/Api/Data/Migrations/{20231113190400_InitialMigration.cs => 20231121162004_InitialMigration.cs} (94%) create mode 100644 src/Templates/Boilerplate/Bit.Boilerplate/src/Server/Api/Services/AppIdentityErrorDescriber.cs create mode 100644 src/Templates/Boilerplate/Bit.Boilerplate/src/Server/Api/Services/AppSecureJwtDataFormat.cs delete mode 100644 src/Templates/Boilerplate/Bit.Boilerplate/src/Server/Api/Services/Contracts/IJwtService.cs delete mode 100644 src/Templates/Boilerplate/Bit.Boilerplate/src/Server/Api/Services/Contracts/IUserInformationProvider.cs delete mode 100644 src/Templates/Boilerplate/Bit.Boilerplate/src/Server/Api/Services/JwtService.cs delete mode 100644 src/Templates/Boilerplate/Bit.Boilerplate/src/Server/Api/Services/UserInformationProvider.cs create mode 100644 src/Templates/Boilerplate/Bit.Boilerplate/src/Shared/Dtos/Identity/RefreshRequestDto.cs rename src/Templates/Boilerplate/Bit.Boilerplate/src/Shared/Dtos/Identity/{SignInResponseDto.cs => TokenDto.cs} (58%) rename src/Websites/{Sales/src/Bit.Websites.Sales.Client/Extensions/JsRuntimeExtension.cs => Careers/src/Bit.Websites.Careers.Client/Extensions/IJSRuntimeExtension.cs} (93%) create mode 100644 src/Websites/Careers/src/Bit.Websites.Careers.Client/Services/HttpMessageHandlers/RequestHeadersDelegationHandler.cs delete mode 100644 src/Websites/Careers/src/Bit.Websites.Careers.Client/Shared/ChangePrerenderResponseStatusCode.cs rename src/Websites/{Careers/src/Bit.Websites.Careers.Client/Extensions/JsRuntimeExtension.cs => Platform/src/Bit.Websites.Platform.Client/Extensions/IJSRuntimeExtension.cs} (93%) create mode 100644 src/Websites/Platform/src/Bit.Websites.Platform.Client/Services/HttpMessageHandlers/RequestHeadersDelegationHandler.cs delete mode 100644 src/Websites/Platform/src/Bit.Websites.Platform.Client/Shared/ChangePrerenderResponseStatusCode.cs delete mode 100644 src/Websites/Platform/src/Bit.Websites.Platform.Client/Shared/PageNotFound.razor delete mode 100644 src/Websites/Platform/src/Bit.Websites.Platform.Client/Shared/PageNotFound.razor.cs delete mode 100644 src/Websites/Platform/src/Bit.Websites.Platform.Client/Shared/PageNotFound.razor.scss rename src/Websites/{Platform/src/Bit.Websites.Platform.Client/Extensions/JsRuntimeExtension.cs => Sales/src/Bit.Websites.Sales.Client/Extensions/IJSRuntimeExtension.cs} (93%) create mode 100644 src/Websites/Sales/src/Bit.Websites.Sales.Client/Services/HttpMessageHandlers/RequestHeadersDelegationHandler.cs delete mode 100644 src/Websites/Sales/src/Bit.Websites.Sales.Client/Shared/ChangePrerenderResponseStatusCode.cs diff --git a/src/Templates/BlazorWeb/Bit.BlazorWeb/.azure-devops/workflows/cd.yml b/src/Templates/BlazorWeb/Bit.BlazorWeb/.azure-devops/workflows/cd.yml index 469e56b680..acf0b68361 100644 --- a/src/Templates/BlazorWeb/Bit.BlazorWeb/.azure-devops/workflows/cd.yml +++ b/src/Templates/BlazorWeb/Bit.BlazorWeb/.azure-devops/workflows/cd.yml @@ -7,8 +7,8 @@ variables: APP_SERVICE_NAME: 'app-service-td-test' AZURE_SERVICE_CONNECTION: 'td-test-service-connection' # https://learn.microsoft.com/en-us/azure/devops/pipelines/library/service-endpoints?view=azure-devops&tabs=yaml#azure-resource-manager-service-connection ConnectionStrings.SqlServerConnectionString: $(DB_CONNECTION_STRING) - AppSettings.JwtSettings.IdentityCertificatePassword: $(API_IDENTITY_CERTIFICATE_PASSWORD) - # ApiServerAddress: 'api/' + AppSettings.IdentitySettings.IdentityCertificatePassword: $(API_IDENTITY_CERTIFICATE_PASSWORD) + ApiServerAddress: 'api/' # // You can also use absolute urls such as https://todob.bitplatform.dev/api/ jobs: diff --git a/src/Templates/BlazorWeb/Bit.BlazorWeb/.github/workflows/cd.yml b/src/Templates/BlazorWeb/Bit.BlazorWeb/.github/workflows/cd.yml index f9b3680db7..47c4e6ed8e 100644 --- a/src/Templates/BlazorWeb/Bit.BlazorWeb/.github/workflows/cd.yml +++ b/src/Templates/BlazorWeb/Bit.BlazorWeb/.github/workflows/cd.yml @@ -33,6 +33,13 @@ jobs: with: node-version: 18 + - name: Update appsettings.json api server address + uses: microsoft/variable-substitution@v1 + with: + files: 'src/BlazorWeb.Client/appsettings.json' + env: + ApiServerAddress: ${{ env.API_SERVER_ADDRESS }} + - name: Install wasm run: cd src && dotnet workload install wasm-tools wasm-experimental @@ -84,7 +91,7 @@ jobs: files: 'appsettings.json' env: ConnectionStrings.SqlServerConnectionString: ${{ secrets.DB_CONNECTION_STRING }} - AppSettings.JwtSettings.IdentityCertificatePassword: ${{ secrets.API_IDENTITY_CERTIFICATE_PASSWORD }} + AppSettings.IdentitySettings.IdentityCertificatePassword: ${{ secrets.API_IDENTITY_CERTIFICATE_PASSWORD }} - name: Delete IdentityCertificate.pfx run: | diff --git a/src/Templates/BlazorWeb/Bit.BlazorWeb/src/BlazorWeb.Client/BlazorWeb.Client.csproj b/src/Templates/BlazorWeb/Bit.BlazorWeb/src/BlazorWeb.Client/BlazorWeb.Client.csproj index b2c860cfa6..62c1a63c0d 100644 --- a/src/Templates/BlazorWeb/Bit.BlazorWeb/src/BlazorWeb.Client/BlazorWeb.Client.csproj +++ b/src/Templates/BlazorWeb/Bit.BlazorWeb/src/BlazorWeb.Client/BlazorWeb.Client.csproj @@ -4,8 +4,6 @@ net8.0 - enable - enable true Default true diff --git a/src/Templates/BlazorWeb/Bit.BlazorWeb/src/BlazorWeb.Client/Extensions/IListExtensions.cs b/src/Templates/BlazorWeb/Bit.BlazorWeb/src/BlazorWeb.Client/Extensions/ICollectionExtensions.cs similarity index 59% rename from src/Templates/BlazorWeb/Bit.BlazorWeb/src/BlazorWeb.Client/Extensions/IListExtensions.cs rename to src/Templates/BlazorWeb/Bit.BlazorWeb/src/BlazorWeb.Client/Extensions/ICollectionExtensions.cs index 8f50eb4679..399d6b295f 100644 --- a/src/Templates/BlazorWeb/Bit.BlazorWeb/src/BlazorWeb.Client/Extensions/IListExtensions.cs +++ b/src/Templates/BlazorWeb/Bit.BlazorWeb/src/BlazorWeb.Client/Extensions/ICollectionExtensions.cs @@ -1,6 +1,6 @@ namespace System.Collections.Generic; -public static class IListExtensions +public static class ICollectionExtensions { // Basically a Polyfill since we now expose IList instead of List // which is better but IList doesn't have AddRange @@ -20,4 +20,14 @@ public static void AddRange(this IList list, IEnumerable items) list.Add(item); } } + + public static async Task> ToListAsync(this IAsyncEnumerable items, CancellationToken cancellationToken = default) + { + var results = new List(); + await foreach (var item in items.WithCancellation(cancellationToken)) + { + results.Add(item); + } + return results; + } } diff --git a/src/Templates/BlazorWeb/Bit.BlazorWeb/src/BlazorWeb.Client/Extensions/IJSRuntimeExtension.cs b/src/Templates/BlazorWeb/Bit.BlazorWeb/src/BlazorWeb.Client/Extensions/IJSRuntimeExtension.cs new file mode 100644 index 0000000000..1c78908da8 --- /dev/null +++ b/src/Templates/BlazorWeb/Bit.BlazorWeb/src/BlazorWeb.Client/Extensions/IJSRuntimeExtension.cs @@ -0,0 +1,73 @@ +using BlazorWeb.Shared.Dtos.Identity; + +namespace Microsoft.JSInterop; + +public static class IJSRuntimeExtensions +{ + /// + /// To disable the scrollbar of the body when showing the modal, so the modal can be always shown in the viewport without being scrolled out. + /// + public static async Task SetBodyOverflow(this IJSRuntime jsRuntime, bool hidden) + { + await jsRuntime.InvokeVoidAsync("App.setBodyOverflow", hidden); + } + + public static async Task GoBack(this IJSRuntime jsRuntime) + { + await jsRuntime.InvokeVoidAsync("App.goBack"); + } + + public static async Task ApplyBodyElementClasses(this IJSRuntime jsRuntime, List cssClasses, Dictionary cssVariables) + { + await jsRuntime.InvokeVoidAsync("App.applyBodyElementClasses", cssClasses, cssVariables); + } + + public static async Task SetCookie(this IJSRuntime jsRuntime, string key, string value, long expiresIn, bool rememberMe) + { + await jsRuntime.InvokeVoidAsync("App.setCookie", key, value, expiresIn, rememberMe); + } + + public static async Task RemoveCookie(this IJSRuntime jsRuntime, string key) + { + await jsRuntime.InvokeVoidAsync("App.removeCookie", key); + } + + public static async Task GetCookie(this IJSRuntime jsRuntime, string key) + { + return await jsRuntime.InvokeAsync("App.getCookie", key); + } + + public static async Task SetLocalStorage(this IJSRuntime jsRuntime, string key, string value, bool rememberMe) + { + await jsRuntime.InvokeVoidAsync($"window.{(rememberMe ? "localStorage" : "sessionStorage")}.setItem", key, value); + } + + public static async Task RemoveLocalStorage(this IJSRuntime jsRuntime, string key) + { + await jsRuntime.InvokeVoidAsync("window.sessionStorage.removeItem", key); + await jsRuntime.InvokeVoidAsync("window.localStorage.removeItem", key); + } + + public static async Task GetLocalStorage(this IJSRuntime jsRuntime, string key) + { + return (await jsRuntime.InvokeAsync("window.localStorage.getItem", key)) ?? + (await jsRuntime.InvokeAsync("window.sessionStorage.getItem", key)); + } + + public static async Task StoreAuthToken(this IJSRuntime jsRuntime, TokenResponseDto tokenResponse, bool? rememberMe = null) + { + if (rememberMe is null) + { + rememberMe = string.IsNullOrEmpty(await jsRuntime.InvokeAsync("window.localStorage.getItem", "refresh_token")) is false; + } + + await jsRuntime.SetCookie("access_token", tokenResponse.AccessToken!, tokenResponse.ExpiresIn, rememberMe is true); + await jsRuntime.SetLocalStorage("refresh_token", tokenResponse.RefreshToken!, rememberMe is true); + } + + public static async Task RemoveAuthTokens(this IJSRuntime jsRuntime) + { + await jsRuntime.RemoveCookie("access_token"); + await jsRuntime.RemoveLocalStorage("refresh_token"); + } +} diff --git a/src/Templates/BlazorWeb/Bit.BlazorWeb/src/BlazorWeb.Client/Extensions/IServiceCollectionExtensions.cs b/src/Templates/BlazorWeb/Bit.BlazorWeb/src/BlazorWeb.Client/Extensions/IServiceCollectionExtensions.cs index 1ccfa701d8..db230b04e9 100644 --- a/src/Templates/BlazorWeb/Bit.BlazorWeb/src/BlazorWeb.Client/Extensions/IServiceCollectionExtensions.cs +++ b/src/Templates/BlazorWeb/Bit.BlazorWeb/src/BlazorWeb.Client/Extensions/IServiceCollectionExtensions.cs @@ -1,5 +1,6 @@ //-:cnd:noEmit using BlazorWeb.Client.Services.HttpMessageHandlers; +using Microsoft.AspNetCore.Components.WebAssembly.Services; namespace Microsoft.Extensions.DependencyInjection; @@ -9,23 +10,23 @@ public static IServiceCollection AddClientSharedServices(this IServiceCollection { services.AddSharedServices(); - services.AddCascadingAuthenticationState(); - services.AddScoped(); - services.AddScoped(); + services.AddTransient(); + services.AddTransient(); services.AddScoped(); services.AddBitBlazorUIServices(); - services.AddTransient(); + services.AddTransient(); services.AddTransient(); services.AddTransient(); services.AddTransient(); services.AddTransient(); services.AddScoped(); - services.AddScoped(); services.AddScoped(sp => (AppAuthenticationStateProvider)sp.GetRequiredService()); - services.AddScoped(); + services.AddTransient(); + + services.AddTransient(); return services; } diff --git a/src/Templates/BlazorWeb/Bit.BlazorWeb/src/BlazorWeb.Client/Extensions/JsRuntimeExtension.cs b/src/Templates/BlazorWeb/Bit.BlazorWeb/src/BlazorWeb.Client/Extensions/JsRuntimeExtension.cs deleted file mode 100644 index a279c37811..0000000000 --- a/src/Templates/BlazorWeb/Bit.BlazorWeb/src/BlazorWeb.Client/Extensions/JsRuntimeExtension.cs +++ /dev/null @@ -1,22 +0,0 @@ -namespace Microsoft.JSInterop; - -public static class JSRuntimeExtension -{ - /// - /// To disable the scrollbar of the body when showing the modal, so the modal can be always shown in the viewport without being scrolled out. - /// - public static async Task SetBodyOverflow(this IJSRuntime jsRuntime, bool hidden) - { - await jsRuntime.InvokeVoidAsync("App.setBodyOverflow", hidden); - } - - public static async Task GoBack(this IJSRuntime jsRuntime) - { - await jsRuntime.InvokeVoidAsync("App.goBack"); - } - - public static async Task ApplyBodyElementClasses(this IJSRuntime jsRuntime, List cssClasses, Dictionary cssVariables) - { - await jsRuntime.InvokeVoidAsync("App.applyBodyElementClasses", cssClasses, cssVariables); - } -} diff --git a/src/Templates/BlazorWeb/Bit.BlazorWeb/src/BlazorWeb.Client/Pages/Categories/AddOrEditCategoryPage.razor b/src/Templates/BlazorWeb/Bit.BlazorWeb/src/BlazorWeb.Client/Pages/Categories/AddOrEditCategoryPage.razor index 7f950be30a..741e223d42 100644 --- a/src/Templates/BlazorWeb/Bit.BlazorWeb/src/BlazorWeb.Client/Pages/Categories/AddOrEditCategoryPage.razor +++ b/src/Templates/BlazorWeb/Bit.BlazorWeb/src/BlazorWeb.Client/Pages/Categories/AddOrEditCategoryPage.razor @@ -54,8 +54,8 @@
@Localizer[nameof(AppStrings.Color)] -
- @foreach (var color in new[] { "#FFCD56", "#FF6384", "#4BC0C0", "#FF9124", "#2B88D8", "#C7E0F4" }) +
+ @foreach (var color in new[] { "#FFCD56", "#FF6384", "#4BC0C0", "#FF9124", "#2B88D8", "#C7E0F4" }) {