From a2e679a8e6009ee75f06510b051214a291ec99c8 Mon Sep 17 00:00:00 2001 From: Oleg Zhuk Date: Thu, 4 Apr 2024 14:30:13 +0200 Subject: [PATCH] VCST-631: Update vc-storefront to NET8 (#678) feat: Update vc-storefront to NET8 --- .github/workflows/main.yml | 2 +- .github/workflows/pr-ci.yml | 8 +- .github/workflows/pr-deploy.yml | 6 +- .github/workflows/release-branch.yml | 4 +- Directory.Build.props | 16 +- README.md | 160 ++++-------------- .../Exceptions/SaasCompileException.cs | 5 +- .../VirtoCommerce.LiquidThemeEngine.csproj | 26 +-- .../Common/Exceptions/StorefrontException.cs | 5 +- .../Features/Exceptions/FeaturesException.cs | 4 +- .../VirtoCommerce.Storefront.Model.csproj | 12 +- .../VirtoCommerce.Storefront.Tests.csproj | 36 ++-- .../Redis/RedisStorefrontMemoryCache.cs | 19 ++- .../Domain/Security/SecurityConverter.cs | 20 +-- .../Exceptions/NoStoresException.cs | 4 +- .../Exceptions/NoThemeException.cs | 4 +- .../Middleware/WorkContextBuildMiddleware.cs | 4 +- VirtoCommerce.Storefront/Startup.cs | 9 +- .../VirtoCommerce.Storefront.csproj | 53 +++--- azuredeploy.json | 5 +- 20 files changed, 139 insertions(+), 263 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 70dec9e3d..51ca5833b 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -140,7 +140,7 @@ jobs: with: tag: ${{ steps.image.outputs.taggedVersion }} imageName: ${{ env.IMAGE_NAME }} - dockerFiles: 'https://raw.githubusercontent.com/VirtoCommerce/vc-docker/feat/net6/linux/storefront/Dockerfile' + dockerFiles: 'https://raw.githubusercontent.com/VirtoCommerce/vc-docker/feat/net8/linux/storefront/Dockerfile' - name: Publish Github Release if: ${{ github.ref == 'refs/heads/master' }} diff --git a/.github/workflows/pr-ci.yml b/.github/workflows/pr-ci.yml index 776e6d277..5b4a54731 100644 --- a/.github/workflows/pr-ci.yml +++ b/.github/workflows/pr-ci.yml @@ -1,4 +1,4 @@ -# v3.200.3 +# v3.800.4 name: PR build on: @@ -15,15 +15,15 @@ on: jobs: test: - uses: VirtoCommerce/.github/.github/workflows/test-and-sonar.yml@v3.800.2 + uses: VirtoCommerce/.github/.github/workflows/test-and-sonar.yml@v3.800.4 secrets: sonarToken: ${{ secrets.SONAR_TOKEN }} build: - uses: VirtoCommerce/.github/.github/workflows/build.yml@v3.800.2 + uses: VirtoCommerce/.github/.github/workflows/build.yml@v3.800.4 with: uploadDocker: 'true' imageName: 'storefront' - dockerFiles: 'https://raw.githubusercontent.com/VirtoCommerce/vc-docker/feat/net6/linux/storefront/Dockerfile' + dockerFiles: 'https://raw.githubusercontent.com/VirtoCommerce/vc-docker/feat/net8/linux/storefront/Dockerfile' secrets: envPAT: ${{ secrets.REPO_TOKEN }} diff --git a/.github/workflows/pr-deploy.yml b/.github/workflows/pr-deploy.yml index c40fca414..a665ff60b 100644 --- a/.github/workflows/pr-deploy.yml +++ b/.github/workflows/pr-deploy.yml @@ -1,4 +1,4 @@ -# v3.200.7 +# v3.800.4 name: PR deploy on: @@ -47,7 +47,7 @@ jobs: publish: needs: get-deployment-data - uses: VirtoCommerce/.github/.github/workflows/publish-docker.yml@v3.800.2 + uses: VirtoCommerce/.github/.github/workflows/publish-docker.yml@v3.800.4 with: fullKey: ${{ needs.get-deployment-data.outputs.dockerFullKey }} shortKey: '${{ needs.get-deployment-data.outputs.dockerShortKey }}-' @@ -60,7 +60,7 @@ jobs: deploy: needs: [publish, get-deployment-data] - uses: VirtoCommerce/.github/.github/workflows/deploy.yml@v3.800.2 + uses: VirtoCommerce/.github/.github/workflows/deploy.yml@v3.800.4 with: argoServer: 'argo.govirto.com' artifactUrl: ${{ needs.publish.outputs.imagePath }} diff --git a/.github/workflows/release-branch.yml b/.github/workflows/release-branch.yml index de9b5513e..82d1e1df5 100644 --- a/.github/workflows/release-branch.yml +++ b/.github/workflows/release-branch.yml @@ -1,4 +1,4 @@ -# v3.200.5 +# v3.800.5 name: Release - branch on: @@ -25,7 +25,7 @@ jobs: uploadDocker: 'true' eventName: ${{ github.event_name }} imageName: 'storefront' - dockerFiles: 'https://raw.githubusercontent.com/VirtoCommerce/vc-docker/feat/net6/linux/storefront/Dockerfile' + dockerFiles: 'https://raw.githubusercontent.com/VirtoCommerce/vc-docker/feat/net8/linux/storefront/Dockerfile' forceVersionSuffix: 'false' secrets: envPAT: ${{ secrets.REPO_TOKEN }} diff --git a/Directory.Build.props b/Directory.Build.props index 426933aa4..2091def04 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -1,15 +1,15 @@ - + + - VirtoCommerce - Copyright © VirtoCommerce 2011-2022 + Copyright © 2011-2024 Virto Commerce. All rights reserved VirtoCommerce - - 6.43.0 - + + 8.0.0 + + $(VersionSuffix)-$(BuildNumber) - - \ No newline at end of file + diff --git a/README.md b/README.md index f601b259c..2610da64f 100644 --- a/README.md +++ b/README.md @@ -1,155 +1,46 @@ # Virto Commerce Storefront Kit -[![Share on Facebook](https://img.shields.io/badge/facebook--blue.svg?style=social&label=Share&logo=data%3Aimage%2Fsvg%2Bxml%3Bbase64%2CPD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0idXRmLTgiPz48IURPQ1RZUEUgc3ZnIFBVQkxJQyAiLS8vVzNDLy9EVEQgU1ZHIDEuMS8vRU4iICJodHRwOi8vd3d3LnczLm9yZy9HcmFwaGljcy9TVkcvMS4xL0RURC9zdmcxMS5kdGQiPjxzdmcgdmVyc2lvbj0iMS4xIiBpZD0iTGF5ZXJfMSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiB4bWxuczp4bGluaz0iaHR0cDovL3d3dy53My5vcmcvMTk5OS94bGluayIgeD0iMHB4IiB5PSIwcHgiIHdpZHRoPSIyNjYuODkzcHgiIGhlaWdodD0iMjY2Ljg5NXB4IiB2aWV3Qm94PSIwIDAgMjY2Ljg5MyAyNjYuODk1IiBlbmFibGUtYmFja2dyb3VuZD0ibmV3IDAgMCAyNjYuODkzIDI2Ni44OTUiIHhtbDpzcGFjZT0icHJlc2VydmUiPjxwYXRoIGlkPSJCbHVlXzFfIiBmaWxsPSIjM0M1QTk5IiBkPSJNMjQ4LjA4MiwyNjIuMzA3YzcuODU0LDAsMTQuMjIzLTYuMzY5LDE0LjIyMy0xNC4yMjVWMTguODEyYzAtNy44NTctNi4zNjgtMTQuMjI0LTE0LjIyMy0xNC4yMjRIMTguODEyYy03Ljg1NywwLTE0LjIyNCw2LjM2Ny0xNC4yMjQsMTQuMjI0djIyOS4yN2MwLDcuODU1LDYuMzY2LDE0LjIyNSwxNC4yMjQsMTQuMjI1SDI0OC4wODJ6Ii8%2BPHBhdGggaWQ9ImYiIGZpbGw9IiNGRkZGRkYiIGQ9Ik0xODIuNDA5LDI2Mi4zMDd2LTk5LjgwM2gzMy40OTlsNS4wMTYtMzguODk1aC0zOC41MTVWOTguNzc3YzAtMTEuMjYxLDMuMTI3LTE4LjkzNSwxOS4yNzUtMTguOTM1bDIwLjU5Ni0wLjAwOVY0NS4wNDVjLTMuNTYyLTAuNDc0LTE1Ljc4OC0xLjUzMy0zMC4wMTItMS41MzNjLTI5LjY5NSwwLTUwLjAyNSwxOC4xMjYtNTAuMDI1LDUxLjQxM3YyOC42ODRoLTMzLjU4NXYzOC44OTVoMzMuNTg1djk5LjgwM0gxODIuNDA5eiIvPjwvc3ZnPg%3D%3D)](https://www.facebook.com/sharer.php?u=https://virtocommerce.com) [![Tweet](https://img.shields.io/twitter/url/https/virtocommerce.com.svg?style=social)](https://twitter.com/intent/tweet?text=%23VirtoCommerce%20puts%20the%20best%20of%20MS%20Azure%20Cloud%2C%20open%20source%20.Net%20code%20and%20agile%20development%20in%20a%20single%20enterprise%20%23ecommerce%20platform.) [![Latest release](https://img.shields.io/github/release/VirtoCommerce/vc-storefront.svg)](https://github.com/VirtoCommerce/vc-storefront/releases/latest) [![Total downloads](https://img.shields.io/github/downloads/VirtoCommerce/vc-storefront/total.svg?colorB=007ec6)](https://github.com/VirtoCommerce/vc-storefront/releases) [![License](https://img.shields.io/badge/license-VC%20OSL-blue.svg)](https://virtocommerce.com/open-source-license) - [![CI status](https://github.com/VirtoCommerce/vc-storefront/workflows/Storefront%20CI/badge.svg?branch=dev)](https://github.com/VirtoCommerce/vc-storefront/actions?query=workflow%3A"Storefront+CI") [![Quality gate](https://sonarcloud.io/api/project_badges/measure?project=VirtoCommerce_vc-storefront&metric=alert_status&branch=dev)](https://sonarcloud.io/dashboard?id=VirtoCommerce_vc-storefront) [![Reliability rating](https://sonarcloud.io/api/project_badges/measure?project=VirtoCommerce_vc-storefront&metric=reliability_rating&branch=dev)](https://sonarcloud.io/dashboard?id=VirtoCommerce_vc-storefront) [![Security rating](https://sonarcloud.io/api/project_badges/measure?project=VirtoCommerce_vc-storefront&metric=security_rating&branch=dev)](https://sonarcloud.io/dashboard?id=VirtoCommerce_vc-storefront) [![Sqale rating](https://sonarcloud.io/api/project_badges/measure?project=VirtoCommerce_vc-storefront&metric=sqale_rating&branch=dev)](https://sonarcloud.io/dashboard?id=VirtoCommerce_vc-storefront) [![Lines of code](https://sonarcloud.io/api/project_badges/measure?project=VirtoCommerce_vc-storefront&branch=dev&metric=ncloc)](https://sonarcloud.io/api/project_badges/measure?project=VirtoCommerce_vc-storefront&branch=dev&metric=ncloc)  -[![Documentation](https://img.shields.io/badge/docs-read-brightgreen.svg)](https://virtocommerce.com/docs/latest/) [![Discourse topics](https://img.shields.io/discourse/topics?label=community&logo=community&server=http%3A%2F%2Fwww.virtocommerce.org)](https://www.virtocommerce.org) [![Contributors](https://img.shields.io/github/contributors/VirtoCommerce/vc-storefront.svg)](https://github.com/VirtoCommerce/vc-storefront/graphs/contributors) - [![Deploy to Azure](https://aka.ms/deploytoazurebutton)](https://portal.azure.com/#create/Microsoft.Template/uri/https%3A%2F%2Fraw.githubusercontent.com%2FVirtoCommerce%2Fvc-storefront%2Fmaster%2Fazuredeploy.json) -Official online shopping website based on [Virto Commerce Platform written on ASP.NET Core](https://virtocommerce.com/microsoft-ecommerce-platform). The website is a client application for VC Platform and uses only public APIs while communicating. +The Virto Commerce Storefront Kit is the official online shopping website based on the Virto Commerce Platform, written on ASP.NET 8. The website serves as a client application for the VC Platform and communicates solely through public APIs. -It is possible to run multiple different stores (web sites) on top of Virto Commerce. Each store (website) might have its own theme with a specific layout still being based on the same catalog and customer data. +The Storefront Kit enables the creation of multiple distinct stores (websites) on top of the Virto Commerce Platform. Each store may have its own theme with specific layouts, yet still be based on the same catalog and customer data. This allows for versatile store configurations, such as: -It is possible, for example, to create sites with a different design for different product categories still having all products in the same backend. +* Different designs for various product categories. +* Regional-specific sites offering tailored product sets. +* Integration with multiple touchpoints for a true omnichannel experience. -Another option is to create different sites for different regions so that a specific product set will be available to a specific region, is still based on one product data. - -It is also possible to connect Virto Commerce to multiple touchpoints so that customers will get a real omnichannel experience. ## Key features +- Launch and host e-commerce themes on top of the Virto Commerce Platform. +- XAPI Gateway. +- Caching mechanism. +- Multi-store support. +- Multi-theme support. +- Server-side rendering. +And more. -- Multi-Store support -- Multi-Language support -- Multi-Currency support -- Multi-Themes support -- Faceted search support -- SEO friendly routing -- Server-side rendering -- Client-side rendering -- Optimization for Desktop -- Optimization for Tables -- Optimization for Mobile - -## Business Requirements - -- Home page -- Catalog browsing -- Product page -- Cart -- Bulk add to cart -- Multiple Whish lists and Mark favorites -- Product compare -- Anonymous Checkout process -- Checkout process -- Address verification -- Integration with Tax providers -- Integration Shippment and Payment methods -- Place orders -- Order Approve process -- Offers -- My Account -- My Orders History -- Reorder -- New Account verification -- Self-registration -- Forgot password -- User permissions to manage their own account page -- Catalog personalization -- Price personalization (List and Sales prices) -- Promotions -- Coupons -- Recommended products -- Banner and dynamic content -- User Groups - to build personalization -- Configurable Branding and customization -- Configurable navigation -- CMS to build Static, Landing, Blog pages - -## References - -- [Public Demo](https://st-storefront.demo.govirto.com/) -- Virto Commerce Documentation: -- Home: -- Community: -- [Download Latest Release](https://github.com/VirtoCommerce/vc-storefront/releases/latest) - -## Sample themes - -### [B2B theme](https://github.com/VirtoCommerce/vc-theme-b2b-vue) - -View [B2B theme on GitHub](https://github.com/VirtoCommerce/vc-theme-b2b-vue). - -![image](https://user-images.githubusercontent.com/7639413/170992875-fbfa2093-ebbf-4404-8140-c952d9f0f0f4.png) +## Architecture +For detailed information about the Virto Storefront Architecture, please refer to our [developer guide](https://docs.virtocommerce.org/storefront/developer-guide/) ## Technologies and frameworks used +- ASP.NET 8 +- ASP.NET Identity Core -- ASP.NET MVC Core 6.0 on .NET 60 -- ASP.NET Identity Core 3.1.0 -- GraphQL - -## Prerequisites -- Install `vc-platform` 3.x the latest version. [Deploy on Windows](https://github.com/VirtoCommerce/vc-platform/blob/master/docs/getting-started/deploy-from-precompiled-binaries-windows.md) or [Deploy on Linux](https://github.com/VirtoCommerce/vc-platform/blob/master/docs/getting-started/deploy-from-precompiled-binaries-linux.md) -- Install `vc-module-experience-api` module. [Getting started](https://github.com/VirtoCommerce/vc-module-experience-api/blob/dev/docs/getting-started.md) -- Install [vc-module-profile-experience-api](https://github.com/VirtoCommerce/vc-module-profile-experience-api) module. -- Install [Node](https://nodejs.org/en/download/) v.16.X -- Install [yarn](https://classic.yarnpkg.com/lang/en/docs/install/#windows-stable) package manager - ``` - npm install --global yarn - ``` - -## Continuous Integration Supported by Browserstack +## Setup +For detailed setup information, please refer to [Quick Start](https://docs.virtocommerce.org/storefront/developer-guide/getting-started/quickstart-on-windows/) to deploy and run. -Cross-browser compatibility of the storefront is generously provided by [Browserstack](https://www.browserstack.com/). -[![Browserstack](https://images.techhive.com/images/article/2014/12/browserstack-logo-100538202-medium.idge.png)](http://browserstack.com/) +## Themes -## Deploy Storefront +### B2B Theme -> If Platform and Storefront are deployed in the same on-premises environment, Storefront should be deployed on different port then Platform. You can do it by `dotnet run CLI` - -### Install the `vc-storefront` - -- Download [latest release](https://github.com/VirtoCommerce/vc-storefront/releases/latest) and unpack in to a local folder -- Or Clone [https://github.com/VirtoCommerce/vc-storefront](https://github.com/VirtoCommerce/vc-storefront) in to a local folder - -- Open the **appsettings.json** file in a text editor. -- In the **Endpoint** section change **Url**, **UserName**, **Password** with correct path and credentials for Virto Commerce Platform: - -```json -... - "Endpoint": { - "Url": "https://localhost:5001", - "UserName": "admin", - "Password": "store", -``` - -### Setup `B2B Mercury theme` - -```bash -# Clone repo into the folder where storefront is installed -git clone https://github.com/VirtoCommerce/vc-theme-b2b-vue.git "C:\vc-storefront\VirtoCommerce.Storefront\wwwroot\cms-content\themes\{store-name}\default" -# Change the current directory -cd C:\vc-storefront\VirtoCommerce.Storefront\wwwroot\cms-content\themes\{store-name}\default -# install dependencies -yarn -# Start theme in development mode with HMR support -yarn dev -# or build theme to get installable artifact -yarn compress -``` +View [B2B theme on GitHub](https://github.com/VirtoCommerce/vc-theme-b2b-vue). -### Run `vc-storefront` application +![image](https://user-images.githubusercontent.com/7639413/170992875-fbfa2093-ebbf-4404-8140-c952d9f0f0f4.png) -```bash -# change the current directory -cd C:\vc-storefront\VirtoCommerce.Storefront -# build and run storefront application -dotnet run -# In future, if you don't need to rebuild you can use that -dotnet run --no-build -``` ### FAQ @@ -187,6 +78,13 @@ To forward the scheme from the proxy in non-IIS scenarios, set `ASPNETCORE_FORWA For more details on how it works, see the Microsoft [documentation](https://docs.microsoft.com/en-us/aspnet/core/host-and-deploy/proxy-load-balancer?view=aspnetcore-5.0#forward-the-scheme-for-linux-and-non-iis-reverse-proxies). +## References +- Virto Commerce Documentation: https://docs.virtocommerce.org +- Home: https://virtocommerce.com +- Community: https://www.virtocommerce.org +- [Download Latest Release](https://github.com/VirtoCommerce/vc-storefront/releases/latest) + + ## License Copyright (c) Virto Solutions LTD. All rights reserved. diff --git a/VirtoCommerce.LiquidThemeEngine/Exceptions/SaasCompileException.cs b/VirtoCommerce.LiquidThemeEngine/Exceptions/SaasCompileException.cs index ed6acc735..fe02df726 100644 --- a/VirtoCommerce.LiquidThemeEngine/Exceptions/SaasCompileException.cs +++ b/VirtoCommerce.LiquidThemeEngine/Exceptions/SaasCompileException.cs @@ -7,8 +7,8 @@ namespace DotLiquid.ViewEngine.Exceptions [Serializable] public class SaasCompileException : Exception { - protected SaasCompileException(SerializationInfo info, - StreamingContext context) : base(info, context) + [Obsolete(DiagnosticId = "SYSLIB0051")] + protected SaasCompileException(SerializationInfo info, StreamingContext context) : base(info, context) { SassLine = info.GetString("SassLine"); } @@ -62,6 +62,7 @@ private static string ReadLine(string text, int lineNumber) return (currentLineNumber == lineNumber) ? line : string.Empty; } + [Obsolete(DiagnosticId = "SYSLIB0051")] public override void GetObjectData(SerializationInfo info, StreamingContext context) { base.GetObjectData(info, context); diff --git a/VirtoCommerce.LiquidThemeEngine/VirtoCommerce.LiquidThemeEngine.csproj b/VirtoCommerce.LiquidThemeEngine/VirtoCommerce.LiquidThemeEngine.csproj index 1a5e46726..29c5328fe 100644 --- a/VirtoCommerce.LiquidThemeEngine/VirtoCommerce.LiquidThemeEngine.csproj +++ b/VirtoCommerce.LiquidThemeEngine/VirtoCommerce.LiquidThemeEngine.csproj @@ -1,7 +1,6 @@ - - net6.0 + net8.0 The storefront implementation of the Virto Commerce platform. https://virtocommerce.com/open-source-license https://github.com/VirtoCommerce/vc-storefront-core @@ -10,30 +9,23 @@ False Library - - - - - - - - + + + + + + - + - - - - - - + \ No newline at end of file diff --git a/VirtoCommerce.Storefront.Model/Common/Exceptions/StorefrontException.cs b/VirtoCommerce.Storefront.Model/Common/Exceptions/StorefrontException.cs index a015eff76..a34bb3dfd 100644 --- a/VirtoCommerce.Storefront.Model/Common/Exceptions/StorefrontException.cs +++ b/VirtoCommerce.Storefront.Model/Common/Exceptions/StorefrontException.cs @@ -8,8 +8,8 @@ public class StorefrontException : Exception { public string View { get; set; } - protected StorefrontException(SerializationInfo info, - StreamingContext context) : base(info, context) + [Obsolete(DiagnosticId = "SYSLIB0051")] + protected StorefrontException(SerializationInfo info, StreamingContext context) : base(info, context) { View = info.GetString("View"); } @@ -34,6 +34,7 @@ public StorefrontException(string message, Exception innerException, string view View = view; } + [Obsolete(DiagnosticId = "SYSLIB0051")] public override void GetObjectData(SerializationInfo info, StreamingContext context) { base.GetObjectData(info, context); diff --git a/VirtoCommerce.Storefront.Model/Features/Exceptions/FeaturesException.cs b/VirtoCommerce.Storefront.Model/Features/Exceptions/FeaturesException.cs index 6ee7f95bc..df80c475f 100644 --- a/VirtoCommerce.Storefront.Model/Features/Exceptions/FeaturesException.cs +++ b/VirtoCommerce.Storefront.Model/Features/Exceptions/FeaturesException.cs @@ -6,8 +6,8 @@ namespace VirtoCommerce.Storefront.Model.Features.Exceptions [Serializable] public class FeaturesException : Exception { - protected FeaturesException(SerializationInfo info, - StreamingContext context) : base(info, context) + [Obsolete(DiagnosticId = "SYSLIB0051")] + protected FeaturesException(SerializationInfo info, StreamingContext context) : base(info, context) { } diff --git a/VirtoCommerce.Storefront.Model/VirtoCommerce.Storefront.Model.csproj b/VirtoCommerce.Storefront.Model/VirtoCommerce.Storefront.Model.csproj index 0b214877f..d4069aab8 100644 --- a/VirtoCommerce.Storefront.Model/VirtoCommerce.Storefront.Model.csproj +++ b/VirtoCommerce.Storefront.Model/VirtoCommerce.Storefront.Model.csproj @@ -1,7 +1,6 @@ - - net6.0 + net8.0 @@ -14,14 +13,11 @@ False Library - - + - + - - - + \ No newline at end of file diff --git a/VirtoCommerce.Storefront.Tests/VirtoCommerce.Storefront.Tests.csproj b/VirtoCommerce.Storefront.Tests/VirtoCommerce.Storefront.Tests.csproj index 27e740ddc..167c035a9 100644 --- a/VirtoCommerce.Storefront.Tests/VirtoCommerce.Storefront.Tests.csproj +++ b/VirtoCommerce.Storefront.Tests/VirtoCommerce.Storefront.Tests.csproj @@ -1,43 +1,38 @@ - - net6.0 - + net8.0 false - - + runtime; build; native; contentfiles; analyzers; buildtransitive all - - - - - - - + + + + + + + - - - + + + all runtime; build; native; contentfiles; analyzers - + all runtime; build; native; contentfiles; analyzers - - + - Always @@ -61,5 +56,4 @@ Always - - + \ No newline at end of file diff --git a/VirtoCommerce.Storefront/Caching/Redis/RedisStorefrontMemoryCache.cs b/VirtoCommerce.Storefront/Caching/Redis/RedisStorefrontMemoryCache.cs index 5c9c8d6ac..c2758f971 100644 --- a/VirtoCommerce.Storefront/Caching/Redis/RedisStorefrontMemoryCache.cs +++ b/VirtoCommerce.Storefront/Caching/Redis/RedisStorefrontMemoryCache.cs @@ -19,7 +19,7 @@ internal class RedisStorefrontMemoryCache : StorefrontMemoryCache private readonly ISubscriber _bus; private readonly RedisCachingOptions _redisCachingOptions; private readonly StorefrontOptions _storefrontOptions; - private readonly IConnectionMultiplexer _connection; + private readonly ConnectionMultiplexer _connection; private readonly ILogger _log; private bool _isSubscribed; @@ -52,7 +52,7 @@ private void CacheCancellableTokensRegistry_OnTokenCancelled(TokenCancelledEvent protected virtual void OnConnectionFailed(object sender, ConnectionFailedEventArgs e) { - _log.LogError($"Redis disconnected from instance { _instanceId }. Endpoint is {e.EndPoint}, failure type is {e.FailureType}"); + _log.LogError($"Redis disconnected from instance {_instanceId}. Endpoint is {e.EndPoint}, failure type is {e.FailureType}"); // If we have no connection to Redis, we can't invalidate cache on another platform instances, // so the better idea is to disable cache at all for data consistence @@ -64,7 +64,7 @@ protected virtual void OnConnectionFailed(object sender, ConnectionFailedEventAr protected virtual void OnConnectionRestored(object sender, ConnectionFailedEventArgs e) { - _log.LogTrace($"Redis backplane connection restored for instance { _instanceId }"); + _log.LogTrace($"Redis backplane connection restored for instance {_instanceId}"); // Return cache to the same state as it was initially. // Don't set directly true because it may be disabled in app settings @@ -116,10 +116,15 @@ protected override void EvictionCallback(object key, object value, EvictionReaso base.EvictionCallback(key, value, reason, state); } + protected virtual RedisChannel GetRedisChannel() + { + return RedisChannel.Literal(_redisCachingOptions.ChannelName); + } + private void Publish(RedisCachingMessage message) { EnsureRedisServerConnection(); - _bus.Publish(_redisCachingOptions.ChannelName, JsonConvert.SerializeObject(message), CommandFlags.FireAndForget); + _bus.Publish(GetRedisChannel(), JsonConvert.SerializeObject(message), CommandFlags.FireAndForget); } private void EnsureRedisServerConnection() @@ -133,9 +138,9 @@ private void EnsureRedisServerConnection() _connection.ConnectionFailed += OnConnectionFailed; _connection.ConnectionRestored += OnConnectionRestored; - _bus.Subscribe(_redisCachingOptions.ChannelName, OnMessage, CommandFlags.FireAndForget); + _bus.Subscribe(GetRedisChannel(), OnMessage, CommandFlags.FireAndForget); - _log.LogTrace($"Successfully subscribed to Redis backplane channel {_redisCachingOptions.ChannelName } with instance id:{ _instanceId }"); + _log.LogTrace($"Successfully subscribed to Redis backplane channel {_redisCachingOptions.ChannelName} with instance id:{_instanceId}"); _isSubscribed = true; } } @@ -149,7 +154,7 @@ protected override void Dispose(bool disposing) { if (disposing) { - _bus.Unsubscribe(_redisCachingOptions.ChannelName, null, CommandFlags.FireAndForget); + _bus.Unsubscribe(GetRedisChannel(), null, CommandFlags.FireAndForget); _connection.ConnectionFailed -= OnConnectionFailed; _connection.ConnectionRestored -= OnConnectionRestored; } diff --git a/VirtoCommerce.Storefront/Domain/Security/SecurityConverter.cs b/VirtoCommerce.Storefront/Domain/Security/SecurityConverter.cs index 61e243dd5..18be62462 100644 --- a/VirtoCommerce.Storefront/Domain/Security/SecurityConverter.cs +++ b/VirtoCommerce.Storefront/Domain/Security/SecurityConverter.cs @@ -2,14 +2,14 @@ using Microsoft.AspNetCore.Identity; using VirtoCommerce.Storefront.Model.Common; using VirtoCommerce.Storefront.Model.Security; -using dto = VirtoCommerce.Storefront.AutoRestClients.PlatformModuleApi.Models; +using Dto = VirtoCommerce.Storefront.AutoRestClients.PlatformModuleApi.Models; namespace VirtoCommerce.Storefront.Domain.Security { public static class SecurityConverter { - public static IdentityResult ToIdentityResult(this dto.SecurityResult resultDto) + public static IdentityResult ToIdentityResult(this Dto.SecurityResult resultDto) { if (resultDto.Succeeded == true) { @@ -18,16 +18,16 @@ public static IdentityResult ToIdentityResult(this dto.SecurityResult resultDto) return IdentityResult.Failed(resultDto.Errors.Select(x => new IdentityError { Description = x }).ToArray()); } - public static dto.Role ToRoleDto(this Role role) + public static Dto.Role ToRoleDto(this Role role) { - return new dto.Role + return new Dto.Role { Id = role.Id, Name = role.Name, - Permissions = role.Permissions.Select(x => new dto.Permission { Id = x, Name = x }).ToList() + Permissions = role.Permissions.Select(x => new Dto.Permission { Id = x, Name = x }).ToList() }; } - public static Role ToRole(this dto.Role roleDto) + public static Role ToRole(this Dto.Role roleDto) { return new Role { @@ -72,7 +72,7 @@ public static User ToUser(this UserRegistration registerForm) return result; } - public static User ToUser(this dto.ApplicationUser userDto) + public static User ToUser(this Dto.ApplicationUser userDto) { var result = new User() { @@ -121,9 +121,9 @@ public static User ToUser(this dto.ApplicationUser userDto) return result; } - public static dto.ApplicationUser ToUserDto(this User user) + public static Dto.ApplicationUser ToUserDto(this User user) { - var result = new dto.ApplicationUser + var result = new Dto.ApplicationUser { Id = user.Id, Email = user.Email, @@ -155,7 +155,7 @@ public static dto.ApplicationUser ToUserDto(this User user) } if (!user.ExternalLogins.IsNullOrEmpty()) { - result.Logins = user.ExternalLogins.Select(x => new dto.ApplicationUserLogin + result.Logins = user.ExternalLogins.Select(x => new Dto.ApplicationUserLogin { LoginProvider = x.LoginProvider, ProviderKey = x.ProviderKey diff --git a/VirtoCommerce.Storefront/Infrastructure/Exceptions/NoStoresException.cs b/VirtoCommerce.Storefront/Infrastructure/Exceptions/NoStoresException.cs index 2ffd5b87d..bb43f989d 100644 --- a/VirtoCommerce.Storefront/Infrastructure/Exceptions/NoStoresException.cs +++ b/VirtoCommerce.Storefront/Infrastructure/Exceptions/NoStoresException.cs @@ -7,8 +7,8 @@ namespace VirtoCommerce.Storefront.Infrastructure.Exceptions [Serializable] public class NoStoresException : StorefrontException { - protected NoStoresException(SerializationInfo info, - StreamingContext context) : base(info, context) + [Obsolete(DiagnosticId = "SYSLIB0051")] + protected NoStoresException(SerializationInfo info, StreamingContext context) : base(info, context) { } diff --git a/VirtoCommerce.Storefront/Infrastructure/Exceptions/NoThemeException.cs b/VirtoCommerce.Storefront/Infrastructure/Exceptions/NoThemeException.cs index 1040403c0..01a2a4098 100644 --- a/VirtoCommerce.Storefront/Infrastructure/Exceptions/NoThemeException.cs +++ b/VirtoCommerce.Storefront/Infrastructure/Exceptions/NoThemeException.cs @@ -7,8 +7,8 @@ namespace VirtoCommerce.Storefront.Infrastructure [Serializable] public class NoThemeException : StorefrontException { - protected NoThemeException(SerializationInfo info, - StreamingContext context) : base(info, context) + [Obsolete(DiagnosticId = "SYSLIB0051")] + protected NoThemeException(SerializationInfo info, StreamingContext context) : base(info, context) { } diff --git a/VirtoCommerce.Storefront/Middleware/WorkContextBuildMiddleware.cs b/VirtoCommerce.Storefront/Middleware/WorkContextBuildMiddleware.cs index db41af4f8..f4b1bd1db 100644 --- a/VirtoCommerce.Storefront/Middleware/WorkContextBuildMiddleware.cs +++ b/VirtoCommerce.Storefront/Middleware/WorkContextBuildMiddleware.cs @@ -72,9 +72,9 @@ public async Task Invoke(HttpContext context) if (workContext.IsPreviewMode) { - context.Response.Headers.Add("non-cached-result", "true"); + context.Response.Headers.Append("non-cached-result", "true"); } - + await _next(context); } } diff --git a/VirtoCommerce.Storefront/Startup.cs b/VirtoCommerce.Storefront/Startup.cs index 36dfbeb4c..bce128f5f 100644 --- a/VirtoCommerce.Storefront/Startup.cs +++ b/VirtoCommerce.Storefront/Startup.cs @@ -1,10 +1,8 @@ using System; using System.IO; using System.Linq; -using System.Net.Http; using System.Text.Encodings.Web; using System.Text.Unicode; -using System.Threading.Tasks; using FluentValidation.AspNetCore; using GraphQL.Client.Abstractions; using GraphQL.Client.Http; @@ -293,9 +291,10 @@ public void ConfigureServices(IServiceCollection services) options.SerializerSettings.NullValueHandling = NullValueHandling.Ignore; options.SerializerSettings.ReferenceLoopHandling = ReferenceLoopHandling.Ignore; options.SerializerSettings.MissingMemberHandling = MissingMemberHandling.Ignore; - }) - .AddFluentValidation(); + }); + services.AddFluentValidationAutoValidation(); + services.AddFluentValidationClientsideAdapters(); // Register event handlers via reflection services.RegisterAssembliesEventHandlers(typeof(Startup)); @@ -426,7 +425,7 @@ public void Configure(IApplicationBuilder app, IWebHostEnvironment env) // Enable browser XSS protection app.Use(async (context, next) => { - context.Response.Headers["X-Xss-Protection"] = "1"; + context.Response.Headers.XXSSProtection = "1"; await next(); }); diff --git a/VirtoCommerce.Storefront/VirtoCommerce.Storefront.csproj b/VirtoCommerce.Storefront/VirtoCommerce.Storefront.csproj index 6d49eff93..fe3a49f69 100644 --- a/VirtoCommerce.Storefront/VirtoCommerce.Storefront.csproj +++ b/VirtoCommerce.Storefront/VirtoCommerce.Storefront.csproj @@ -1,26 +1,23 @@ - - net6.0 + net8.0 ..\docker-compose.dcproj 0cd403c4-2cd0-42b3-987a-02900f4a683e The storefront implementation of the Virto Commerce platform. https://virtocommerce.com/open-source-license https://github.com/VirtoCommerce/vc-storefront https://github.com/VirtoCommerce/vc-storefront - https://virtocommerce.com/themes/assets/logo.jpg - + + 3.1 - true 1701;1702;1591;1573;1570 - @@ -30,68 +27,60 @@ - Always - - - - - - - - - + + + + + + + + - - - - + + + - + - + all runtime; build; native; contentfiles; analyzers - + - - + + - + - - - - - - + \ No newline at end of file diff --git a/azuredeploy.json b/azuredeploy.json index fe4e86d23..1e5a9cd6b 100644 --- a/azuredeploy.json +++ b/azuredeploy.json @@ -122,9 +122,10 @@ "metadata": [ { "name": "CURRENT_STACK", - "value": "dotnetcore" + "value": "dotnet" } - ] + ], + "netFrameworkVersion": "v8.0" } }, "resources": [