diff --git a/Directory.Build.props b/Directory.Build.props index 340a75f33b7..f0e8124a5d9 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -15,6 +15,10 @@ $(NoWarn);S3875;S4457 + + true + + $(VersionPrefix) diff --git a/VirtoCommerce.Platform.sln.DotSettings b/VirtoCommerce.Platform.sln.DotSettings index fc91addd8bf..c81792632ba 100644 --- a/VirtoCommerce.Platform.sln.DotSettings +++ b/VirtoCommerce.Platform.sln.DotSettings @@ -2,6 +2,7 @@ UI <Policy Inspect="True" Prefix="_" Suffix="" Style="aaBb" /> <Policy><Descriptor Staticness="Static" AccessRightKinds="Private" Description="Static readonly fields (private)"><ElementKinds><Kind Name="READONLY_FIELD" /></ElementKinds></Descriptor><Policy Inspect="True" Prefix="_" Suffix="" Style="aaBb" /></Policy> + <Policy><Descriptor Staticness="Any" AccessRightKinds="Private" Description="Constant fields (private)"><ElementKinds><Kind Name="CONSTANT_FIELD" /></ElementKinds></Descriptor><Policy Inspect="True" Prefix="_" Suffix="" Style="aaBb" /></Policy> True True True diff --git a/module.ignore b/module.ignore index 314bbf67bf1..e77ae7cba43 100644 --- a/module.ignore +++ b/module.ignore @@ -1,7 +1,6 @@ Azure.Core.dll Azure.Data.AppConfiguration.dll Azure.Identity.dll -Azure.Messaging.EventGrid.dll Azure.Security.KeyVault.Secrets.dll Dapper.dll DnsClient.dll @@ -20,13 +19,6 @@ Hangfire.SqlServer.dll Humanizer.dll MessagePack.Annotations.dll MessagePack.dll -Microsoft.AI.DependencyCollector.dll -Microsoft.AI.EventCounterCollector.dll -Microsoft.AI.PerfCounterCollector.dll -Microsoft.AI.ServerTelemetryChannel.dll -Microsoft.AI.WindowsServer.dll -Microsoft.ApplicationInsights.AspNetCore.dll -Microsoft.ApplicationInsights.dll Microsoft.AspNetCore.Authentication.JwtBearer.dll Microsoft.AspNetCore.Authentication.OpenIdConnect.dll Microsoft.AspNetCore.Authorization.dll @@ -84,7 +76,6 @@ Microsoft.Extensions.Http.Polly.dll Microsoft.Extensions.Identity.Core.dll Microsoft.Extensions.Identity.Stores.dll Microsoft.Extensions.Logging.Abstractions.dll -Microsoft.Extensions.Logging.ApplicationInsights.dll Microsoft.Extensions.Logging.AzureAppServices.dll Microsoft.Extensions.Options.dll Microsoft.Extensions.PlatformAbstractions.dll @@ -165,7 +156,6 @@ System.Composition.Runtime.dll System.Composition.TypedParts.dll System.Configuration.ConfigurationManager.dll System.Data.SqlClient.dll -System.Diagnostics.PerformanceCounter.dll System.Drawing.Common.dll System.IdentityModel.Tokens.Jwt.dll System.IO.Abstractions.dll diff --git a/src/VirtoCommerce.Platform.Caching/Redis/RedisCachingOptions.cs b/src/VirtoCommerce.Platform.Caching/Redis/RedisCachingOptions.cs index cf19e2cd5f1..46540c7b21e 100644 --- a/src/VirtoCommerce.Platform.Caching/Redis/RedisCachingOptions.cs +++ b/src/VirtoCommerce.Platform.Caching/Redis/RedisCachingOptions.cs @@ -1,12 +1,7 @@ -using System; - namespace VirtoCommerce.Platform.Redis { public class RedisCachingOptions { public string ChannelName { get; set; } - - [Obsolete("Use Redis connection string parameters for retry policy configration")] - public int BusRetryCount { get; set; } = 3; } } diff --git a/src/VirtoCommerce.Platform.Caching/VirtoCommerce.Platform.Caching.csproj b/src/VirtoCommerce.Platform.Caching/VirtoCommerce.Platform.Caching.csproj index ab5581d2b54..78ecf8ac92d 100644 --- a/src/VirtoCommerce.Platform.Caching/VirtoCommerce.Platform.Caching.csproj +++ b/src/VirtoCommerce.Platform.Caching/VirtoCommerce.Platform.Caching.csproj @@ -2,7 +2,7 @@ net8.0 - 1591 + 1591;NU5048 Library True true diff --git a/src/VirtoCommerce.Platform.Core/Caching/MemoryCacheExtensions.cs b/src/VirtoCommerce.Platform.Core/Caching/MemoryCacheExtensions.cs index 92c36de8cde..7b6f1fbd97f 100644 --- a/src/VirtoCommerce.Platform.Core/Caching/MemoryCacheExtensions.cs +++ b/src/VirtoCommerce.Platform.Core/Caching/MemoryCacheExtensions.cs @@ -29,7 +29,7 @@ public static async Task> GetOrLoadByIdsAsync( if (!TryGetByIds(memoryCache, keyPrefix, ids, out var result)) { - using (await AsyncLock.GetLockByKey(keyPrefix).GetReleaserAsync()) + using (await AsyncLock.GetLockByKey(keyPrefix).LockAsync()) { if (!TryGetByIds(memoryCache, keyPrefix, ids, out result)) { @@ -96,7 +96,7 @@ public static async Task GetOrCreateExclusiveAsync(this IMemoryCac { if (!cache.TryGetValue(key, out var result)) { - using (await AsyncLock.GetLockByKey(key).GetReleaserAsync()) + using (await AsyncLock.GetLockByKey(key).LockAsync()) { if (!cache.TryGetValue(key, out result)) { diff --git a/src/VirtoCommerce.Platform.Core/Common/AsyncLock.cs b/src/VirtoCommerce.Platform.Core/Common/AsyncLock.cs index 11d3886531c..5a34df250b9 100644 --- a/src/VirtoCommerce.Platform.Core/Common/AsyncLock.cs +++ b/src/VirtoCommerce.Platform.Core/Common/AsyncLock.cs @@ -16,9 +16,9 @@ public AsyncLock(string key) _key = key; } - private static readonly Dictionary> _semaphoreSlims = new Dictionary>(); + private static readonly Dictionary> _semaphoreSlims = new(); - private SemaphoreSlim GetOrCreate(string key) + private static SemaphoreSlim GetOrCreate(string key) { RefCounted item; lock (_semaphoreSlims) @@ -41,22 +41,19 @@ public static AsyncLock GetLockByKey(string key) return new AsyncLock(key); } - // TODO: Rename to LockAsync after resolving problem with backward compatibility - // in the modules (look on this ticket https://virtocommerce.atlassian.net/browse/PT-3548) - public async Task GetReleaserAsync() + [Obsolete("Use LockAsync()", DiagnosticId = "VC0009", UrlFormat = "https://docs.virtocommerce.org/products/products-virto3-versions")] + public Task GetReleaserAsync() { - await GetOrCreate(_key).WaitAsync().ConfigureAwait(false); - return new Releaser(_key); + return LockAsync(); } - [Obsolete("Left for backward compatibility. Use GetReleaserAsync")] - public async Task LockAsync() + public async Task LockAsync() { await GetOrCreate(_key).WaitAsync().ConfigureAwait(false); return new Releaser(_key); } - public struct Releaser : IDisposable + public readonly struct Releaser : IDisposable { private readonly string _key; @@ -90,7 +87,7 @@ public RefCounted(T value) } public int RefCount { get; set; } - public T Value { get; private set; } + public T Value { get; } } } } diff --git a/src/VirtoCommerce.Platform.Core/Common/MigrationName.cs b/src/VirtoCommerce.Platform.Core/Common/MigrationName.cs index 91a1b6c99f0..a6a343f5758 100644 --- a/src/VirtoCommerce.Platform.Core/Common/MigrationName.cs +++ b/src/VirtoCommerce.Platform.Core/Common/MigrationName.cs @@ -1,12 +1,10 @@ -using System; - namespace VirtoCommerce.Platform.Core.Common { public static class MigrationName { /// /// It's important thing of naming for correct migration to v.3 - /// The migration of update from v.2 should be apply at the first + /// The migration from v.2 should be applied first /// /// /// 20000000000000_UpdateModuleNameV2 @@ -14,11 +12,5 @@ public static string GetUpdateV2MigrationName(string moduleName) { return $"20000000000000_Update{moduleName.Replace(".", "").Replace("VirtoCommerce", "")}V2"; } - - [Obsolete("use GetUpdateV2MigrationName")] - public static string GetUpdateV2MigrationNameByOwnerName(string moduleName, string ownerName) - { - return GetUpdateV2MigrationName(moduleName); - } } } diff --git a/src/VirtoCommerce.Platform.Core/DynamicProperties/IDynamicPropertyDictionaryItemsSearchService.cs b/src/VirtoCommerce.Platform.Core/DynamicProperties/IDynamicPropertyDictionaryItemsSearchService.cs index cdc7b0f3588..af88324d9e3 100644 --- a/src/VirtoCommerce.Platform.Core/DynamicProperties/IDynamicPropertyDictionaryItemsSearchService.cs +++ b/src/VirtoCommerce.Platform.Core/DynamicProperties/IDynamicPropertyDictionaryItemsSearchService.cs @@ -1,12 +1,8 @@ -using System; -using System.Threading.Tasks; using VirtoCommerce.Platform.Core.GenericCrud; namespace VirtoCommerce.Platform.Core.DynamicProperties { public interface IDynamicPropertyDictionaryItemsSearchService : ISearchService { - [Obsolete("Use SearchAsync()", DiagnosticId = "VC0005", UrlFormat = "https://docs.virtocommerce.org/products/products-virto3-versions/")] - Task SearchDictionaryItemsAsync(DynamicPropertyDictionaryItemSearchCriteria criteria); } } diff --git a/src/VirtoCommerce.Platform.Core/DynamicProperties/IDynamicPropertySearchService.cs b/src/VirtoCommerce.Platform.Core/DynamicProperties/IDynamicPropertySearchService.cs index 641a7c49b21..f62910a15af 100644 --- a/src/VirtoCommerce.Platform.Core/DynamicProperties/IDynamicPropertySearchService.cs +++ b/src/VirtoCommerce.Platform.Core/DynamicProperties/IDynamicPropertySearchService.cs @@ -1,12 +1,8 @@ -using System; -using System.Threading.Tasks; using VirtoCommerce.Platform.Core.GenericCrud; namespace VirtoCommerce.Platform.Core.DynamicProperties { public interface IDynamicPropertySearchService : ISearchService { - [Obsolete("Use SearchAsync()", DiagnosticId = "VC0005", UrlFormat = "https://docs.virtocommerce.org/products/products-virto3-versions/")] - Task SearchDynamicPropertiesAsync(DynamicPropertySearchCriteria criteria); } } diff --git a/src/VirtoCommerce.Platform.Core/Exceptions/SettingsTypeNotRegisteredException.cs b/src/VirtoCommerce.Platform.Core/Exceptions/SettingsTypeNotRegisteredException.cs deleted file mode 100644 index 6f2df978962..00000000000 --- a/src/VirtoCommerce.Platform.Core/Exceptions/SettingsTypeNotRegisteredException.cs +++ /dev/null @@ -1,13 +0,0 @@ -using System; - -namespace VirtoCommerce.Platform.Core.Exceptions -{ - [Obsolete("Not used in the platform, will be removed when migrating to a new version of .net")] - public class SettingsTypeNotRegisteredException : PlatformException - { - public SettingsTypeNotRegisteredException(string settingsType) - : base($"Settings for type: {settingsType} not registered, please register it first") - { - } - } -} diff --git a/src/VirtoCommerce.Platform.Core/Extensions/CrudServiceExtensions.cs b/src/VirtoCommerce.Platform.Core/Extensions/CrudServiceExtensions.cs index 10d2c95faa4..70f0c27d8eb 100644 --- a/src/VirtoCommerce.Platform.Core/Extensions/CrudServiceExtensions.cs +++ b/src/VirtoCommerce.Platform.Core/Extensions/CrudServiceExtensions.cs @@ -1,4 +1,3 @@ -using System; using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; @@ -38,11 +37,4 @@ public static async Task GetByIdAsync(this ICrudService return entities?.FirstOrDefault(); } - - [Obsolete("Use GetAsync() or GetNoCloneAsync()")] - public static Task> GetByIdsAsync(this ICrudService crudService, IList ids, string responseGroup = null, bool clone = true) - where TModel : Entity - { - return crudService.GetAsync(ids, responseGroup, clone); - } } diff --git a/src/VirtoCommerce.Platform.Core/Extensions/SearchServiceExtensions.cs b/src/VirtoCommerce.Platform.Core/Extensions/SearchServiceExtensions.cs index c97347b6bec..31a23bcabe6 100644 --- a/src/VirtoCommerce.Platform.Core/Extensions/SearchServiceExtensions.cs +++ b/src/VirtoCommerce.Platform.Core/Extensions/SearchServiceExtensions.cs @@ -1,4 +1,3 @@ -using System; using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; @@ -45,24 +44,6 @@ public static Task SearchNoCloneAsync(this return searchService.SearchAsync(searchCriteria, clone: false); } - [Obsolete("Use SearchBatchesNoCloneAsync()", DiagnosticId = "VC0005", UrlFormat = "https://docs.virtocommerce.org/products/products-virto3-versions/")] - public static IAsyncEnumerable SearchBatchesNoClone(this ISearchService searchService, TCriteria searchCriteria) - where TCriteria : SearchCriteriaBase - where TResult : GenericSearchResult - where TModel : Entity, ICloneable - { - return searchService.SearchBatchesNoCloneAsync(searchCriteria); - } - - [Obsolete("Use SearchBatchesAsync()", DiagnosticId = "VC0005", UrlFormat = "https://docs.virtocommerce.org/products/products-virto3-versions/")] - public static IAsyncEnumerable SearchBatches(this ISearchService searchService, TCriteria searchCriteria, bool clone = true) - where TCriteria : SearchCriteriaBase - where TResult : GenericSearchResult - where TModel : Entity, ICloneable - { - return searchService.SearchBatchesAsync(searchCriteria, clone); - } - /// /// Returns data from the cache without cloning. This consumes less memory, but the returned data must not be modified. /// diff --git a/src/VirtoCommerce.Platform.Core/Modularity/ModuleAttribute.cs b/src/VirtoCommerce.Platform.Core/Modularity/ModuleAttribute.cs index 1bcd72142a1..4343d0f7063 100644 --- a/src/VirtoCommerce.Platform.Core/Modularity/ModuleAttribute.cs +++ b/src/VirtoCommerce.Platform.Core/Modularity/ModuleAttribute.cs @@ -15,25 +15,11 @@ public sealed class ModuleAttribute : Attribute /// The name of the module. public string ModuleName { get; set; } - /// - /// Gets or sets a value indicating whether the module should be loaded at startup. - /// - /// When (default value), it indicates that this module should be loaded at startup. - /// Otherwise you should explicitly load this module on demand. - /// A value. - [Obsolete("StartupLoaded has been replaced by the OnDemand property.")] - public bool StartupLoaded - { - get { return !OnDemand; } - set { OnDemand = !value; } - } - - /// /// Gets or sets the value indicating whether the module should be loaded OnDemand. /// /// When (default value), it indicates the module should be loaded as soon as it's dependencies are satisfied. - /// Otherwise you should explicitily load this module via the ModuleManager. + /// Otherwise, you should explicitly load this module via the ModuleManager. public bool OnDemand { get; set; } } } diff --git a/src/VirtoCommerce.Platform.Core/Notifications/DefaultEmailSender.cs b/src/VirtoCommerce.Platform.Core/Notifications/DefaultEmailSender.cs deleted file mode 100644 index 5904bb5e964..00000000000 --- a/src/VirtoCommerce.Platform.Core/Notifications/DefaultEmailSender.cs +++ /dev/null @@ -1,13 +0,0 @@ -using System.Threading.Tasks; - -namespace VirtoCommerce.Platform.Core.Notifications -{ - public class DefaultEmailSender : IEmailSender - { - public Task SendEmailAsync(string email, string subject, string message) - { - //nothing to do - return Task.CompletedTask; - } - } -} diff --git a/src/VirtoCommerce.Platform.Core/Notifications/IEmailSender.cs b/src/VirtoCommerce.Platform.Core/Notifications/IEmailSender.cs deleted file mode 100644 index 34611efe366..00000000000 --- a/src/VirtoCommerce.Platform.Core/Notifications/IEmailSender.cs +++ /dev/null @@ -1,11 +0,0 @@ -using System; -using System.Threading.Tasks; - -namespace VirtoCommerce.Platform.Core.Notifications -{ - [Obsolete("Use notification module instead")] - public interface IEmailSender - { - Task SendEmailAsync(string email, string subject, string message); - } -} diff --git a/src/VirtoCommerce.Platform.Core/PlatformConstants.cs b/src/VirtoCommerce.Platform.Core/PlatformConstants.cs index 6289b980999..26b10fa76f3 100644 --- a/src/VirtoCommerce.Platform.Core/PlatformConstants.cs +++ b/src/VirtoCommerce.Platform.Core/PlatformConstants.cs @@ -24,10 +24,12 @@ public static class Claims public const string UserNameClaimType = "username"; public const string LimitedPermissionsClaimType = "limited_permissions"; public const string MemberIdClaimType = "memberId"; + /// - /// Represents Operator User Id after impersonation + /// Represents Operator User ID after impersonation /// public const string OperatorUserId = "vc_operator_user_id"; + /// /// Represents Operator User Name after impersonation /// @@ -45,42 +47,42 @@ public static class Permissions { public const string ResetCache = "cache:reset"; - public const string AssetAccess = "platform:asset:access", - AssetDelete = "platform:asset:delete", - AssetUpdate = "platform:asset:update", - AssetCreate = "platform:asset:create", - AssetRead = "platform:asset:read"; - - public const string ModuleQuery = "platform:module:read", - ModuleAccess = "platform:module:access", - ModuleManage = "platform:module:manage"; - - public const string SettingQuery = "platform:setting:read", - SettingAccess = "platform:setting:access", - SettingUpdate = "platform:setting:update"; - - public const string DynamicPropertiesQuery = "platform:dynamic_properties:read", - DynamicPropertiesCreate = "platform:dynamic_properties:create", - DynamicPropertiesAccess = "platform:dynamic_properties:access", - DynamicPropertiesUpdate = "platform:dynamic_properties:update", - DynamicPropertiesDelete = "platform:dynamic_properties:delete"; - - public const string SecurityQuery = "platform:security:read", - SecurityCreate = "platform:security:create", - SecurityAccess = "platform:security:access", - SecurityUpdate = "platform:security:update", - SecurityDelete = "platform:security:delete", - SecurityVerifyEmail = "platform:security:verifyEmail", - SecurityLoginOnBehalf = "platform:security:loginOnBehalf", - SecurityConfirmEmail = "platform:security:confirmEmail", - SecurityGenerateToken = "platform:security:generateToken", - SecurityVerifyToken = "platform:security:verifyToken"; + public const string AssetAccess = "platform:asset:access"; + public const string AssetDelete = "platform:asset:delete"; + public const string AssetUpdate = "platform:asset:update"; + public const string AssetCreate = "platform:asset:create"; + public const string AssetRead = "platform:asset:read"; + + public const string ModuleQuery = "platform:module:read"; + public const string ModuleAccess = "platform:module:access"; + public const string ModuleManage = "platform:module:manage"; + + public const string SettingQuery = "platform:setting:read"; + public const string SettingAccess = "platform:setting:access"; + public const string SettingUpdate = "platform:setting:update"; + + public const string DynamicPropertiesQuery = "platform:dynamic_properties:read"; + public const string DynamicPropertiesCreate = "platform:dynamic_properties:create"; + public const string DynamicPropertiesAccess = "platform:dynamic_properties:access"; + public const string DynamicPropertiesUpdate = "platform:dynamic_properties:update"; + public const string DynamicPropertiesDelete = "platform:dynamic_properties:delete"; + + public const string SecurityQuery = "platform:security:read"; + public const string SecurityCreate = "platform:security:create"; + public const string SecurityAccess = "platform:security:access"; + public const string SecurityUpdate = "platform:security:update"; + public const string SecurityDelete = "platform:security:delete"; + public const string SecurityVerifyEmail = "platform:security:verifyEmail"; + public const string SecurityLoginOnBehalf = "platform:security:loginOnBehalf"; + public const string SecurityConfirmEmail = "platform:security:confirmEmail"; + public const string SecurityGenerateToken = "platform:security:generateToken"; + public const string SecurityVerifyToken = "platform:security:verifyToken"; public const string BackgroundJobsManage = "background_jobs:manage"; - public const string PlatformExportImportAccess = "platform:exportImport:access", - PlatformImport = "platform:import", - PlatformExport = "platform:export"; + public const string PlatformExportImportAccess = "platform:exportImport:access"; + public const string PlatformImport = "platform:import"; + public const string PlatformExport = "platform:export"; public static string[] AllPermissions { get; } = new[] { ResetCache, AssetAccess, AssetDelete, AssetUpdate, AssetCreate, AssetRead, ModuleQuery, ModuleAccess, ModuleManage, SettingQuery, SettingAccess, SettingUpdate, DynamicPropertiesQuery, DynamicPropertiesCreate, DynamicPropertiesAccess, DynamicPropertiesUpdate, DynamicPropertiesDelete, @@ -447,21 +449,6 @@ public static IEnumerable AllSettings } } - public static class Other - { - [Obsolete("Use PlatformConstants.Settings.Security.AccountStatuses", DiagnosticId = "VC0005", UrlFormat = "https://docs.virtocommerce.org/products/products-virto3-versions/")] - public static SettingDescriptor AccountStatuses => Security.AccountStatuses; - - [Obsolete("Use PlatformConstants.Settings.Security.AllSettings", DiagnosticId = "VC0005", UrlFormat = "https://docs.virtocommerce.org/products/products-virto3-versions/")] - public static IEnumerable AllSettings - { - get - { - yield return AccountStatuses; - } - } - } - public static IEnumerable AllSettings => General.AllGeneralSettings .Concat(Security.AllSettings) diff --git a/src/VirtoCommerce.Platform.Core/Security/AccountState.cs b/src/VirtoCommerce.Platform.Core/Security/AccountState.cs deleted file mode 100644 index 880dc513ed3..00000000000 --- a/src/VirtoCommerce.Platform.Core/Security/AccountState.cs +++ /dev/null @@ -1,12 +0,0 @@ -namespace VirtoCommerce.Platform.Core.Security -{ - /// - /// Obsolete. Left due to compatibility issues. Will be removed. Instead of, use: ApplicationUser.EmailConfirmed, ApplicationUser.LockoutEnd. - /// - public enum AccountState - { - PendingApproval, - Approved, - Rejected - } -} diff --git a/src/VirtoCommerce.Platform.Core/Security/ApplicationUser.cs b/src/VirtoCommerce.Platform.Core/Security/ApplicationUser.cs index d429efacc00..c798269d9f5 100644 --- a/src/VirtoCommerce.Platform.Core/Security/ApplicationUser.cs +++ b/src/VirtoCommerce.Platform.Core/Security/ApplicationUser.cs @@ -2,8 +2,6 @@ using System.Collections.Generic; using System.Linq; using Microsoft.AspNetCore.Identity; -using Newtonsoft.Json; -using Newtonsoft.Json.Converters; using VirtoCommerce.Platform.Core.Common; using VirtoCommerce.Platform.Core.Utils.ChangeDetector; @@ -16,17 +14,17 @@ public class ApplicationUser : IdentityUser, IEntity, IAuditable, ICloneable /// public virtual string StoreId { get; set; } - [DetectChangesAttribute(PlatformConstants.Security.Changes.UserUpdated)] + [DetectChanges(PlatformConstants.Security.Changes.UserUpdated)] public virtual string MemberId { get; set; } - [DetectChangesAttribute(PlatformConstants.Security.Changes.UserUpdated)] + [DetectChanges(PlatformConstants.Security.Changes.UserUpdated)] public virtual bool IsAdministrator { get; set; } public virtual string PhotoUrl { get; set; } - [DetectChangesAttribute(PlatformConstants.Security.Changes.UserUpdated)] + [DetectChanges(PlatformConstants.Security.Changes.UserUpdated)] public virtual string UserType { get; set; } - [DetectChangesAttribute(PlatformConstants.Security.Changes.UserUpdated)] + [DetectChanges(PlatformConstants.Security.Changes.UserUpdated)] public virtual string Status { get; set; } public virtual string Password { get; set; } public virtual DateTime CreatedDate { get; set; } @@ -38,32 +36,6 @@ public class ApplicationUser : IdentityUser, IEntity, IAuditable, ICloneable [SwaggerIgnore] public virtual ICollection> UserRoles { get; set; } - /// - /// Obsolete. Use LockoutEnd. DateTime in UTC when lockout ends, any time in the past is considered not locked out. - /// - [Obsolete("Left due to compatibility issues. Use LockoutEnd")] - public virtual DateTime? LockoutEndDateUtc - { - get - { - return LockoutEnd?.UtcDateTime; - } - set - { - LockoutEnd = value; - } - } - - [Obsolete("Left due to compatibility issues. Will be removed. Instead of, use properties: EmailConfirmed, LockoutEnd.")] - [JsonConverter(typeof(StringEnumConverter))] - public virtual AccountState UserState { get; set; } - - /// - /// Obsolete. All permissions from assigned roles. - /// - [Obsolete("Left due to compatibility issues")] - public virtual string[] Permissions { get; set; } - /// /// External provider logins. /// @@ -104,7 +76,6 @@ public virtual void Patch(ApplicationUser target) target.TwoFactorEnabled = TwoFactorEnabled; target.LockoutEnabled = LockoutEnabled; target.LockoutEnd = LockoutEnd; - target.UserState = UserState; target.AccessFailedCount = AccessFailedCount; target.MemberId = MemberId; @@ -158,7 +129,7 @@ public virtual ListDictionary DetectUserChanges(ApplicationUser public virtual object Clone() { - var result = MemberwiseClone() as ApplicationUser; + var result = (ApplicationUser)MemberwiseClone(); result.Roles = Roles?.Select(x => x.Clone()).OfType().ToList(); diff --git a/src/VirtoCommerce.Platform.Core/Security/IUserPasswordHasher.cs b/src/VirtoCommerce.Platform.Core/Security/IUserPasswordHasher.cs deleted file mode 100644 index f16c9ab28c2..00000000000 --- a/src/VirtoCommerce.Platform.Core/Security/IUserPasswordHasher.cs +++ /dev/null @@ -1,13 +0,0 @@ -using System; -using Microsoft.AspNetCore.Identity; - -namespace VirtoCommerce.Platform.Core.Security -{ - /// - /// Basic interface for platform password hashers - /// - [Obsolete("Use IPasswordHasher instead. UserPasswordsHistory is available from ISecurityRepository")] - public interface IUserPasswordHasher : IPasswordHasher - { - } -} diff --git a/src/VirtoCommerce.Platform.Core/Security/Permission.cs b/src/VirtoCommerce.Platform.Core/Security/Permission.cs index dd98e4d8897..51b37a80b0b 100644 --- a/src/VirtoCommerce.Platform.Core/Security/Permission.cs +++ b/src/VirtoCommerce.Platform.Core/Security/Permission.cs @@ -1,4 +1,3 @@ -using System; using System.Collections.Generic; using System.Linq; using System.Security.Claims; @@ -7,25 +6,10 @@ namespace VirtoCommerce.Platform.Core.Security { - public class Permission : ValueObject, ICloneable + public class Permission : ValueObject { private const char _scopeCharSeparator = '|'; - [Obsolete("Left for backward compatibility")] - public string Id - { - get - { - return Name; - } -#pragma warning disable S3237 // "value" parameters should be used - set -#pragma warning restore S3237 // "value" parameters should be used - { - // Do not remove this empty set-accessor! It is needed for backward compatibility. - } - } - public string Name { get; set; } /// /// Id of the module which has registered this permission. @@ -98,7 +82,7 @@ public virtual void Patch(Permission target) #region ICloneable members public override object Clone() { - var result = MemberwiseClone() as Permission; + var result = (Permission)MemberwiseClone(); result.AssignedScopes = AssignedScopes?.Select(x => x.Clone()).OfType().ToList(); diff --git a/src/VirtoCommerce.Platform.Core/Security/Search/IUserApiKeySearchService.cs b/src/VirtoCommerce.Platform.Core/Security/Search/IUserApiKeySearchService.cs index be491359645..92cbc2e5117 100644 --- a/src/VirtoCommerce.Platform.Core/Security/Search/IUserApiKeySearchService.cs +++ b/src/VirtoCommerce.Platform.Core/Security/Search/IUserApiKeySearchService.cs @@ -1,12 +1,8 @@ -using System; -using System.Threading.Tasks; using VirtoCommerce.Platform.Core.GenericCrud; namespace VirtoCommerce.Platform.Core.Security.Search { public interface IUserApiKeySearchService : ISearchService { - [Obsolete("Use SearchAsync()", DiagnosticId = "VC0005", UrlFormat = "https://docs.virtocommerce.org/products/products-virto3-versions/")] - Task SearchUserApiKeysAsync(UserApiKeySearchCriteria criteria); } } diff --git a/src/VirtoCommerce.Platform.Core/Settings/ISettingsSearchService.cs b/src/VirtoCommerce.Platform.Core/Settings/ISettingsSearchService.cs index 9d44c5e2de8..ac8af5c62cc 100644 --- a/src/VirtoCommerce.Platform.Core/Settings/ISettingsSearchService.cs +++ b/src/VirtoCommerce.Platform.Core/Settings/ISettingsSearchService.cs @@ -1,13 +1,8 @@ -using System; -using System.Threading.Tasks; -using VirtoCommerce.Platform.Core.Common; using VirtoCommerce.Platform.Core.GenericCrud; namespace VirtoCommerce.Platform.Core.Settings { public interface ISettingsSearchService : ISearchService { - [Obsolete("Use SearchAsync()", DiagnosticId = "VC0005", UrlFormat = "https://docs.virtocommerce.org/products/products-virto3-versions/")] - Task> SearchSettingsAsync(SettingsSearchCriteria searchCriteria); } } diff --git a/src/VirtoCommerce.Platform.Core/Settings/SettingsExtension.cs b/src/VirtoCommerce.Platform.Core/Settings/SettingsExtension.cs index 7f3a6b04bc7..3d53f683ea4 100644 --- a/src/VirtoCommerce.Platform.Core/Settings/SettingsExtension.cs +++ b/src/VirtoCommerce.Platform.Core/Settings/SettingsExtension.cs @@ -120,18 +120,6 @@ public static async Task DeepRemoveSettingsAsync(this ISettingsManager manager, await manager.RemoveObjectSettingsAsync(foDeleteSettings); } - [Obsolete("Use GetValue<>(SettingDescriptor)")] - public static TValue GetValueByDescriptor(this ISettingsManager manager, SettingDescriptor descriptor) - { - return manager.GetValueAsync(descriptor).GetAwaiter().GetResult(); - } - - [Obsolete("Use GetValueAsync<>(SettingDescriptor)")] - public static Task GetValueByDescriptorAsync(this ISettingsManager manager, SettingDescriptor descriptor) - { - return manager.GetValueAsync(descriptor); - } - /// /// Takes default value from the setting descriptor /// @@ -155,18 +143,6 @@ public static Task GetValueAsync(this ISettingsManager manager, return manager.GetValueInternalAsync(descriptor.Name, defaultValue); } - [Obsolete("Use GetValue<>(SettingDescriptor)")] - public static T GetValue(this ISettingsManager manager, string name, T defaultValue) - { - return manager.GetValueInternalAsync(name, defaultValue).GetAwaiter().GetResult(); - } - - [Obsolete("Use GetValueAsync<>(SettingDescriptor)")] - public static Task GetValueAsync(this ISettingsManager manager, string name, T defaultValue) - { - return manager.GetValueInternalAsync(name, defaultValue); - } - private static async Task GetValueInternalAsync(this ISettingsManager manager, string name, T defaultValue) { var result = defaultValue; @@ -211,12 +187,6 @@ public static TValue GetValue(this IEnumerable objec return objectSettings.GetValueInternal(descriptor.Name, defaultValue); } - [Obsolete("Use GetValue<>(SettingDescriptor)", DiagnosticId = "VC0005", UrlFormat = "https://docs.virtocommerce.org/products/products-virto3-versions/")] - public static T GetSettingValue(this IEnumerable objectSettings, string settingName, T defaultValue) - { - return objectSettings.GetValueInternal(settingName, defaultValue); - } - private static T GetValueInternal(this IEnumerable objectSettings, string settingName, T defaultValue) { var retVal = defaultValue; diff --git a/src/VirtoCommerce.Platform.Core/Swagger/SwaggerPlatformOptions.cs b/src/VirtoCommerce.Platform.Core/Swagger/SwaggerPlatformOptions.cs index 3e6d09da2dd..712a659789f 100644 --- a/src/VirtoCommerce.Platform.Core/Swagger/SwaggerPlatformOptions.cs +++ b/src/VirtoCommerce.Platform.Core/Swagger/SwaggerPlatformOptions.cs @@ -1,21 +1,10 @@ -using System; - namespace VirtoCommerce.Platform.Core.Swagger { public class SwaggerPlatformOptions { /// - /// Disable swagger at the startup (switch off endpoints for swagger UI and docs) + /// Enable (default) or disable swagger at the startup (switch off endpoints for swagger UI and docs) /// - [Obsolete("Use Enable", DiagnosticId = "VC0005", UrlFormat = "https://docs.virtocommerce.org/products/products-virto3-versions/")] - public bool Disable - { - get => !Enable; - set => Enable = !value; - } - - // We want the Enable property to have a higher priority than Disable, - // so Enable should come after the Disable because of the implementation details of IConfiguration.Bind(). public bool Enable { get; set; } = true; } } diff --git a/src/VirtoCommerce.Platform.Core/Telemetry/ApplicationInsightsOptions.cs b/src/VirtoCommerce.Platform.Core/Telemetry/ApplicationInsightsOptions.cs deleted file mode 100644 index e90f4a8f060..00000000000 --- a/src/VirtoCommerce.Platform.Core/Telemetry/ApplicationInsightsOptions.cs +++ /dev/null @@ -1,42 +0,0 @@ -using System; - -namespace VirtoCommerce.Platform.Core.Telemetry -{ - - /// - /// ApplicationInsights options - /// - [Obsolete("Not used anymore. Moved to VirtoCommerce.ApplicationInsights module.")] - public class ApplicationInsightsOptions - { - /// - /// AppInsights sampling options - /// - public SamplingOptions SamplingOptions { get; set; } = new SamplingOptions(); - - /// - /// Enable SQL dependencies filtering ApplicationInsights processor - /// - public IgnoreSqlTelemetryOptions IgnoreSqlTelemetryOptions { get; set; } - - /// - /// Force SQL reflection in dependencies for ApplicationInsights - /// - public bool EnableLocalSqlCommandTextInstrumentation { get; set; } - - /// - /// Same as EnableLocalSqlCommandTextInstrumentation - /// - public bool EnableSqlCommandTextInstrumentation { get; set; } - - /// - /// Cloud Role Name - /// - public string RoleName { get; set; } - - /// - /// Cloud Role Instance - /// - public string RoleInstance { get; set; } - } -} diff --git a/src/VirtoCommerce.Platform.Core/Telemetry/FixedProcessorSettings.cs b/src/VirtoCommerce.Platform.Core/Telemetry/FixedProcessorSettings.cs deleted file mode 100644 index d313ba1b55a..00000000000 --- a/src/VirtoCommerce.Platform.Core/Telemetry/FixedProcessorSettings.cs +++ /dev/null @@ -1,18 +0,0 @@ -using System; - -namespace VirtoCommerce.Platform.Core.Telemetry -{ - /// - /// AppInsights settings for fixed sampling - /// - [Obsolete("Not used anymore. Moved to VirtoCommerce.ApplicationInsights module.")] - public class FixedProcessorSettings - { - /// - /// Data sampling percentage (between 0 and 100). - /// All sampling percentage must be in a ratio of 100/N where N is a whole number (2, 3, 4, …). E.g. 50 for 1/2 or 33.33 for 1/3. - /// Failure to follow this pattern can result in unexpected / incorrect computation of values in the portal. - /// - public double SamplingPercentage { get; set; } = 100; - } -} diff --git a/src/VirtoCommerce.Platform.Core/Telemetry/IgnoreSQLTelemetryOptions.cs b/src/VirtoCommerce.Platform.Core/Telemetry/IgnoreSQLTelemetryOptions.cs deleted file mode 100644 index 086cb98c4eb..00000000000 --- a/src/VirtoCommerce.Platform.Core/Telemetry/IgnoreSQLTelemetryOptions.cs +++ /dev/null @@ -1,10 +0,0 @@ -using System; - -namespace VirtoCommerce.Platform.Core.Telemetry -{ - [Obsolete("Not used anymore. Moved to VirtoCommerce.ApplicationInsights module.")] - public class IgnoreSqlTelemetryOptions - { - public string[] QueryIgnoreSubstrings { get; set; } = new string[] { }; - } -} diff --git a/src/VirtoCommerce.Platform.Core/Telemetry/SamplingOptions.cs b/src/VirtoCommerce.Platform.Core/Telemetry/SamplingOptions.cs deleted file mode 100644 index 17597b59903..00000000000 --- a/src/VirtoCommerce.Platform.Core/Telemetry/SamplingOptions.cs +++ /dev/null @@ -1,37 +0,0 @@ -using System; -using Microsoft.ApplicationInsights.WindowsServer.Channel.Implementation; - -namespace VirtoCommerce.Platform.Core.Telemetry -{ - /// - /// AppInsights sampling options - /// - [Obsolete("Not used anymore. Moved to VirtoCommerce.ApplicationInsights module.")] - public class SamplingOptions - { - /// - /// Type of sampling processor: adaptive or fixed. See https://docs.microsoft.com/en-us/azure/azure-monitor/app/sampling - /// - public SamplingProcessor Processor { get; set; } = SamplingProcessor.Adaptive; - /// - /// Adaptive sampling settings (if Processor==SamplingProcessor.Adaptive) - /// - public SamplingPercentageEstimatorSettings Adaptive { get; set; } = new SamplingPercentageEstimatorSettings(); - /// - /// Fixed sampling settings (if Processor==SamplingProcessor.Fixed) - /// - public FixedProcessorSettings Fixed { get; set; } = new FixedProcessorSettings(); - /// - /// A semi-colon delimited list of types that you do want to subject to sampling. - /// Recognized types are: Dependency, Event, Exception, PageView, Request, Trace. The specified types will be sampled. - /// All types included by default. - /// - public string IncludedTypes { get; set; } = "Dependency;Event;Exception;PageView;Request;Trace"; - /// - /// A semi-colon delimited list of types that you do not want to be subject to sampling. - /// Recognized types are: Dependency, Event, Exception, PageView, Request, Trace. - /// Empty by default. - /// - public string ExcludedTypes { get; set; } - } -} diff --git a/src/VirtoCommerce.Platform.Core/Telemetry/SamplingProcessor.cs b/src/VirtoCommerce.Platform.Core/Telemetry/SamplingProcessor.cs deleted file mode 100644 index 42fcc056106..00000000000 --- a/src/VirtoCommerce.Platform.Core/Telemetry/SamplingProcessor.cs +++ /dev/null @@ -1,11 +0,0 @@ -using System; - -namespace VirtoCommerce.Platform.Core.Telemetry -{ - [Obsolete("Not used anymore. Moved to VirtoCommerce.ApplicationInsights module.")] - public enum SamplingProcessor - { - Adaptive, - Fixed - } -} diff --git a/src/VirtoCommerce.Platform.Core/VirtoCommerce.Platform.Core.csproj b/src/VirtoCommerce.Platform.Core/VirtoCommerce.Platform.Core.csproj index 6ffc7c99c9b..1f08ecadf52 100644 --- a/src/VirtoCommerce.Platform.Core/VirtoCommerce.Platform.Core.csproj +++ b/src/VirtoCommerce.Platform.Core/VirtoCommerce.Platform.Core.csproj @@ -2,7 +2,7 @@ net8.0 - 1591 + 1591;NU5048 Library True @@ -23,11 +23,10 @@ - - + diff --git a/src/VirtoCommerce.Platform.Data.MySql/MySqlCertificateLoader.cs b/src/VirtoCommerce.Platform.Data.MySql/MySqlCertificateLoader.cs index dbce4527cc8..58b8719e731 100644 --- a/src/VirtoCommerce.Platform.Data.MySql/MySqlCertificateLoader.cs +++ b/src/VirtoCommerce.Platform.Data.MySql/MySqlCertificateLoader.cs @@ -17,7 +17,8 @@ public MySqlCertificateLoader(IConfiguration configuration) protected virtual string GetConnectionString() { return _configuration["Auth:ConnectionString"] ?? - _configuration.GetConnectionString("VirtoCommerce"); + _configuration.GetConnectionString("VirtoCommerce") ?? + string.Empty; } /// diff --git a/src/VirtoCommerce.Platform.Data.MySql/VirtoCommerce.Platform.Data.MySql.csproj b/src/VirtoCommerce.Platform.Data.MySql/VirtoCommerce.Platform.Data.MySql.csproj index 435345ef9f0..124cc8e90ce 100644 --- a/src/VirtoCommerce.Platform.Data.MySql/VirtoCommerce.Platform.Data.MySql.csproj +++ b/src/VirtoCommerce.Platform.Data.MySql/VirtoCommerce.Platform.Data.MySql.csproj @@ -4,10 +4,11 @@ net8.0 enable enable + NU5048 - + runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/src/VirtoCommerce.Platform.Data.PostgreSql/PostgreSqlCertificateLoader.cs b/src/VirtoCommerce.Platform.Data.PostgreSql/PostgreSqlCertificateLoader.cs index 53e50455b9f..84d7a6d9579 100644 --- a/src/VirtoCommerce.Platform.Data.PostgreSql/PostgreSqlCertificateLoader.cs +++ b/src/VirtoCommerce.Platform.Data.PostgreSql/PostgreSqlCertificateLoader.cs @@ -17,7 +17,8 @@ public PostgreSqlCertificateLoader(IConfiguration configuration) protected virtual string GetConnectionString() { return _configuration["Auth:ConnectionString"] ?? - _configuration.GetConnectionString("VirtoCommerce"); + _configuration.GetConnectionString("VirtoCommerce") ?? + string.Empty; } /// diff --git a/src/VirtoCommerce.Platform.Data.PostgreSql/VirtoCommerce.Platform.Data.PostgreSql.csproj b/src/VirtoCommerce.Platform.Data.PostgreSql/VirtoCommerce.Platform.Data.PostgreSql.csproj index 188063f9376..eb478ffd9c1 100644 --- a/src/VirtoCommerce.Platform.Data.PostgreSql/VirtoCommerce.Platform.Data.PostgreSql.csproj +++ b/src/VirtoCommerce.Platform.Data.PostgreSql/VirtoCommerce.Platform.Data.PostgreSql.csproj @@ -4,10 +4,11 @@ net8.0 enable enable + NU5048 - + runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/src/VirtoCommerce.Platform.Data.SqlServer/SqlServerCertificateLoader.cs b/src/VirtoCommerce.Platform.Data.SqlServer/SqlServerCertificateLoader.cs index 7a20cf68785..dd2a8fc3e72 100644 --- a/src/VirtoCommerce.Platform.Data.SqlServer/SqlServerCertificateLoader.cs +++ b/src/VirtoCommerce.Platform.Data.SqlServer/SqlServerCertificateLoader.cs @@ -1,8 +1,3 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; using Microsoft.Data.SqlClient; using Microsoft.Extensions.Configuration; using VirtoCommerce.Platform.Core.Security; @@ -22,7 +17,8 @@ public SqlServerCertificateLoader(IConfiguration configuration) protected virtual string GetConnectionString() { return _configuration["Auth:ConnectionString"] ?? - _configuration.GetConnectionString("VirtoCommerce"); + _configuration.GetConnectionString("VirtoCommerce") ?? + string.Empty; } /// @@ -36,7 +32,7 @@ protected virtual bool CheckDatabaseExist(string sourceConnectionString) var dbName = builder.InitialCatalog; // Catch database name to search from the connection string builder.Remove("Initial Catalog"); // Initial catalog should be removed from connection string, otherwise the connection could not be opened const string cmdCheckDb = - @"select 1 from [sys].[databases] where name=@dbname"; + "select 1 from [sys].[databases] where name=@dbname"; var connectionString = builder.ConnectionString; using var conn = new SqlConnection(connectionString); @@ -61,7 +57,7 @@ public ServerCertificate Load() if (CheckDatabaseExist(connectionString)) { const string cmdCheckMigration = - @"select 1 from [sys].[tables] where name='ServerCertificate'"; + "select 1 from [sys].[tables] where name='ServerCertificate'"; const string cmdServerCert = @"SELECT TOP (1) [Id] @@ -106,7 +102,7 @@ public ServerCertificate Load() // If there is no certificate in DB and certificate is present in files // then load from files. - // Otherwise left it empty with default virto-cert number. + // Otherwise, left it empty with default virto-cert number. // Default certificate will be replaced later by self-signed if (!result.StoredInDb && !string.IsNullOrEmpty(publicCertPath) && diff --git a/src/VirtoCommerce.Platform.Data.SqlServer/VirtoCommerce.Platform.Data.SqlServer.csproj b/src/VirtoCommerce.Platform.Data.SqlServer/VirtoCommerce.Platform.Data.SqlServer.csproj index 795659f0db1..ac13b2e61e4 100644 --- a/src/VirtoCommerce.Platform.Data.SqlServer/VirtoCommerce.Platform.Data.SqlServer.csproj +++ b/src/VirtoCommerce.Platform.Data.SqlServer/VirtoCommerce.Platform.Data.SqlServer.csproj @@ -4,13 +4,14 @@ net8.0 enable enable + NU5048 - + runtime; build; native; contentfiles; analyzers; buildtransitive - + diff --git a/src/VirtoCommerce.Platform.Data/DynamicProperties/DynamicPropertyDictionaryItemsSearchService.cs b/src/VirtoCommerce.Platform.Data/DynamicProperties/DynamicPropertyDictionaryItemsSearchService.cs index 4a78b38d41d..67edec5569b 100644 --- a/src/VirtoCommerce.Platform.Data/DynamicProperties/DynamicPropertyDictionaryItemsSearchService.cs +++ b/src/VirtoCommerce.Platform.Data/DynamicProperties/DynamicPropertyDictionaryItemsSearchService.cs @@ -24,12 +24,6 @@ public DynamicPropertyDictionaryItemsSearchService(Func rep _dynamicPropertyDictionaryItemsService = dynamicPropertyDictionaryItemsService; } - [Obsolete("Use SearchAsync()", DiagnosticId = "VC0005", UrlFormat = "https://docs.virtocommerce.org/products/products-virto3-versions/")] - public virtual Task SearchDictionaryItemsAsync(DynamicPropertyDictionaryItemSearchCriteria criteria) - { - return SearchAsync(criteria, clone: true); - } - public virtual async Task SearchAsync(DynamicPropertyDictionaryItemSearchCriteria criteria, bool clone = true) { var cacheKey = CacheKey.With(GetType(), "SearchDictionaryItemsAsync", criteria.GetHashCode().ToString()); diff --git a/src/VirtoCommerce.Platform.Data/DynamicProperties/DynamicPropertySearchService.cs b/src/VirtoCommerce.Platform.Data/DynamicProperties/DynamicPropertySearchService.cs index ec4bd6eadc6..c2cf8a14d7c 100644 --- a/src/VirtoCommerce.Platform.Data/DynamicProperties/DynamicPropertySearchService.cs +++ b/src/VirtoCommerce.Platform.Data/DynamicProperties/DynamicPropertySearchService.cs @@ -24,16 +24,6 @@ public DynamicPropertySearchService(Func repositoryFactory, _memoryCache = memoryCache; } - - #region IDynamicPropertySearchService members - - - [Obsolete("Use SearchAsync()", DiagnosticId = "VC0005", UrlFormat = "https://docs.virtocommerce.org/products/products-virto3-versions/")] - public virtual Task SearchDynamicPropertiesAsync(DynamicPropertySearchCriteria criteria) - { - return SearchAsync(criteria, clone: true); - } - public Task SearchAsync(DynamicPropertySearchCriteria criteria, bool clone = true) { var cacheKey = CacheKey.With(GetType(), "SearchDynamicPropertiesAsync", criteria.GetCacheKey()); @@ -86,6 +76,5 @@ public Task SearchAsync(DynamicPropertySearchCriter return result; }); } - #endregion } } diff --git a/src/VirtoCommerce.Platform.Data/ExportImport/JsonSerializerExtensions.cs b/src/VirtoCommerce.Platform.Data/ExportImport/JsonSerializerExtensions.cs deleted file mode 100644 index abe913ea7ca..00000000000 --- a/src/VirtoCommerce.Platform.Data/ExportImport/JsonSerializerExtensions.cs +++ /dev/null @@ -1,71 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Threading.Tasks; -using Newtonsoft.Json; -using VirtoCommerce.Platform.Core.Common; - -namespace VirtoCommerce.Platform.Data.ExportImport -{ - public static class JsonSerializerExtensions - { - public const int DefaultPageSize = 50; - - [Obsolete("Use VirtoCommerce.Platform.Core.ExportImport.JsonSerializerExtensions.SerializeArrayWithPagingAsync()")] - public static async Task SerializeJsonArrayWithPagingAsync(this JsonTextWriter writer, JsonSerializer serializer, int pageSize, Func>> pagedDataLoader, Action progressCallback, ICancellationToken cancellationToken) - { - //Evaluate total items counts - var result = await pagedDataLoader(0, 1); - - var totalCount = result.TotalCount; - - await writer.WriteStartArrayAsync(); - - // Prevent infinity loop - if (pageSize <= 0) - { - pageSize = DefaultPageSize; - } - - for (var i = 0; i < totalCount; i += pageSize) - { - var nextPage = await pagedDataLoader(i, pageSize); - foreach (var data in nextPage.Results) - { - cancellationToken.ThrowIfCancellationRequested(); - serializer.Serialize(writer, data); - } - await writer.FlushAsync(); - progressCallback(Math.Min(totalCount, i + pageSize), totalCount); - } - await writer.WriteEndArrayAsync(); - } - - [Obsolete("Use VirtoCommerce.Platform.Core.ExportImport.JsonSerializerExtensions.DeserializeArrayWithPagingAsync()")] - public static async Task DeserializeJsonArrayWithPagingAsync(this JsonTextReader reader, JsonSerializer serializer, int pageSize, Func, Task> action, Action progressCallback, ICancellationToken cancellationToken) - { - await reader.ReadAsync(); - if (reader.TokenType == JsonToken.StartArray) - { - await reader.ReadAsync(); - - var items = new List(); - var processedCount = 0; - while (reader.TokenType != JsonToken.EndArray) - { - cancellationToken.ThrowIfCancellationRequested(); - - var item = serializer.Deserialize(reader); - items.Add(item); - processedCount++; - await reader.ReadAsync(); - if (processedCount % pageSize == 0 || reader.TokenType == JsonToken.EndArray) - { - await action(items); - items.Clear(); - progressCallback(processedCount); - } - } - } - } - } -} diff --git a/src/VirtoCommerce.Platform.Data/Extensions/ServiceCollectionExtensions.cs b/src/VirtoCommerce.Platform.Data/Extensions/ServiceCollectionExtensions.cs index e8e3cd76ef6..b7bbe61724e 100644 --- a/src/VirtoCommerce.Platform.Data/Extensions/ServiceCollectionExtensions.cs +++ b/src/VirtoCommerce.Platform.Data/Extensions/ServiceCollectionExtensions.cs @@ -10,7 +10,6 @@ using VirtoCommerce.Platform.Core.ExportImport; using VirtoCommerce.Platform.Core.GenericCrud; using VirtoCommerce.Platform.Core.Localizations; -using VirtoCommerce.Platform.Core.Notifications; using VirtoCommerce.Platform.Core.TransactionFileManager; using VirtoCommerce.Platform.Core.ZipFile; using VirtoCommerce.Platform.Data.ChangeLog; @@ -52,9 +51,6 @@ public static IServiceCollection AddPlatformServices(this IServiceCollection ser services.AddScoped(); services.AddSingleton(); - services.AddTransient(); - - //Register dependencies for translation services.AddSingleton(); services.AddSingleton(); diff --git a/src/VirtoCommerce.Platform.Data/Settings/SettingsSearchService.cs b/src/VirtoCommerce.Platform.Data/Settings/SettingsSearchService.cs index ccd1be2c353..65c7d1c2d69 100644 --- a/src/VirtoCommerce.Platform.Data/Settings/SettingsSearchService.cs +++ b/src/VirtoCommerce.Platform.Data/Settings/SettingsSearchService.cs @@ -1,4 +1,3 @@ -using System; using System.Linq; using System.Threading.Tasks; using VirtoCommerce.Platform.Core.Common; @@ -15,12 +14,6 @@ public SettingsSearchService(ISettingsManager settingsManager) _settingsManager = settingsManager; } - [Obsolete("Use SearchAsync()", DiagnosticId = "VC0005", UrlFormat = "https://docs.virtocommerce.org/products/products-virto3-versions/")] - public async Task> SearchSettingsAsync(SettingsSearchCriteria criteria) - { - return await SearchAsync(criteria, clone: true); - } - public async Task SearchAsync(SettingsSearchCriteria criteria, bool clone = true) { var result = AbstractTypeFactory.TryCreateInstance(); diff --git a/src/VirtoCommerce.Platform.Data/VirtoCommerce.Platform.Data.csproj b/src/VirtoCommerce.Platform.Data/VirtoCommerce.Platform.Data.csproj index 40b93a21c10..fa5ee3a087b 100644 --- a/src/VirtoCommerce.Platform.Data/VirtoCommerce.Platform.Data.csproj +++ b/src/VirtoCommerce.Platform.Data/VirtoCommerce.Platform.Data.csproj @@ -2,7 +2,7 @@ net8.0 - 1591 + 1591;NU5048 Library True true @@ -21,11 +21,11 @@ - - + + runtime; build; native; contentfiles; analyzers; buildtransitive - + diff --git a/src/VirtoCommerce.Platform.DistributedLock/VirtoCommerce.Platform.DistributedLock.csproj b/src/VirtoCommerce.Platform.DistributedLock/VirtoCommerce.Platform.DistributedLock.csproj index 6eb38d99e5d..d7288484130 100644 --- a/src/VirtoCommerce.Platform.DistributedLock/VirtoCommerce.Platform.DistributedLock.csproj +++ b/src/VirtoCommerce.Platform.DistributedLock/VirtoCommerce.Platform.DistributedLock.csproj @@ -2,7 +2,7 @@ net8.0 - 1591 + 1591;NU5048 Library True diff --git a/src/VirtoCommerce.Platform.Hangfire/Extensions/ApplicationBuilderExtensions.cs b/src/VirtoCommerce.Platform.Hangfire/Extensions/ApplicationBuilderExtensions.cs index d1aefdb3d3b..e6328509191 100644 --- a/src/VirtoCommerce.Platform.Hangfire/Extensions/ApplicationBuilderExtensions.cs +++ b/src/VirtoCommerce.Platform.Hangfire/Extensions/ApplicationBuilderExtensions.cs @@ -27,7 +27,7 @@ public static IApplicationBuilder UseHangfire(this IApplicationBuilder appBuilde // This is an important workaround of Hangfire initialization issues // The standard database schema initialization way described at the page https://docs.hangfire.io/en/latest/configuration/using-sql-server.html works on an existing database only. - // Therefore we create SqlServerStorage for Hangfire manually here. + // Therefore, we create SqlServerStorage for Hangfire manually here. // This way we ensure Hangfire schema will be applied to storage AFTER platform database creation. var hangfireOptions = appBuilder.ApplicationServices.GetRequiredService>().Value; if (hangfireOptions.JobStorageType == HangfireJobStorageType.SqlServer || @@ -40,19 +40,20 @@ public static IApplicationBuilder UseHangfire(this IApplicationBuilder appBuilde switch (databaseProvider) { case "PostgreSql": - storage = new PostgreSqlStorage(connectionString, hangfireOptions.PostgreSqlStorageOptions); + hangfireGlobalConfiguration.UsePostgreSqlStorage(options => + options.UseNpgsqlConnection(connectionString), hangfireOptions.PostgreSqlStorageOptions); break; case "MySql": storage = new MySqlStorage(connectionString, hangfireOptions.MySqlStorageOptions); + hangfireGlobalConfiguration.UseStorage(storage); break; default: storage = new SqlServerStorage(connectionString, hangfireOptions.SqlServerStorageOptions); + hangfireGlobalConfiguration.UseStorage(storage); break; } - hangfireGlobalConfiguration.UseStorage(storage); hangfireGlobalConfiguration.UseConsole(); - } appBuilder.UseHangfireDashboard("/hangfire", new DashboardOptions { Authorization = new[] { new HangfireAuthorizationHandler() } }); diff --git a/src/VirtoCommerce.Platform.Hangfire/RecurringJobService.cs b/src/VirtoCommerce.Platform.Hangfire/RecurringJobService.cs index 4277a49f39e..7a4de5da8ad 100644 --- a/src/VirtoCommerce.Platform.Hangfire/RecurringJobService.cs +++ b/src/VirtoCommerce.Platform.Hangfire/RecurringJobService.cs @@ -93,12 +93,20 @@ private async Task RunOrRemoveJobAsync(SettingCronJob settingCronJob) { var cronExpression = await _settingsManager.GetValueAsync(settingCronJob.CronSetting); + var options = new RecurringJobOptions + { + TimeZone = settingCronJob.TimeZone, +#pragma warning disable CS0618 // Type or member is obsolete + // Remove when Hangfire.MySqlStorage will be updated to support JobStorageFeatures.JobQueueProperty + QueueName = settingCronJob.Queue, +#pragma warning restore CS0618 // Type or member is obsolete + }; + _recurringJobManager.AddOrUpdate( settingCronJob.RecurringJobId, settingCronJob.Job, cronExpression, - settingCronJob.TimeZone, - settingCronJob.Queue); + options); } else { diff --git a/src/VirtoCommerce.Platform.Hangfire/SettingCronJobBuilder.cs b/src/VirtoCommerce.Platform.Hangfire/SettingCronJobBuilder.cs index 9506b351933..9c8e528a64f 100644 --- a/src/VirtoCommerce.Platform.Hangfire/SettingCronJobBuilder.cs +++ b/src/VirtoCommerce.Platform.Hangfire/SettingCronJobBuilder.cs @@ -58,7 +58,8 @@ public SettingCronJobBuilder SetTimeZoneInfo(TimeZoneInfo timeZoneInfo) public SettingCronJobBuilder ToJob(Expression> methodCall) { - _settingCronJob.Job = Job.FromExpression(methodCall); + // Uncomment when Hangfire.MySqlStorage will be updated to support JobStorageFeatures.JobQueueProperty + _settingCronJob.Job = Job.FromExpression(methodCall/*, _settingCronJob.Queue*/); _settingCronJob.RecurringJobId ??= $"{_settingCronJob.Job.Type.Name}.{_settingCronJob.Job.Method.Name}"; return this; } diff --git a/src/VirtoCommerce.Platform.Hangfire/VirtoCommerce.Platform.Hangfire.csproj b/src/VirtoCommerce.Platform.Hangfire/VirtoCommerce.Platform.Hangfire.csproj index 77f63813a8c..85d3b376f06 100644 --- a/src/VirtoCommerce.Platform.Hangfire/VirtoCommerce.Platform.Hangfire.csproj +++ b/src/VirtoCommerce.Platform.Hangfire/VirtoCommerce.Platform.Hangfire.csproj @@ -2,7 +2,7 @@ net8.0 - 1591 + 1591;NU5048 Library True @@ -26,7 +26,7 @@ - + diff --git a/src/VirtoCommerce.Platform.Modules/External/ExternalModulesClient.cs b/src/VirtoCommerce.Platform.Modules/External/ExternalModulesClient.cs index f5e545fd6b8..f6f023d4241 100644 --- a/src/VirtoCommerce.Platform.Modules/External/ExternalModulesClient.cs +++ b/src/VirtoCommerce.Platform.Modules/External/ExternalModulesClient.cs @@ -1,7 +1,8 @@ using System; using System.IO; -using System.Net; +using System.Net.Http; using Microsoft.Extensions.Options; +using Microsoft.Net.Http.Headers; using VirtoCommerce.Platform.Core.Modularity; namespace VirtoCommerce.Platform.Modules.External @@ -9,33 +10,41 @@ namespace VirtoCommerce.Platform.Modules.External public class ExternalModulesClient : IExternalModulesClient { private readonly ExternalModuleCatalogOptions _options; + private readonly IHttpClientFactory _httpClientFactory; - public ExternalModulesClient(IOptions options) + public ExternalModulesClient(IOptions options, IHttpClientFactory httpClientFactory) { + _httpClientFactory = httpClientFactory; _options = options.Value; } public Stream OpenRead(Uri address) { - using (var webClient = new WebClient()) + var httpClient = _httpClientFactory.CreateClient(); + + var request = new HttpRequestMessage(HttpMethod.Get, address) { - webClient.Headers[HttpRequestHeader.UserAgent] = "Virto Commerce Manager"; + Version = httpClient.DefaultRequestVersion, + VersionPolicy = httpClient.DefaultVersionPolicy, + Headers = { { HeaderNames.UserAgent, "Virto Commerce Manager" } }, + }; - if (!string.IsNullOrEmpty(_options.AuthorizationToken)) - { - webClient.Headers[HttpRequestHeader.Accept] = "application/octet-stream"; - webClient.Headers[HttpRequestHeader.Authorization] = "Token " + _options.AuthorizationToken; - } + if (!string.IsNullOrEmpty(_options.AuthorizationToken)) + { + request.Headers.Add(HeaderNames.Accept, "application/octet-stream"); + request.Headers.Add(HeaderNames.Authorization, "Token " + _options.AuthorizationToken); + } - if (!string.IsNullOrEmpty(_options.AuthorizationSchema) && - !string.IsNullOrEmpty(_options.AuthorizationParameter)) - { - webClient.Headers[HttpRequestHeader.Authorization] = $"{_options.AuthorizationSchema} {_options.AuthorizationParameter}"; - } + if (!string.IsNullOrEmpty(_options.AuthorizationSchema) && + !string.IsNullOrEmpty(_options.AuthorizationParameter)) + { + request.Headers.Add(HeaderNames.Authorization, $"{_options.AuthorizationSchema} {_options.AuthorizationParameter}"); + } + var response = httpClient.Send(request, HttpCompletionOption.ResponseHeadersRead); + response.EnsureSuccessStatusCode(); - return webClient.OpenRead(address); - } + return response.Content.ReadAsStream(); } } } diff --git a/src/VirtoCommerce.Platform.Modules/VirtoCommerce.Platform.Modules.csproj b/src/VirtoCommerce.Platform.Modules/VirtoCommerce.Platform.Modules.csproj index 89f181a0861..28ac235a108 100644 --- a/src/VirtoCommerce.Platform.Modules/VirtoCommerce.Platform.Modules.csproj +++ b/src/VirtoCommerce.Platform.Modules/VirtoCommerce.Platform.Modules.csproj @@ -2,7 +2,7 @@ net8.0 - 1591 + 1591;NU5048 Library True true diff --git a/src/VirtoCommerce.Platform.Security.MySql/Migrations/20221124131800_Initial.Designer.cs b/src/VirtoCommerce.Platform.Security.MySql/Migrations/20221124131800_Initial.Designer.cs deleted file mode 100644 index a11259dbed2..00000000000 --- a/src/VirtoCommerce.Platform.Security.MySql/Migrations/20221124131800_Initial.Designer.cs +++ /dev/null @@ -1,680 +0,0 @@ -// -using System; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Migrations; -using Microsoft.EntityFrameworkCore.Storage.ValueConversion; -using VirtoCommerce.Platform.Security.Repositories; - -#nullable disable - -namespace VirtoCommerce.Platform.Security.MySql.Migrations -{ - [DbContext(typeof(SecurityDbContext))] - [Migration("20221124131800_Initial")] - partial class Initial - { - protected override void BuildTargetModel(ModelBuilder modelBuilder) - { -#pragma warning disable 612, 618 - modelBuilder - .HasAnnotation("ProductVersion", "6.0.0") - .HasAnnotation("Relational:MaxIdentifierLength", 64); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("ClaimType") - .HasColumnType("longtext"); - - b.Property("ClaimValue") - .HasColumnType("longtext"); - - b.Property("RoleId") - .IsRequired() - .HasMaxLength(128) - .HasColumnType("varchar(128)"); - - b.HasKey("Id"); - - b.HasIndex("RoleId"); - - b.ToTable("AspNetRoleClaims", (string)null); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("ClaimType") - .HasColumnType("longtext"); - - b.Property("ClaimValue") - .HasColumnType("longtext"); - - b.Property("UserId") - .IsRequired() - .HasMaxLength(128) - .HasColumnType("varchar(128)"); - - b.HasKey("Id"); - - b.HasIndex("UserId"); - - b.ToTable("AspNetUserClaims", (string)null); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin", b => - { - b.Property("LoginProvider") - .HasMaxLength(128) - .HasColumnType("varchar(128)"); - - b.Property("ProviderKey") - .HasMaxLength(128) - .HasColumnType("varchar(128)"); - - b.Property("ProviderDisplayName") - .HasColumnType("longtext"); - - b.Property("UserId") - .IsRequired() - .HasMaxLength(128) - .HasColumnType("varchar(128)"); - - b.HasKey("LoginProvider", "ProviderKey"); - - b.HasIndex("UserId"); - - b.ToTable("AspNetUserLogins", (string)null); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole", b => - { - b.Property("UserId") - .HasMaxLength(128) - .HasColumnType("varchar(128)"); - - b.Property("RoleId") - .HasMaxLength(128) - .HasColumnType("varchar(128)"); - - b.HasKey("UserId", "RoleId"); - - b.HasIndex("RoleId"); - - b.ToTable("AspNetUserRoles", (string)null); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken", b => - { - b.Property("UserId") - .HasMaxLength(128) - .HasColumnType("varchar(128)"); - - b.Property("LoginProvider") - .HasColumnType("varchar(95)"); - - b.Property("Name") - .HasColumnType("varchar(95)"); - - b.Property("Value") - .HasColumnType("longtext"); - - b.HasKey("UserId", "LoginProvider", "Name"); - - b.ToTable("AspNetUserTokens", (string)null); - }); - - modelBuilder.Entity("OpenIddict.EntityFrameworkCore.Models.OpenIddictEntityFrameworkCoreApplication", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("varchar(95)"); - - b.Property("ClientId") - .HasMaxLength(100) - .HasColumnType("varchar(100)"); - - b.Property("ClientSecret") - .HasColumnType("longtext"); - - b.Property("ConcurrencyToken") - .IsConcurrencyToken() - .HasMaxLength(50) - .HasColumnType("varchar(50)"); - - b.Property("ConsentType") - .HasMaxLength(50) - .HasColumnType("varchar(50)"); - - b.Property("DisplayName") - .HasColumnType("longtext"); - - b.Property("DisplayNames") - .HasColumnType("longtext"); - - b.Property("Permissions") - .HasColumnType("longtext"); - - b.Property("PostLogoutRedirectUris") - .HasColumnType("longtext"); - - b.Property("Properties") - .HasColumnType("longtext"); - - b.Property("RedirectUris") - .HasColumnType("longtext"); - - b.Property("Requirements") - .HasColumnType("longtext"); - - b.Property("Type") - .HasMaxLength(50) - .HasColumnType("varchar(50)"); - - b.HasKey("Id"); - - b.HasIndex("ClientId") - .IsUnique(); - - b.ToTable("OpenIddictApplications", (string)null); - }); - - modelBuilder.Entity("OpenIddict.EntityFrameworkCore.Models.OpenIddictEntityFrameworkCoreAuthorization", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("varchar(95)"); - - b.Property("ApplicationId") - .HasColumnType("varchar(95)"); - - b.Property("ConcurrencyToken") - .IsConcurrencyToken() - .HasMaxLength(50) - .HasColumnType("varchar(50)"); - - b.Property("CreationDate") - .HasColumnType("datetime(6)"); - - b.Property("Properties") - .HasColumnType("longtext"); - - b.Property("Scopes") - .HasColumnType("longtext"); - - b.Property("Status") - .HasMaxLength(50) - .HasColumnType("varchar(50)"); - - b.Property("Subject") - .HasMaxLength(400) - .HasColumnType("varchar(400)"); - - b.Property("Type") - .HasMaxLength(50) - .HasColumnType("varchar(50)"); - - b.HasKey("Id"); - - b.HasIndex("ApplicationId", "Status", "Subject", "Type"); - - b.ToTable("OpenIddictAuthorizations", (string)null); - }); - - modelBuilder.Entity("OpenIddict.EntityFrameworkCore.Models.OpenIddictEntityFrameworkCoreScope", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("varchar(95)"); - - b.Property("ConcurrencyToken") - .IsConcurrencyToken() - .HasMaxLength(50) - .HasColumnType("varchar(50)"); - - b.Property("Description") - .HasColumnType("longtext"); - - b.Property("Descriptions") - .HasColumnType("longtext"); - - b.Property("DisplayName") - .HasColumnType("longtext"); - - b.Property("DisplayNames") - .HasColumnType("longtext"); - - b.Property("Name") - .HasMaxLength(200) - .HasColumnType("varchar(200)"); - - b.Property("Properties") - .HasColumnType("longtext"); - - b.Property("Resources") - .HasColumnType("longtext"); - - b.HasKey("Id"); - - b.HasIndex("Name") - .IsUnique(); - - b.ToTable("OpenIddictScopes", (string)null); - }); - - modelBuilder.Entity("OpenIddict.EntityFrameworkCore.Models.OpenIddictEntityFrameworkCoreToken", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("varchar(95)"); - - b.Property("ApplicationId") - .HasColumnType("varchar(95)"); - - b.Property("AuthorizationId") - .HasColumnType("varchar(95)"); - - b.Property("ConcurrencyToken") - .IsConcurrencyToken() - .HasMaxLength(50) - .HasColumnType("varchar(50)"); - - b.Property("CreationDate") - .HasColumnType("datetime(6)"); - - b.Property("ExpirationDate") - .HasColumnType("datetime(6)"); - - b.Property("Payload") - .HasColumnType("longtext"); - - b.Property("Properties") - .HasColumnType("longtext"); - - b.Property("RedemptionDate") - .HasColumnType("datetime(6)"); - - b.Property("ReferenceId") - .HasMaxLength(100) - .HasColumnType("varchar(100)"); - - b.Property("Status") - .HasMaxLength(50) - .HasColumnType("varchar(50)"); - - b.Property("Subject") - .HasMaxLength(400) - .HasColumnType("varchar(400)"); - - b.Property("Type") - .HasMaxLength(50) - .HasColumnType("varchar(50)"); - - b.HasKey("Id"); - - b.HasIndex("AuthorizationId"); - - b.HasIndex("ReferenceId") - .IsUnique(); - - b.HasIndex("ApplicationId", "Status", "Subject", "Type"); - - b.ToTable("OpenIddictTokens", (string)null); - }); - - modelBuilder.Entity("VirtoCommerce.Platform.Core.Security.ApplicationUser", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasMaxLength(128) - .HasColumnType("varchar(128)"); - - b.Property("AccessFailedCount") - .HasColumnType("int"); - - b.Property("ConcurrencyStamp") - .IsConcurrencyToken() - .HasColumnType("longtext"); - - b.Property("CreatedBy") - .HasColumnType("longtext"); - - b.Property("CreatedDate") - .HasColumnType("datetime(6)"); - - b.Property("Email") - .HasMaxLength(256) - .HasColumnType("varchar(256)"); - - b.Property("EmailConfirmed") - .HasColumnType("tinyint(1)"); - - b.Property("IsAdministrator") - .HasColumnType("tinyint(1)"); - - b.Property("LastPasswordChangeRequestDate") - .HasColumnType("datetime(6)"); - - b.Property("LastPasswordChangedDate") - .HasColumnType("datetime(6)"); - - b.Property("LockoutEnabled") - .HasColumnType("tinyint(1)"); - - b.Property("LockoutEnd") - .HasColumnType("datetime(6)"); - - b.Property("MemberId") - .HasMaxLength(128) - .HasColumnType("varchar(128)"); - - b.Property("ModifiedBy") - .HasColumnType("longtext"); - - b.Property("ModifiedDate") - .HasColumnType("datetime(6)"); - - b.Property("NormalizedEmail") - .HasMaxLength(256) - .HasColumnType("varchar(256)"); - - b.Property("NormalizedUserName") - .HasMaxLength(256) - .HasColumnType("varchar(256)"); - - b.Property("PasswordExpired") - .HasColumnType("tinyint(1)"); - - b.Property("PasswordHash") - .HasColumnType("longtext"); - - b.Property("PhoneNumber") - .HasColumnType("longtext"); - - b.Property("PhoneNumberConfirmed") - .HasColumnType("tinyint(1)"); - - b.Property("PhotoUrl") - .HasMaxLength(2048) - .HasColumnType("varchar(2048)"); - - b.Property("SecurityStamp") - .HasColumnType("longtext"); - - b.Property("Status") - .HasMaxLength(64) - .HasColumnType("varchar(64)"); - - b.Property("StoreId") - .HasMaxLength(128) - .HasColumnType("varchar(128)"); - - b.Property("TwoFactorEnabled") - .HasColumnType("tinyint(1)"); - - b.Property("UserName") - .HasMaxLength(256) - .HasColumnType("varchar(256)"); - - b.Property("UserType") - .HasMaxLength(64) - .HasColumnType("varchar(64)"); - - b.HasKey("Id"); - - b.HasIndex("NormalizedEmail") - .HasDatabaseName("EmailIndex"); - - b.HasIndex("NormalizedUserName") - .IsUnique() - .HasDatabaseName("UserNameIndex"); - - b.ToTable("AspNetUsers", (string)null); - }); - - modelBuilder.Entity("VirtoCommerce.Platform.Core.Security.Role", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasMaxLength(128) - .HasColumnType("varchar(128)"); - - b.Property("ConcurrencyStamp") - .IsConcurrencyToken() - .HasColumnType("longtext"); - - b.Property("Description") - .HasColumnType("longtext"); - - b.Property("Name") - .HasMaxLength(256) - .HasColumnType("varchar(256)"); - - b.Property("NormalizedName") - .HasMaxLength(256) - .HasColumnType("varchar(256)"); - - b.HasKey("Id"); - - b.HasIndex("NormalizedName") - .IsUnique() - .HasDatabaseName("RoleNameIndex"); - - b.ToTable("AspNetRoles", (string)null); - }); - - modelBuilder.Entity("VirtoCommerce.Platform.Security.Model.ServerCertificateEntity", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasMaxLength(128) - .HasColumnType("varchar(128)"); - - b.Property("PrivateKeyCertBase64") - .HasColumnType("longtext"); - - b.Property("PrivateKeyCertPassword") - .HasMaxLength(128) - .HasColumnType("varchar(128)"); - - b.Property("PublicCertBase64") - .HasColumnType("longtext"); - - b.HasKey("Id"); - - b.ToTable("ServerCertificate", (string)null); - }); - - modelBuilder.Entity("VirtoCommerce.Platform.Security.Model.UserApiKeyEntity", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasMaxLength(128) - .HasColumnType("varchar(128)"); - - b.Property("ApiKey") - .HasMaxLength(128) - .HasColumnType("varchar(128)"); - - b.Property("CreatedBy") - .HasMaxLength(64) - .HasColumnType("varchar(64)"); - - b.Property("CreatedDate") - .HasColumnType("datetime(6)"); - - b.Property("IsActive") - .HasColumnType("tinyint(1)"); - - b.Property("ModifiedBy") - .HasMaxLength(64) - .HasColumnType("varchar(64)"); - - b.Property("ModifiedDate") - .HasColumnType("datetime(6)"); - - b.Property("UserId") - .HasColumnType("longtext"); - - b.Property("UserName") - .HasColumnType("longtext"); - - b.HasKey("Id"); - - b.HasIndex("ApiKey") - .IsUnique(); - - b.ToTable("UserApiKey", (string)null); - }); - - modelBuilder.Entity("VirtoCommerce.Platform.Security.Model.UserPasswordHistoryEntity", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasMaxLength(128) - .HasColumnType("varchar(128)"); - - b.Property("CreatedBy") - .HasMaxLength(64) - .HasColumnType("varchar(64)"); - - b.Property("CreatedDate") - .HasColumnType("datetime(6)"); - - b.Property("ModifiedBy") - .HasMaxLength(64) - .HasColumnType("varchar(64)"); - - b.Property("ModifiedDate") - .HasColumnType("datetime(6)"); - - b.Property("PasswordHash") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("UserId") - .HasMaxLength(128) - .HasColumnType("varchar(128)"); - - b.HasKey("Id"); - - b.HasIndex("UserId"); - - b.ToTable("AspNetUserPasswordsHistory", (string)null); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim", b => - { - b.HasOne("VirtoCommerce.Platform.Core.Security.Role", null) - .WithMany() - .HasForeignKey("RoleId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim", b => - { - b.HasOne("VirtoCommerce.Platform.Core.Security.ApplicationUser", null) - .WithMany() - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin", b => - { - b.HasOne("VirtoCommerce.Platform.Core.Security.ApplicationUser", null) - .WithMany() - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole", b => - { - b.HasOne("VirtoCommerce.Platform.Core.Security.Role", null) - .WithMany("UserRoles") - .HasForeignKey("RoleId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("VirtoCommerce.Platform.Core.Security.ApplicationUser", null) - .WithMany("UserRoles") - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken", b => - { - b.HasOne("VirtoCommerce.Platform.Core.Security.ApplicationUser", null) - .WithMany() - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - }); - - modelBuilder.Entity("OpenIddict.EntityFrameworkCore.Models.OpenIddictEntityFrameworkCoreAuthorization", b => - { - b.HasOne("OpenIddict.EntityFrameworkCore.Models.OpenIddictEntityFrameworkCoreApplication", "Application") - .WithMany("Authorizations") - .HasForeignKey("ApplicationId"); - - b.Navigation("Application"); - }); - - modelBuilder.Entity("OpenIddict.EntityFrameworkCore.Models.OpenIddictEntityFrameworkCoreToken", b => - { - b.HasOne("OpenIddict.EntityFrameworkCore.Models.OpenIddictEntityFrameworkCoreApplication", "Application") - .WithMany("Tokens") - .HasForeignKey("ApplicationId"); - - b.HasOne("OpenIddict.EntityFrameworkCore.Models.OpenIddictEntityFrameworkCoreAuthorization", "Authorization") - .WithMany("Tokens") - .HasForeignKey("AuthorizationId"); - - b.Navigation("Application"); - - b.Navigation("Authorization"); - }); - - modelBuilder.Entity("VirtoCommerce.Platform.Security.Model.UserPasswordHistoryEntity", b => - { - b.HasOne("VirtoCommerce.Platform.Core.Security.ApplicationUser", null) - .WithMany() - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Cascade); - }); - - modelBuilder.Entity("OpenIddict.EntityFrameworkCore.Models.OpenIddictEntityFrameworkCoreApplication", b => - { - b.Navigation("Authorizations"); - - b.Navigation("Tokens"); - }); - - modelBuilder.Entity("OpenIddict.EntityFrameworkCore.Models.OpenIddictEntityFrameworkCoreAuthorization", b => - { - b.Navigation("Tokens"); - }); - - modelBuilder.Entity("VirtoCommerce.Platform.Core.Security.ApplicationUser", b => - { - b.Navigation("UserRoles"); - }); - - modelBuilder.Entity("VirtoCommerce.Platform.Core.Security.Role", b => - { - b.Navigation("UserRoles"); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/src/VirtoCommerce.Platform.Security.MySql/Migrations/20221124131800_Initial.cs b/src/VirtoCommerce.Platform.Security.MySql/Migrations/20221124131800_Initial.cs deleted file mode 100644 index d5823bb5a77..00000000000 --- a/src/VirtoCommerce.Platform.Security.MySql/Migrations/20221124131800_Initial.cs +++ /dev/null @@ -1,563 +0,0 @@ -using System; -using Microsoft.EntityFrameworkCore.Metadata; -using Microsoft.EntityFrameworkCore.Migrations; - -#nullable disable - -namespace VirtoCommerce.Platform.Security.MySql.Migrations -{ - public partial class Initial : Migration - { - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.AlterDatabase() - .Annotation("MySql:CharSet", "utf8mb4"); - - migrationBuilder.CreateTable( - name: "AspNetRoles", - columns: table => new - { - Id = table.Column(type: "varchar(128)", maxLength: 128, nullable: false) - .Annotation("MySql:CharSet", "utf8mb4"), - Description = table.Column(type: "longtext", nullable: true) - .Annotation("MySql:CharSet", "utf8mb4"), - Name = table.Column(type: "varchar(256)", maxLength: 256, nullable: true) - .Annotation("MySql:CharSet", "utf8mb4"), - NormalizedName = table.Column(type: "varchar(256)", maxLength: 256, nullable: true) - .Annotation("MySql:CharSet", "utf8mb4"), - ConcurrencyStamp = table.Column(type: "longtext", nullable: true) - .Annotation("MySql:CharSet", "utf8mb4") - }, - constraints: table => - { - table.PrimaryKey("PK_AspNetRoles", x => x.Id); - }) - .Annotation("MySql:CharSet", "utf8mb4"); - - migrationBuilder.CreateTable( - name: "AspNetUsers", - columns: table => new - { - Id = table.Column(type: "varchar(128)", maxLength: 128, nullable: false) - .Annotation("MySql:CharSet", "utf8mb4"), - StoreId = table.Column(type: "varchar(128)", maxLength: 128, nullable: true) - .Annotation("MySql:CharSet", "utf8mb4"), - MemberId = table.Column(type: "varchar(128)", maxLength: 128, nullable: true) - .Annotation("MySql:CharSet", "utf8mb4"), - IsAdministrator = table.Column(type: "tinyint(1)", nullable: false), - PhotoUrl = table.Column(type: "varchar(2048)", maxLength: 2048, nullable: true) - .Annotation("MySql:CharSet", "utf8mb4"), - UserType = table.Column(type: "varchar(64)", maxLength: 64, nullable: true) - .Annotation("MySql:CharSet", "utf8mb4"), - Status = table.Column(type: "varchar(64)", maxLength: 64, nullable: true) - .Annotation("MySql:CharSet", "utf8mb4"), - CreatedDate = table.Column(type: "datetime(6)", nullable: false), - ModifiedDate = table.Column(type: "datetime(6)", nullable: true), - CreatedBy = table.Column(type: "longtext", nullable: true) - .Annotation("MySql:CharSet", "utf8mb4"), - ModifiedBy = table.Column(type: "longtext", nullable: true) - .Annotation("MySql:CharSet", "utf8mb4"), - PasswordExpired = table.Column(type: "tinyint(1)", nullable: false), - LastPasswordChangedDate = table.Column(type: "datetime(6)", nullable: true), - LastPasswordChangeRequestDate = table.Column(type: "datetime(6)", nullable: true), - UserName = table.Column(type: "varchar(256)", maxLength: 256, nullable: true) - .Annotation("MySql:CharSet", "utf8mb4"), - NormalizedUserName = table.Column(type: "varchar(256)", maxLength: 256, nullable: true) - .Annotation("MySql:CharSet", "utf8mb4"), - Email = table.Column(type: "varchar(256)", maxLength: 256, nullable: true) - .Annotation("MySql:CharSet", "utf8mb4"), - NormalizedEmail = table.Column(type: "varchar(256)", maxLength: 256, nullable: true) - .Annotation("MySql:CharSet", "utf8mb4"), - EmailConfirmed = table.Column(type: "tinyint(1)", nullable: false), - PasswordHash = table.Column(type: "longtext", nullable: true) - .Annotation("MySql:CharSet", "utf8mb4"), - SecurityStamp = table.Column(type: "longtext", nullable: true) - .Annotation("MySql:CharSet", "utf8mb4"), - ConcurrencyStamp = table.Column(type: "longtext", nullable: true) - .Annotation("MySql:CharSet", "utf8mb4"), - PhoneNumber = table.Column(type: "longtext", nullable: true) - .Annotation("MySql:CharSet", "utf8mb4"), - PhoneNumberConfirmed = table.Column(type: "tinyint(1)", nullable: false), - TwoFactorEnabled = table.Column(type: "tinyint(1)", nullable: false), - LockoutEnd = table.Column(type: "datetime(6)", nullable: true), - LockoutEnabled = table.Column(type: "tinyint(1)", nullable: false), - AccessFailedCount = table.Column(type: "int", nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_AspNetUsers", x => x.Id); - }) - .Annotation("MySql:CharSet", "utf8mb4"); - - migrationBuilder.CreateTable( - name: "OpenIddictApplications", - columns: table => new - { - Id = table.Column(type: "varchar(95)", nullable: false) - .Annotation("MySql:CharSet", "utf8mb4"), - ClientId = table.Column(type: "varchar(100)", maxLength: 100, nullable: true) - .Annotation("MySql:CharSet", "utf8mb4"), - ClientSecret = table.Column(type: "longtext", nullable: true) - .Annotation("MySql:CharSet", "utf8mb4"), - ConcurrencyToken = table.Column(type: "varchar(50)", maxLength: 50, nullable: true) - .Annotation("MySql:CharSet", "utf8mb4"), - ConsentType = table.Column(type: "varchar(50)", maxLength: 50, nullable: true) - .Annotation("MySql:CharSet", "utf8mb4"), - DisplayName = table.Column(type: "longtext", nullable: true) - .Annotation("MySql:CharSet", "utf8mb4"), - DisplayNames = table.Column(type: "longtext", nullable: true) - .Annotation("MySql:CharSet", "utf8mb4"), - Permissions = table.Column(type: "longtext", nullable: true) - .Annotation("MySql:CharSet", "utf8mb4"), - PostLogoutRedirectUris = table.Column(type: "longtext", nullable: true) - .Annotation("MySql:CharSet", "utf8mb4"), - Properties = table.Column(type: "longtext", nullable: true) - .Annotation("MySql:CharSet", "utf8mb4"), - RedirectUris = table.Column(type: "longtext", nullable: true) - .Annotation("MySql:CharSet", "utf8mb4"), - Requirements = table.Column(type: "longtext", nullable: true) - .Annotation("MySql:CharSet", "utf8mb4"), - Type = table.Column(type: "varchar(50)", maxLength: 50, nullable: true) - .Annotation("MySql:CharSet", "utf8mb4") - }, - constraints: table => - { - table.PrimaryKey("PK_OpenIddictApplications", x => x.Id); - }) - .Annotation("MySql:CharSet", "utf8mb4"); - - migrationBuilder.CreateTable( - name: "OpenIddictScopes", - columns: table => new - { - Id = table.Column(type: "varchar(95)", nullable: false) - .Annotation("MySql:CharSet", "utf8mb4"), - ConcurrencyToken = table.Column(type: "varchar(50)", maxLength: 50, nullable: true) - .Annotation("MySql:CharSet", "utf8mb4"), - Description = table.Column(type: "longtext", nullable: true) - .Annotation("MySql:CharSet", "utf8mb4"), - Descriptions = table.Column(type: "longtext", nullable: true) - .Annotation("MySql:CharSet", "utf8mb4"), - DisplayName = table.Column(type: "longtext", nullable: true) - .Annotation("MySql:CharSet", "utf8mb4"), - DisplayNames = table.Column(type: "longtext", nullable: true) - .Annotation("MySql:CharSet", "utf8mb4"), - Name = table.Column(type: "varchar(200)", maxLength: 200, nullable: true) - .Annotation("MySql:CharSet", "utf8mb4"), - Properties = table.Column(type: "longtext", nullable: true) - .Annotation("MySql:CharSet", "utf8mb4"), - Resources = table.Column(type: "longtext", nullable: true) - .Annotation("MySql:CharSet", "utf8mb4") - }, - constraints: table => - { - table.PrimaryKey("PK_OpenIddictScopes", x => x.Id); - }) - .Annotation("MySql:CharSet", "utf8mb4"); - - migrationBuilder.CreateTable( - name: "ServerCertificate", - columns: table => new - { - Id = table.Column(type: "varchar(128)", maxLength: 128, nullable: false) - .Annotation("MySql:CharSet", "utf8mb4"), - PublicCertBase64 = table.Column(type: "longtext", nullable: true) - .Annotation("MySql:CharSet", "utf8mb4"), - PrivateKeyCertBase64 = table.Column(type: "longtext", nullable: true) - .Annotation("MySql:CharSet", "utf8mb4"), - PrivateKeyCertPassword = table.Column(type: "varchar(128)", maxLength: 128, nullable: true) - .Annotation("MySql:CharSet", "utf8mb4") - }, - constraints: table => - { - table.PrimaryKey("PK_ServerCertificate", x => x.Id); - }) - .Annotation("MySql:CharSet", "utf8mb4"); - - migrationBuilder.CreateTable( - name: "UserApiKey", - columns: table => new - { - Id = table.Column(type: "varchar(128)", maxLength: 128, nullable: false) - .Annotation("MySql:CharSet", "utf8mb4"), - UserName = table.Column(type: "longtext", nullable: true) - .Annotation("MySql:CharSet", "utf8mb4"), - ApiKey = table.Column(type: "varchar(128)", maxLength: 128, nullable: true) - .Annotation("MySql:CharSet", "utf8mb4"), - UserId = table.Column(type: "longtext", nullable: true) - .Annotation("MySql:CharSet", "utf8mb4"), - IsActive = table.Column(type: "tinyint(1)", nullable: false), - CreatedDate = table.Column(type: "datetime(6)", nullable: false), - ModifiedDate = table.Column(type: "datetime(6)", nullable: true), - CreatedBy = table.Column(type: "varchar(64)", maxLength: 64, nullable: true) - .Annotation("MySql:CharSet", "utf8mb4"), - ModifiedBy = table.Column(type: "varchar(64)", maxLength: 64, nullable: true) - .Annotation("MySql:CharSet", "utf8mb4") - }, - constraints: table => - { - table.PrimaryKey("PK_UserApiKey", x => x.Id); - }) - .Annotation("MySql:CharSet", "utf8mb4"); - - migrationBuilder.CreateTable( - name: "AspNetRoleClaims", - columns: table => new - { - Id = table.Column(type: "int", nullable: false) - .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), - RoleId = table.Column(type: "varchar(128)", maxLength: 128, nullable: false) - .Annotation("MySql:CharSet", "utf8mb4"), - ClaimType = table.Column(type: "longtext", nullable: true) - .Annotation("MySql:CharSet", "utf8mb4"), - ClaimValue = table.Column(type: "longtext", nullable: true) - .Annotation("MySql:CharSet", "utf8mb4") - }, - constraints: table => - { - table.PrimaryKey("PK_AspNetRoleClaims", x => x.Id); - table.ForeignKey( - name: "FK_AspNetRoleClaims_AspNetRoles_RoleId", - column: x => x.RoleId, - principalTable: "AspNetRoles", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - }) - .Annotation("MySql:CharSet", "utf8mb4"); - - migrationBuilder.CreateTable( - name: "AspNetUserClaims", - columns: table => new - { - Id = table.Column(type: "int", nullable: false) - .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), - UserId = table.Column(type: "varchar(128)", maxLength: 128, nullable: false) - .Annotation("MySql:CharSet", "utf8mb4"), - ClaimType = table.Column(type: "longtext", nullable: true) - .Annotation("MySql:CharSet", "utf8mb4"), - ClaimValue = table.Column(type: "longtext", nullable: true) - .Annotation("MySql:CharSet", "utf8mb4") - }, - constraints: table => - { - table.PrimaryKey("PK_AspNetUserClaims", x => x.Id); - table.ForeignKey( - name: "FK_AspNetUserClaims_AspNetUsers_UserId", - column: x => x.UserId, - principalTable: "AspNetUsers", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - }) - .Annotation("MySql:CharSet", "utf8mb4"); - - migrationBuilder.CreateTable( - name: "AspNetUserLogins", - columns: table => new - { - LoginProvider = table.Column(type: "varchar(128)", maxLength: 128, nullable: false) - .Annotation("MySql:CharSet", "utf8mb4"), - ProviderKey = table.Column(type: "varchar(128)", maxLength: 128, nullable: false) - .Annotation("MySql:CharSet", "utf8mb4"), - ProviderDisplayName = table.Column(type: "longtext", nullable: true) - .Annotation("MySql:CharSet", "utf8mb4"), - UserId = table.Column(type: "varchar(128)", maxLength: 128, nullable: false) - .Annotation("MySql:CharSet", "utf8mb4") - }, - constraints: table => - { - table.PrimaryKey("PK_AspNetUserLogins", x => new { x.LoginProvider, x.ProviderKey }); - table.ForeignKey( - name: "FK_AspNetUserLogins_AspNetUsers_UserId", - column: x => x.UserId, - principalTable: "AspNetUsers", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - }) - .Annotation("MySql:CharSet", "utf8mb4"); - - migrationBuilder.CreateTable( - name: "AspNetUserPasswordsHistory", - columns: table => new - { - Id = table.Column(type: "varchar(128)", maxLength: 128, nullable: false) - .Annotation("MySql:CharSet", "utf8mb4"), - UserId = table.Column(type: "varchar(128)", maxLength: 128, nullable: true) - .Annotation("MySql:CharSet", "utf8mb4"), - PasswordHash = table.Column(type: "longtext", nullable: false) - .Annotation("MySql:CharSet", "utf8mb4"), - CreatedDate = table.Column(type: "datetime(6)", nullable: false), - ModifiedDate = table.Column(type: "datetime(6)", nullable: true), - CreatedBy = table.Column(type: "varchar(64)", maxLength: 64, nullable: true) - .Annotation("MySql:CharSet", "utf8mb4"), - ModifiedBy = table.Column(type: "varchar(64)", maxLength: 64, nullable: true) - .Annotation("MySql:CharSet", "utf8mb4") - }, - constraints: table => - { - table.PrimaryKey("PK_AspNetUserPasswordsHistory", x => x.Id); - table.ForeignKey( - name: "FK_AspNetUserPasswordsHistory_AspNetUsers_UserId", - column: x => x.UserId, - principalTable: "AspNetUsers", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - }) - .Annotation("MySql:CharSet", "utf8mb4"); - - migrationBuilder.CreateTable( - name: "AspNetUserRoles", - columns: table => new - { - UserId = table.Column(type: "varchar(128)", maxLength: 128, nullable: false) - .Annotation("MySql:CharSet", "utf8mb4"), - RoleId = table.Column(type: "varchar(128)", maxLength: 128, nullable: false) - .Annotation("MySql:CharSet", "utf8mb4") - }, - constraints: table => - { - table.PrimaryKey("PK_AspNetUserRoles", x => new { x.UserId, x.RoleId }); - table.ForeignKey( - name: "FK_AspNetUserRoles_AspNetRoles_RoleId", - column: x => x.RoleId, - principalTable: "AspNetRoles", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - table.ForeignKey( - name: "FK_AspNetUserRoles_AspNetUsers_UserId", - column: x => x.UserId, - principalTable: "AspNetUsers", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - }) - .Annotation("MySql:CharSet", "utf8mb4"); - - migrationBuilder.CreateTable( - name: "AspNetUserTokens", - columns: table => new - { - UserId = table.Column(type: "varchar(128)", maxLength: 128, nullable: false) - .Annotation("MySql:CharSet", "utf8mb4"), - LoginProvider = table.Column(type: "varchar(95)", nullable: false) - .Annotation("MySql:CharSet", "utf8mb4"), - Name = table.Column(type: "varchar(95)", nullable: false) - .Annotation("MySql:CharSet", "utf8mb4"), - Value = table.Column(type: "longtext", nullable: true) - .Annotation("MySql:CharSet", "utf8mb4") - }, - constraints: table => - { - table.PrimaryKey("PK_AspNetUserTokens", x => new { x.UserId, x.LoginProvider, x.Name }); - table.ForeignKey( - name: "FK_AspNetUserTokens_AspNetUsers_UserId", - column: x => x.UserId, - principalTable: "AspNetUsers", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - }) - .Annotation("MySql:CharSet", "utf8mb4"); - - migrationBuilder.CreateTable( - name: "OpenIddictAuthorizations", - columns: table => new - { - Id = table.Column(type: "varchar(95)", nullable: false) - .Annotation("MySql:CharSet", "utf8mb4"), - ApplicationId = table.Column(type: "varchar(95)", nullable: true) - .Annotation("MySql:CharSet", "utf8mb4"), - ConcurrencyToken = table.Column(type: "varchar(50)", maxLength: 50, nullable: true) - .Annotation("MySql:CharSet", "utf8mb4"), - CreationDate = table.Column(type: "datetime(6)", nullable: true), - Properties = table.Column(type: "longtext", nullable: true) - .Annotation("MySql:CharSet", "utf8mb4"), - Scopes = table.Column(type: "longtext", nullable: true) - .Annotation("MySql:CharSet", "utf8mb4"), - Status = table.Column(type: "varchar(50)", maxLength: 50, nullable: true) - .Annotation("MySql:CharSet", "utf8mb4"), - Subject = table.Column(type: "varchar(400)", maxLength: 400, nullable: true) - .Annotation("MySql:CharSet", "utf8mb4"), - Type = table.Column(type: "varchar(50)", maxLength: 50, nullable: true) - .Annotation("MySql:CharSet", "utf8mb4") - }, - constraints: table => - { - table.PrimaryKey("PK_OpenIddictAuthorizations", x => x.Id); - table.ForeignKey( - name: "FK_OpenIddictAuthorizations_OpenIddictApplications_ApplicationId", - column: x => x.ApplicationId, - principalTable: "OpenIddictApplications", - principalColumn: "Id"); - }) - .Annotation("MySql:CharSet", "utf8mb4"); - - migrationBuilder.CreateTable( - name: "OpenIddictTokens", - columns: table => new - { - Id = table.Column(type: "varchar(95)", nullable: false) - .Annotation("MySql:CharSet", "utf8mb4"), - ApplicationId = table.Column(type: "varchar(95)", nullable: true) - .Annotation("MySql:CharSet", "utf8mb4"), - AuthorizationId = table.Column(type: "varchar(95)", nullable: true) - .Annotation("MySql:CharSet", "utf8mb4"), - ConcurrencyToken = table.Column(type: "varchar(50)", maxLength: 50, nullable: true) - .Annotation("MySql:CharSet", "utf8mb4"), - CreationDate = table.Column(type: "datetime(6)", nullable: true), - ExpirationDate = table.Column(type: "datetime(6)", nullable: true), - Payload = table.Column(type: "longtext", nullable: true) - .Annotation("MySql:CharSet", "utf8mb4"), - Properties = table.Column(type: "longtext", nullable: true) - .Annotation("MySql:CharSet", "utf8mb4"), - RedemptionDate = table.Column(type: "datetime(6)", nullable: true), - ReferenceId = table.Column(type: "varchar(100)", maxLength: 100, nullable: true) - .Annotation("MySql:CharSet", "utf8mb4"), - Status = table.Column(type: "varchar(50)", maxLength: 50, nullable: true) - .Annotation("MySql:CharSet", "utf8mb4"), - Subject = table.Column(type: "varchar(400)", maxLength: 400, nullable: true) - .Annotation("MySql:CharSet", "utf8mb4"), - Type = table.Column(type: "varchar(50)", maxLength: 50, nullable: true) - .Annotation("MySql:CharSet", "utf8mb4") - }, - constraints: table => - { - table.PrimaryKey("PK_OpenIddictTokens", x => x.Id); - table.ForeignKey( - name: "FK_OpenIddictTokens_OpenIddictApplications_ApplicationId", - column: x => x.ApplicationId, - principalTable: "OpenIddictApplications", - principalColumn: "Id"); - table.ForeignKey( - name: "FK_OpenIddictTokens_OpenIddictAuthorizations_AuthorizationId", - column: x => x.AuthorizationId, - principalTable: "OpenIddictAuthorizations", - principalColumn: "Id"); - }) - .Annotation("MySql:CharSet", "utf8mb4"); - - migrationBuilder.CreateIndex( - name: "IX_AspNetRoleClaims_RoleId", - table: "AspNetRoleClaims", - column: "RoleId"); - - migrationBuilder.CreateIndex( - name: "RoleNameIndex", - table: "AspNetRoles", - column: "NormalizedName", - unique: true); - - migrationBuilder.CreateIndex( - name: "IX_AspNetUserClaims_UserId", - table: "AspNetUserClaims", - column: "UserId"); - - migrationBuilder.CreateIndex( - name: "IX_AspNetUserLogins_UserId", - table: "AspNetUserLogins", - column: "UserId"); - - migrationBuilder.CreateIndex( - name: "IX_AspNetUserPasswordsHistory_UserId", - table: "AspNetUserPasswordsHistory", - column: "UserId"); - - migrationBuilder.CreateIndex( - name: "IX_AspNetUserRoles_RoleId", - table: "AspNetUserRoles", - column: "RoleId"); - - migrationBuilder.CreateIndex( - name: "EmailIndex", - table: "AspNetUsers", - column: "NormalizedEmail"); - - migrationBuilder.CreateIndex( - name: "UserNameIndex", - table: "AspNetUsers", - column: "NormalizedUserName", - unique: true); - - migrationBuilder.CreateIndex( - name: "IX_OpenIddictApplications_ClientId", - table: "OpenIddictApplications", - column: "ClientId", - unique: true); - - migrationBuilder.CreateIndex( - name: "IX_OpenIddictAuthorizations_ApplicationId_Status_Subject_Type", - table: "OpenIddictAuthorizations", - columns: new[] { "ApplicationId", "Status", "Subject", "Type" }); - - migrationBuilder.CreateIndex( - name: "IX_OpenIddictScopes_Name", - table: "OpenIddictScopes", - column: "Name", - unique: true); - - migrationBuilder.CreateIndex( - name: "IX_OpenIddictTokens_ApplicationId_Status_Subject_Type", - table: "OpenIddictTokens", - columns: new[] { "ApplicationId", "Status", "Subject", "Type" }); - - migrationBuilder.CreateIndex( - name: "IX_OpenIddictTokens_AuthorizationId", - table: "OpenIddictTokens", - column: "AuthorizationId"); - - migrationBuilder.CreateIndex( - name: "IX_OpenIddictTokens_ReferenceId", - table: "OpenIddictTokens", - column: "ReferenceId", - unique: true); - - migrationBuilder.CreateIndex( - name: "IX_UserApiKey_ApiKey", - table: "UserApiKey", - column: "ApiKey", - unique: true); - } - - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropTable( - name: "AspNetRoleClaims"); - - migrationBuilder.DropTable( - name: "AspNetUserClaims"); - - migrationBuilder.DropTable( - name: "AspNetUserLogins"); - - migrationBuilder.DropTable( - name: "AspNetUserPasswordsHistory"); - - migrationBuilder.DropTable( - name: "AspNetUserRoles"); - - migrationBuilder.DropTable( - name: "AspNetUserTokens"); - - migrationBuilder.DropTable( - name: "OpenIddictScopes"); - - migrationBuilder.DropTable( - name: "OpenIddictTokens"); - - migrationBuilder.DropTable( - name: "ServerCertificate"); - - migrationBuilder.DropTable( - name: "UserApiKey"); - - migrationBuilder.DropTable( - name: "AspNetRoles"); - - migrationBuilder.DropTable( - name: "AspNetUsers"); - - migrationBuilder.DropTable( - name: "OpenIddictAuthorizations"); - - migrationBuilder.DropTable( - name: "OpenIddictApplications"); - } - } -} diff --git a/src/VirtoCommerce.Platform.Security.MySql/Migrations/SecurityDbContextModelSnapshot.cs b/src/VirtoCommerce.Platform.Security.MySql/Migrations/SecurityDbContextModelSnapshot.cs deleted file mode 100644 index 09037f9f0da..00000000000 --- a/src/VirtoCommerce.Platform.Security.MySql/Migrations/SecurityDbContextModelSnapshot.cs +++ /dev/null @@ -1,678 +0,0 @@ -// -using System; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Storage.ValueConversion; -using VirtoCommerce.Platform.Security.Repositories; - -#nullable disable - -namespace VirtoCommerce.Platform.Security.MySql.Migrations -{ - [DbContext(typeof(SecurityDbContext))] - partial class SecurityDbContextModelSnapshot : ModelSnapshot - { - protected override void BuildModel(ModelBuilder modelBuilder) - { -#pragma warning disable 612, 618 - modelBuilder - .HasAnnotation("ProductVersion", "6.0.0") - .HasAnnotation("Relational:MaxIdentifierLength", 64); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("ClaimType") - .HasColumnType("longtext"); - - b.Property("ClaimValue") - .HasColumnType("longtext"); - - b.Property("RoleId") - .IsRequired() - .HasMaxLength(128) - .HasColumnType("varchar(128)"); - - b.HasKey("Id"); - - b.HasIndex("RoleId"); - - b.ToTable("AspNetRoleClaims", (string)null); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("ClaimType") - .HasColumnType("longtext"); - - b.Property("ClaimValue") - .HasColumnType("longtext"); - - b.Property("UserId") - .IsRequired() - .HasMaxLength(128) - .HasColumnType("varchar(128)"); - - b.HasKey("Id"); - - b.HasIndex("UserId"); - - b.ToTable("AspNetUserClaims", (string)null); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin", b => - { - b.Property("LoginProvider") - .HasMaxLength(128) - .HasColumnType("varchar(128)"); - - b.Property("ProviderKey") - .HasMaxLength(128) - .HasColumnType("varchar(128)"); - - b.Property("ProviderDisplayName") - .HasColumnType("longtext"); - - b.Property("UserId") - .IsRequired() - .HasMaxLength(128) - .HasColumnType("varchar(128)"); - - b.HasKey("LoginProvider", "ProviderKey"); - - b.HasIndex("UserId"); - - b.ToTable("AspNetUserLogins", (string)null); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole", b => - { - b.Property("UserId") - .HasMaxLength(128) - .HasColumnType("varchar(128)"); - - b.Property("RoleId") - .HasMaxLength(128) - .HasColumnType("varchar(128)"); - - b.HasKey("UserId", "RoleId"); - - b.HasIndex("RoleId"); - - b.ToTable("AspNetUserRoles", (string)null); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken", b => - { - b.Property("UserId") - .HasMaxLength(128) - .HasColumnType("varchar(128)"); - - b.Property("LoginProvider") - .HasColumnType("varchar(95)"); - - b.Property("Name") - .HasColumnType("varchar(95)"); - - b.Property("Value") - .HasColumnType("longtext"); - - b.HasKey("UserId", "LoginProvider", "Name"); - - b.ToTable("AspNetUserTokens", (string)null); - }); - - modelBuilder.Entity("OpenIddict.EntityFrameworkCore.Models.OpenIddictEntityFrameworkCoreApplication", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("varchar(95)"); - - b.Property("ClientId") - .HasMaxLength(100) - .HasColumnType("varchar(100)"); - - b.Property("ClientSecret") - .HasColumnType("longtext"); - - b.Property("ConcurrencyToken") - .IsConcurrencyToken() - .HasMaxLength(50) - .HasColumnType("varchar(50)"); - - b.Property("ConsentType") - .HasMaxLength(50) - .HasColumnType("varchar(50)"); - - b.Property("DisplayName") - .HasColumnType("longtext"); - - b.Property("DisplayNames") - .HasColumnType("longtext"); - - b.Property("Permissions") - .HasColumnType("longtext"); - - b.Property("PostLogoutRedirectUris") - .HasColumnType("longtext"); - - b.Property("Properties") - .HasColumnType("longtext"); - - b.Property("RedirectUris") - .HasColumnType("longtext"); - - b.Property("Requirements") - .HasColumnType("longtext"); - - b.Property("Type") - .HasMaxLength(50) - .HasColumnType("varchar(50)"); - - b.HasKey("Id"); - - b.HasIndex("ClientId") - .IsUnique(); - - b.ToTable("OpenIddictApplications", (string)null); - }); - - modelBuilder.Entity("OpenIddict.EntityFrameworkCore.Models.OpenIddictEntityFrameworkCoreAuthorization", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("varchar(95)"); - - b.Property("ApplicationId") - .HasColumnType("varchar(95)"); - - b.Property("ConcurrencyToken") - .IsConcurrencyToken() - .HasMaxLength(50) - .HasColumnType("varchar(50)"); - - b.Property("CreationDate") - .HasColumnType("datetime(6)"); - - b.Property("Properties") - .HasColumnType("longtext"); - - b.Property("Scopes") - .HasColumnType("longtext"); - - b.Property("Status") - .HasMaxLength(50) - .HasColumnType("varchar(50)"); - - b.Property("Subject") - .HasMaxLength(400) - .HasColumnType("varchar(400)"); - - b.Property("Type") - .HasMaxLength(50) - .HasColumnType("varchar(50)"); - - b.HasKey("Id"); - - b.HasIndex("ApplicationId", "Status", "Subject", "Type"); - - b.ToTable("OpenIddictAuthorizations", (string)null); - }); - - modelBuilder.Entity("OpenIddict.EntityFrameworkCore.Models.OpenIddictEntityFrameworkCoreScope", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("varchar(95)"); - - b.Property("ConcurrencyToken") - .IsConcurrencyToken() - .HasMaxLength(50) - .HasColumnType("varchar(50)"); - - b.Property("Description") - .HasColumnType("longtext"); - - b.Property("Descriptions") - .HasColumnType("longtext"); - - b.Property("DisplayName") - .HasColumnType("longtext"); - - b.Property("DisplayNames") - .HasColumnType("longtext"); - - b.Property("Name") - .HasMaxLength(200) - .HasColumnType("varchar(200)"); - - b.Property("Properties") - .HasColumnType("longtext"); - - b.Property("Resources") - .HasColumnType("longtext"); - - b.HasKey("Id"); - - b.HasIndex("Name") - .IsUnique(); - - b.ToTable("OpenIddictScopes", (string)null); - }); - - modelBuilder.Entity("OpenIddict.EntityFrameworkCore.Models.OpenIddictEntityFrameworkCoreToken", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("varchar(95)"); - - b.Property("ApplicationId") - .HasColumnType("varchar(95)"); - - b.Property("AuthorizationId") - .HasColumnType("varchar(95)"); - - b.Property("ConcurrencyToken") - .IsConcurrencyToken() - .HasMaxLength(50) - .HasColumnType("varchar(50)"); - - b.Property("CreationDate") - .HasColumnType("datetime(6)"); - - b.Property("ExpirationDate") - .HasColumnType("datetime(6)"); - - b.Property("Payload") - .HasColumnType("longtext"); - - b.Property("Properties") - .HasColumnType("longtext"); - - b.Property("RedemptionDate") - .HasColumnType("datetime(6)"); - - b.Property("ReferenceId") - .HasMaxLength(100) - .HasColumnType("varchar(100)"); - - b.Property("Status") - .HasMaxLength(50) - .HasColumnType("varchar(50)"); - - b.Property("Subject") - .HasMaxLength(400) - .HasColumnType("varchar(400)"); - - b.Property("Type") - .HasMaxLength(50) - .HasColumnType("varchar(50)"); - - b.HasKey("Id"); - - b.HasIndex("AuthorizationId"); - - b.HasIndex("ReferenceId") - .IsUnique(); - - b.HasIndex("ApplicationId", "Status", "Subject", "Type"); - - b.ToTable("OpenIddictTokens", (string)null); - }); - - modelBuilder.Entity("VirtoCommerce.Platform.Core.Security.ApplicationUser", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasMaxLength(128) - .HasColumnType("varchar(128)"); - - b.Property("AccessFailedCount") - .HasColumnType("int"); - - b.Property("ConcurrencyStamp") - .IsConcurrencyToken() - .HasColumnType("longtext"); - - b.Property("CreatedBy") - .HasColumnType("longtext"); - - b.Property("CreatedDate") - .HasColumnType("datetime(6)"); - - b.Property("Email") - .HasMaxLength(256) - .HasColumnType("varchar(256)"); - - b.Property("EmailConfirmed") - .HasColumnType("tinyint(1)"); - - b.Property("IsAdministrator") - .HasColumnType("tinyint(1)"); - - b.Property("LastPasswordChangeRequestDate") - .HasColumnType("datetime(6)"); - - b.Property("LastPasswordChangedDate") - .HasColumnType("datetime(6)"); - - b.Property("LockoutEnabled") - .HasColumnType("tinyint(1)"); - - b.Property("LockoutEnd") - .HasColumnType("datetime(6)"); - - b.Property("MemberId") - .HasMaxLength(128) - .HasColumnType("varchar(128)"); - - b.Property("ModifiedBy") - .HasColumnType("longtext"); - - b.Property("ModifiedDate") - .HasColumnType("datetime(6)"); - - b.Property("NormalizedEmail") - .HasMaxLength(256) - .HasColumnType("varchar(256)"); - - b.Property("NormalizedUserName") - .HasMaxLength(256) - .HasColumnType("varchar(256)"); - - b.Property("PasswordExpired") - .HasColumnType("tinyint(1)"); - - b.Property("PasswordHash") - .HasColumnType("longtext"); - - b.Property("PhoneNumber") - .HasColumnType("longtext"); - - b.Property("PhoneNumberConfirmed") - .HasColumnType("tinyint(1)"); - - b.Property("PhotoUrl") - .HasMaxLength(2048) - .HasColumnType("varchar(2048)"); - - b.Property("SecurityStamp") - .HasColumnType("longtext"); - - b.Property("Status") - .HasMaxLength(64) - .HasColumnType("varchar(64)"); - - b.Property("StoreId") - .HasMaxLength(128) - .HasColumnType("varchar(128)"); - - b.Property("TwoFactorEnabled") - .HasColumnType("tinyint(1)"); - - b.Property("UserName") - .HasMaxLength(256) - .HasColumnType("varchar(256)"); - - b.Property("UserType") - .HasMaxLength(64) - .HasColumnType("varchar(64)"); - - b.HasKey("Id"); - - b.HasIndex("NormalizedEmail") - .HasDatabaseName("EmailIndex"); - - b.HasIndex("NormalizedUserName") - .IsUnique() - .HasDatabaseName("UserNameIndex"); - - b.ToTable("AspNetUsers", (string)null); - }); - - modelBuilder.Entity("VirtoCommerce.Platform.Core.Security.Role", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasMaxLength(128) - .HasColumnType("varchar(128)"); - - b.Property("ConcurrencyStamp") - .IsConcurrencyToken() - .HasColumnType("longtext"); - - b.Property("Description") - .HasColumnType("longtext"); - - b.Property("Name") - .HasMaxLength(256) - .HasColumnType("varchar(256)"); - - b.Property("NormalizedName") - .HasMaxLength(256) - .HasColumnType("varchar(256)"); - - b.HasKey("Id"); - - b.HasIndex("NormalizedName") - .IsUnique() - .HasDatabaseName("RoleNameIndex"); - - b.ToTable("AspNetRoles", (string)null); - }); - - modelBuilder.Entity("VirtoCommerce.Platform.Security.Model.ServerCertificateEntity", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasMaxLength(128) - .HasColumnType("varchar(128)"); - - b.Property("PrivateKeyCertBase64") - .HasColumnType("longtext"); - - b.Property("PrivateKeyCertPassword") - .HasMaxLength(128) - .HasColumnType("varchar(128)"); - - b.Property("PublicCertBase64") - .HasColumnType("longtext"); - - b.HasKey("Id"); - - b.ToTable("ServerCertificate", (string)null); - }); - - modelBuilder.Entity("VirtoCommerce.Platform.Security.Model.UserApiKeyEntity", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasMaxLength(128) - .HasColumnType("varchar(128)"); - - b.Property("ApiKey") - .HasMaxLength(128) - .HasColumnType("varchar(128)"); - - b.Property("CreatedBy") - .HasMaxLength(64) - .HasColumnType("varchar(64)"); - - b.Property("CreatedDate") - .HasColumnType("datetime(6)"); - - b.Property("IsActive") - .HasColumnType("tinyint(1)"); - - b.Property("ModifiedBy") - .HasMaxLength(64) - .HasColumnType("varchar(64)"); - - b.Property("ModifiedDate") - .HasColumnType("datetime(6)"); - - b.Property("UserId") - .HasColumnType("longtext"); - - b.Property("UserName") - .HasColumnType("longtext"); - - b.HasKey("Id"); - - b.HasIndex("ApiKey") - .IsUnique(); - - b.ToTable("UserApiKey", (string)null); - }); - - modelBuilder.Entity("VirtoCommerce.Platform.Security.Model.UserPasswordHistoryEntity", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasMaxLength(128) - .HasColumnType("varchar(128)"); - - b.Property("CreatedBy") - .HasMaxLength(64) - .HasColumnType("varchar(64)"); - - b.Property("CreatedDate") - .HasColumnType("datetime(6)"); - - b.Property("ModifiedBy") - .HasMaxLength(64) - .HasColumnType("varchar(64)"); - - b.Property("ModifiedDate") - .HasColumnType("datetime(6)"); - - b.Property("PasswordHash") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("UserId") - .HasMaxLength(128) - .HasColumnType("varchar(128)"); - - b.HasKey("Id"); - - b.HasIndex("UserId"); - - b.ToTable("AspNetUserPasswordsHistory", (string)null); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim", b => - { - b.HasOne("VirtoCommerce.Platform.Core.Security.Role", null) - .WithMany() - .HasForeignKey("RoleId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim", b => - { - b.HasOne("VirtoCommerce.Platform.Core.Security.ApplicationUser", null) - .WithMany() - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin", b => - { - b.HasOne("VirtoCommerce.Platform.Core.Security.ApplicationUser", null) - .WithMany() - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole", b => - { - b.HasOne("VirtoCommerce.Platform.Core.Security.Role", null) - .WithMany("UserRoles") - .HasForeignKey("RoleId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("VirtoCommerce.Platform.Core.Security.ApplicationUser", null) - .WithMany("UserRoles") - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken", b => - { - b.HasOne("VirtoCommerce.Platform.Core.Security.ApplicationUser", null) - .WithMany() - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - }); - - modelBuilder.Entity("OpenIddict.EntityFrameworkCore.Models.OpenIddictEntityFrameworkCoreAuthorization", b => - { - b.HasOne("OpenIddict.EntityFrameworkCore.Models.OpenIddictEntityFrameworkCoreApplication", "Application") - .WithMany("Authorizations") - .HasForeignKey("ApplicationId"); - - b.Navigation("Application"); - }); - - modelBuilder.Entity("OpenIddict.EntityFrameworkCore.Models.OpenIddictEntityFrameworkCoreToken", b => - { - b.HasOne("OpenIddict.EntityFrameworkCore.Models.OpenIddictEntityFrameworkCoreApplication", "Application") - .WithMany("Tokens") - .HasForeignKey("ApplicationId"); - - b.HasOne("OpenIddict.EntityFrameworkCore.Models.OpenIddictEntityFrameworkCoreAuthorization", "Authorization") - .WithMany("Tokens") - .HasForeignKey("AuthorizationId"); - - b.Navigation("Application"); - - b.Navigation("Authorization"); - }); - - modelBuilder.Entity("VirtoCommerce.Platform.Security.Model.UserPasswordHistoryEntity", b => - { - b.HasOne("VirtoCommerce.Platform.Core.Security.ApplicationUser", null) - .WithMany() - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Cascade); - }); - - modelBuilder.Entity("OpenIddict.EntityFrameworkCore.Models.OpenIddictEntityFrameworkCoreApplication", b => - { - b.Navigation("Authorizations"); - - b.Navigation("Tokens"); - }); - - modelBuilder.Entity("OpenIddict.EntityFrameworkCore.Models.OpenIddictEntityFrameworkCoreAuthorization", b => - { - b.Navigation("Tokens"); - }); - - modelBuilder.Entity("VirtoCommerce.Platform.Core.Security.ApplicationUser", b => - { - b.Navigation("UserRoles"); - }); - - modelBuilder.Entity("VirtoCommerce.Platform.Core.Security.Role", b => - { - b.Navigation("UserRoles"); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/src/VirtoCommerce.Platform.Security.MySql/VirtoCommerce.Platform.Security.MySql.csproj b/src/VirtoCommerce.Platform.Security.MySql/VirtoCommerce.Platform.Security.MySql.csproj deleted file mode 100644 index c4065eefed2..00000000000 --- a/src/VirtoCommerce.Platform.Security.MySql/VirtoCommerce.Platform.Security.MySql.csproj +++ /dev/null @@ -1,13 +0,0 @@ - - - - net6.0 - enable - enable - - - - - - - diff --git a/src/VirtoCommerce.Platform.Security.PostgreSql/Migrations/20221124131823_Initial.Designer.cs b/src/VirtoCommerce.Platform.Security.PostgreSql/Migrations/20221124131823_Initial.Designer.cs deleted file mode 100644 index 08664edf0ca..00000000000 --- a/src/VirtoCommerce.Platform.Security.PostgreSql/Migrations/20221124131823_Initial.Designer.cs +++ /dev/null @@ -1,687 +0,0 @@ -// -using System; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Migrations; -using Microsoft.EntityFrameworkCore.Storage.ValueConversion; -using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; -using VirtoCommerce.Platform.Security.Repositories; - -#nullable disable - -namespace VirtoCommerce.Platform.Security.PostgreSql.Migrations -{ - [DbContext(typeof(SecurityDbContext))] - [Migration("20221124131823_Initial")] - partial class Initial - { - protected override void BuildTargetModel(ModelBuilder modelBuilder) - { -#pragma warning disable 612, 618 - modelBuilder - .HasAnnotation("ProductVersion", "6.0.0") - .HasAnnotation("Relational:MaxIdentifierLength", 63); - - NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("ClaimType") - .HasColumnType("text"); - - b.Property("ClaimValue") - .HasColumnType("text"); - - b.Property("RoleId") - .IsRequired() - .HasMaxLength(128) - .HasColumnType("character varying(128)"); - - b.HasKey("Id"); - - b.HasIndex("RoleId"); - - b.ToTable("AspNetRoleClaims", (string)null); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("ClaimType") - .HasColumnType("text"); - - b.Property("ClaimValue") - .HasColumnType("text"); - - b.Property("UserId") - .IsRequired() - .HasMaxLength(128) - .HasColumnType("character varying(128)"); - - b.HasKey("Id"); - - b.HasIndex("UserId"); - - b.ToTable("AspNetUserClaims", (string)null); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin", b => - { - b.Property("LoginProvider") - .HasMaxLength(128) - .HasColumnType("character varying(128)"); - - b.Property("ProviderKey") - .HasMaxLength(128) - .HasColumnType("character varying(128)"); - - b.Property("ProviderDisplayName") - .HasColumnType("text"); - - b.Property("UserId") - .IsRequired() - .HasMaxLength(128) - .HasColumnType("character varying(128)"); - - b.HasKey("LoginProvider", "ProviderKey"); - - b.HasIndex("UserId"); - - b.ToTable("AspNetUserLogins", (string)null); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole", b => - { - b.Property("UserId") - .HasMaxLength(128) - .HasColumnType("character varying(128)"); - - b.Property("RoleId") - .HasMaxLength(128) - .HasColumnType("character varying(128)"); - - b.HasKey("UserId", "RoleId"); - - b.HasIndex("RoleId"); - - b.ToTable("AspNetUserRoles", (string)null); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken", b => - { - b.Property("UserId") - .HasMaxLength(128) - .HasColumnType("character varying(128)"); - - b.Property("LoginProvider") - .HasColumnType("text"); - - b.Property("Name") - .HasColumnType("text"); - - b.Property("Value") - .HasColumnType("text"); - - b.HasKey("UserId", "LoginProvider", "Name"); - - b.ToTable("AspNetUserTokens", (string)null); - }); - - modelBuilder.Entity("OpenIddict.EntityFrameworkCore.Models.OpenIddictEntityFrameworkCoreApplication", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("text"); - - b.Property("ClientId") - .HasMaxLength(100) - .HasColumnType("character varying(100)"); - - b.Property("ClientSecret") - .HasColumnType("text"); - - b.Property("ConcurrencyToken") - .IsConcurrencyToken() - .HasMaxLength(50) - .HasColumnType("character varying(50)"); - - b.Property("ConsentType") - .HasMaxLength(50) - .HasColumnType("character varying(50)"); - - b.Property("DisplayName") - .HasColumnType("text"); - - b.Property("DisplayNames") - .HasColumnType("text"); - - b.Property("Permissions") - .HasColumnType("text"); - - b.Property("PostLogoutRedirectUris") - .HasColumnType("text"); - - b.Property("Properties") - .HasColumnType("text"); - - b.Property("RedirectUris") - .HasColumnType("text"); - - b.Property("Requirements") - .HasColumnType("text"); - - b.Property("Type") - .HasMaxLength(50) - .HasColumnType("character varying(50)"); - - b.HasKey("Id"); - - b.HasIndex("ClientId") - .IsUnique(); - - b.ToTable("OpenIddictApplications", (string)null); - }); - - modelBuilder.Entity("OpenIddict.EntityFrameworkCore.Models.OpenIddictEntityFrameworkCoreAuthorization", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("text"); - - b.Property("ApplicationId") - .HasColumnType("text"); - - b.Property("ConcurrencyToken") - .IsConcurrencyToken() - .HasMaxLength(50) - .HasColumnType("character varying(50)"); - - b.Property("CreationDate") - .HasColumnType("timestamp with time zone"); - - b.Property("Properties") - .HasColumnType("text"); - - b.Property("Scopes") - .HasColumnType("text"); - - b.Property("Status") - .HasMaxLength(50) - .HasColumnType("character varying(50)"); - - b.Property("Subject") - .HasMaxLength(400) - .HasColumnType("character varying(400)"); - - b.Property("Type") - .HasMaxLength(50) - .HasColumnType("character varying(50)"); - - b.HasKey("Id"); - - b.HasIndex("ApplicationId", "Status", "Subject", "Type"); - - b.ToTable("OpenIddictAuthorizations", (string)null); - }); - - modelBuilder.Entity("OpenIddict.EntityFrameworkCore.Models.OpenIddictEntityFrameworkCoreScope", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("text"); - - b.Property("ConcurrencyToken") - .IsConcurrencyToken() - .HasMaxLength(50) - .HasColumnType("character varying(50)"); - - b.Property("Description") - .HasColumnType("text"); - - b.Property("Descriptions") - .HasColumnType("text"); - - b.Property("DisplayName") - .HasColumnType("text"); - - b.Property("DisplayNames") - .HasColumnType("text"); - - b.Property("Name") - .HasMaxLength(200) - .HasColumnType("character varying(200)"); - - b.Property("Properties") - .HasColumnType("text"); - - b.Property("Resources") - .HasColumnType("text"); - - b.HasKey("Id"); - - b.HasIndex("Name") - .IsUnique(); - - b.ToTable("OpenIddictScopes", (string)null); - }); - - modelBuilder.Entity("OpenIddict.EntityFrameworkCore.Models.OpenIddictEntityFrameworkCoreToken", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("text"); - - b.Property("ApplicationId") - .HasColumnType("text"); - - b.Property("AuthorizationId") - .HasColumnType("text"); - - b.Property("ConcurrencyToken") - .IsConcurrencyToken() - .HasMaxLength(50) - .HasColumnType("character varying(50)"); - - b.Property("CreationDate") - .HasColumnType("timestamp with time zone"); - - b.Property("ExpirationDate") - .HasColumnType("timestamp with time zone"); - - b.Property("Payload") - .HasColumnType("text"); - - b.Property("Properties") - .HasColumnType("text"); - - b.Property("RedemptionDate") - .HasColumnType("timestamp with time zone"); - - b.Property("ReferenceId") - .HasMaxLength(100) - .HasColumnType("character varying(100)"); - - b.Property("Status") - .HasMaxLength(50) - .HasColumnType("character varying(50)"); - - b.Property("Subject") - .HasMaxLength(400) - .HasColumnType("character varying(400)"); - - b.Property("Type") - .HasMaxLength(50) - .HasColumnType("character varying(50)"); - - b.HasKey("Id"); - - b.HasIndex("AuthorizationId"); - - b.HasIndex("ReferenceId") - .IsUnique(); - - b.HasIndex("ApplicationId", "Status", "Subject", "Type"); - - b.ToTable("OpenIddictTokens", (string)null); - }); - - modelBuilder.Entity("VirtoCommerce.Platform.Core.Security.ApplicationUser", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasMaxLength(128) - .HasColumnType("character varying(128)"); - - b.Property("AccessFailedCount") - .HasColumnType("integer"); - - b.Property("ConcurrencyStamp") - .IsConcurrencyToken() - .HasColumnType("text"); - - b.Property("CreatedBy") - .HasColumnType("text"); - - b.Property("CreatedDate") - .HasColumnType("timestamp with time zone"); - - b.Property("Email") - .HasMaxLength(256) - .HasColumnType("character varying(256)"); - - b.Property("EmailConfirmed") - .HasColumnType("boolean"); - - b.Property("IsAdministrator") - .HasColumnType("boolean"); - - b.Property("LastPasswordChangeRequestDate") - .HasColumnType("timestamp with time zone"); - - b.Property("LastPasswordChangedDate") - .HasColumnType("timestamp with time zone"); - - b.Property("LockoutEnabled") - .HasColumnType("boolean"); - - b.Property("LockoutEnd") - .HasColumnType("timestamp with time zone"); - - b.Property("MemberId") - .HasMaxLength(128) - .HasColumnType("character varying(128)"); - - b.Property("ModifiedBy") - .HasColumnType("text"); - - b.Property("ModifiedDate") - .HasColumnType("timestamp with time zone"); - - b.Property("NormalizedEmail") - .HasMaxLength(256) - .HasColumnType("character varying(256)"); - - b.Property("NormalizedUserName") - .HasMaxLength(256) - .HasColumnType("character varying(256)"); - - b.Property("PasswordExpired") - .HasColumnType("boolean"); - - b.Property("PasswordHash") - .HasColumnType("text"); - - b.Property("PhoneNumber") - .HasColumnType("text"); - - b.Property("PhoneNumberConfirmed") - .HasColumnType("boolean"); - - b.Property("PhotoUrl") - .HasMaxLength(2048) - .HasColumnType("character varying(2048)"); - - b.Property("SecurityStamp") - .HasColumnType("text"); - - b.Property("Status") - .HasMaxLength(64) - .HasColumnType("character varying(64)"); - - b.Property("StoreId") - .HasMaxLength(128) - .HasColumnType("character varying(128)"); - - b.Property("TwoFactorEnabled") - .HasColumnType("boolean"); - - b.Property("UserName") - .HasMaxLength(256) - .HasColumnType("character varying(256)"); - - b.Property("UserType") - .HasMaxLength(64) - .HasColumnType("character varying(64)"); - - b.HasKey("Id"); - - b.HasIndex("NormalizedEmail") - .HasDatabaseName("EmailIndex"); - - b.HasIndex("NormalizedUserName") - .IsUnique() - .HasDatabaseName("UserNameIndex"); - - b.ToTable("AspNetUsers", (string)null); - }); - - modelBuilder.Entity("VirtoCommerce.Platform.Core.Security.Role", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasMaxLength(128) - .HasColumnType("character varying(128)"); - - b.Property("ConcurrencyStamp") - .IsConcurrencyToken() - .HasColumnType("text"); - - b.Property("Description") - .HasColumnType("text"); - - b.Property("Name") - .HasMaxLength(256) - .HasColumnType("character varying(256)"); - - b.Property("NormalizedName") - .HasMaxLength(256) - .HasColumnType("character varying(256)"); - - b.HasKey("Id"); - - b.HasIndex("NormalizedName") - .IsUnique() - .HasDatabaseName("RoleNameIndex"); - - b.ToTable("AspNetRoles", (string)null); - }); - - modelBuilder.Entity("VirtoCommerce.Platform.Security.Model.ServerCertificateEntity", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasMaxLength(128) - .HasColumnType("character varying(128)"); - - b.Property("PrivateKeyCertBase64") - .HasColumnType("text"); - - b.Property("PrivateKeyCertPassword") - .HasMaxLength(128) - .HasColumnType("character varying(128)"); - - b.Property("PublicCertBase64") - .HasColumnType("text"); - - b.HasKey("Id"); - - b.ToTable("ServerCertificate", (string)null); - }); - - modelBuilder.Entity("VirtoCommerce.Platform.Security.Model.UserApiKeyEntity", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasMaxLength(128) - .HasColumnType("character varying(128)"); - - b.Property("ApiKey") - .HasMaxLength(128) - .HasColumnType("character varying(128)"); - - b.Property("CreatedBy") - .HasMaxLength(64) - .HasColumnType("character varying(64)"); - - b.Property("CreatedDate") - .HasColumnType("timestamp with time zone"); - - b.Property("IsActive") - .HasColumnType("boolean"); - - b.Property("ModifiedBy") - .HasMaxLength(64) - .HasColumnType("character varying(64)"); - - b.Property("ModifiedDate") - .HasColumnType("timestamp with time zone"); - - b.Property("UserId") - .HasColumnType("text"); - - b.Property("UserName") - .HasColumnType("text"); - - b.HasKey("Id"); - - b.HasIndex("ApiKey") - .IsUnique(); - - b.ToTable("UserApiKey", (string)null); - }); - - modelBuilder.Entity("VirtoCommerce.Platform.Security.Model.UserPasswordHistoryEntity", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasMaxLength(128) - .HasColumnType("character varying(128)"); - - b.Property("CreatedBy") - .HasMaxLength(64) - .HasColumnType("character varying(64)"); - - b.Property("CreatedDate") - .HasColumnType("timestamp with time zone"); - - b.Property("ModifiedBy") - .HasMaxLength(64) - .HasColumnType("character varying(64)"); - - b.Property("ModifiedDate") - .HasColumnType("timestamp with time zone"); - - b.Property("PasswordHash") - .IsRequired() - .HasColumnType("text"); - - b.Property("UserId") - .HasMaxLength(128) - .HasColumnType("character varying(128)"); - - b.HasKey("Id"); - - b.HasIndex("UserId"); - - b.ToTable("AspNetUserPasswordsHistory", (string)null); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim", b => - { - b.HasOne("VirtoCommerce.Platform.Core.Security.Role", null) - .WithMany() - .HasForeignKey("RoleId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim", b => - { - b.HasOne("VirtoCommerce.Platform.Core.Security.ApplicationUser", null) - .WithMany() - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin", b => - { - b.HasOne("VirtoCommerce.Platform.Core.Security.ApplicationUser", null) - .WithMany() - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole", b => - { - b.HasOne("VirtoCommerce.Platform.Core.Security.Role", null) - .WithMany("UserRoles") - .HasForeignKey("RoleId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("VirtoCommerce.Platform.Core.Security.ApplicationUser", null) - .WithMany("UserRoles") - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken", b => - { - b.HasOne("VirtoCommerce.Platform.Core.Security.ApplicationUser", null) - .WithMany() - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - }); - - modelBuilder.Entity("OpenIddict.EntityFrameworkCore.Models.OpenIddictEntityFrameworkCoreAuthorization", b => - { - b.HasOne("OpenIddict.EntityFrameworkCore.Models.OpenIddictEntityFrameworkCoreApplication", "Application") - .WithMany("Authorizations") - .HasForeignKey("ApplicationId"); - - b.Navigation("Application"); - }); - - modelBuilder.Entity("OpenIddict.EntityFrameworkCore.Models.OpenIddictEntityFrameworkCoreToken", b => - { - b.HasOne("OpenIddict.EntityFrameworkCore.Models.OpenIddictEntityFrameworkCoreApplication", "Application") - .WithMany("Tokens") - .HasForeignKey("ApplicationId"); - - b.HasOne("OpenIddict.EntityFrameworkCore.Models.OpenIddictEntityFrameworkCoreAuthorization", "Authorization") - .WithMany("Tokens") - .HasForeignKey("AuthorizationId"); - - b.Navigation("Application"); - - b.Navigation("Authorization"); - }); - - modelBuilder.Entity("VirtoCommerce.Platform.Security.Model.UserPasswordHistoryEntity", b => - { - b.HasOne("VirtoCommerce.Platform.Core.Security.ApplicationUser", null) - .WithMany() - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Cascade); - }); - - modelBuilder.Entity("OpenIddict.EntityFrameworkCore.Models.OpenIddictEntityFrameworkCoreApplication", b => - { - b.Navigation("Authorizations"); - - b.Navigation("Tokens"); - }); - - modelBuilder.Entity("OpenIddict.EntityFrameworkCore.Models.OpenIddictEntityFrameworkCoreAuthorization", b => - { - b.Navigation("Tokens"); - }); - - modelBuilder.Entity("VirtoCommerce.Platform.Core.Security.ApplicationUser", b => - { - b.Navigation("UserRoles"); - }); - - modelBuilder.Entity("VirtoCommerce.Platform.Core.Security.Role", b => - { - b.Navigation("UserRoles"); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/src/VirtoCommerce.Platform.Security.PostgreSql/Migrations/20221124131823_Initial.cs b/src/VirtoCommerce.Platform.Security.PostgreSql/Migrations/20221124131823_Initial.cs deleted file mode 100644 index 45afdc485ce..00000000000 --- a/src/VirtoCommerce.Platform.Security.PostgreSql/Migrations/20221124131823_Initial.cs +++ /dev/null @@ -1,454 +0,0 @@ -using System; -using Microsoft.EntityFrameworkCore.Migrations; -using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; - -#nullable disable - -namespace VirtoCommerce.Platform.Security.PostgreSql.Migrations -{ - public partial class Initial : Migration - { - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.CreateTable( - name: "AspNetRoles", - columns: table => new - { - Id = table.Column(type: "character varying(128)", maxLength: 128, nullable: false), - Description = table.Column(type: "text", nullable: true), - Name = table.Column(type: "character varying(256)", maxLength: 256, nullable: true), - NormalizedName = table.Column(type: "character varying(256)", maxLength: 256, nullable: true), - ConcurrencyStamp = table.Column(type: "text", nullable: true) - }, - constraints: table => - { - table.PrimaryKey("PK_AspNetRoles", x => x.Id); - }); - - migrationBuilder.CreateTable( - name: "AspNetUsers", - columns: table => new - { - Id = table.Column(type: "character varying(128)", maxLength: 128, nullable: false), - StoreId = table.Column(type: "character varying(128)", maxLength: 128, nullable: true), - MemberId = table.Column(type: "character varying(128)", maxLength: 128, nullable: true), - IsAdministrator = table.Column(type: "boolean", nullable: false), - PhotoUrl = table.Column(type: "character varying(2048)", maxLength: 2048, nullable: true), - UserType = table.Column(type: "character varying(64)", maxLength: 64, nullable: true), - Status = table.Column(type: "character varying(64)", maxLength: 64, nullable: true), - CreatedDate = table.Column(type: "timestamp with time zone", nullable: false), - ModifiedDate = table.Column(type: "timestamp with time zone", nullable: true), - CreatedBy = table.Column(type: "text", nullable: true), - ModifiedBy = table.Column(type: "text", nullable: true), - PasswordExpired = table.Column(type: "boolean", nullable: false), - LastPasswordChangedDate = table.Column(type: "timestamp with time zone", nullable: true), - LastPasswordChangeRequestDate = table.Column(type: "timestamp with time zone", nullable: true), - UserName = table.Column(type: "character varying(256)", maxLength: 256, nullable: true), - NormalizedUserName = table.Column(type: "character varying(256)", maxLength: 256, nullable: true), - Email = table.Column(type: "character varying(256)", maxLength: 256, nullable: true), - NormalizedEmail = table.Column(type: "character varying(256)", maxLength: 256, nullable: true), - EmailConfirmed = table.Column(type: "boolean", nullable: false), - PasswordHash = table.Column(type: "text", nullable: true), - SecurityStamp = table.Column(type: "text", nullable: true), - ConcurrencyStamp = table.Column(type: "text", nullable: true), - PhoneNumber = table.Column(type: "text", nullable: true), - PhoneNumberConfirmed = table.Column(type: "boolean", nullable: false), - TwoFactorEnabled = table.Column(type: "boolean", nullable: false), - LockoutEnd = table.Column(type: "timestamp with time zone", nullable: true), - LockoutEnabled = table.Column(type: "boolean", nullable: false), - AccessFailedCount = table.Column(type: "integer", nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_AspNetUsers", x => x.Id); - }); - - migrationBuilder.CreateTable( - name: "OpenIddictApplications", - columns: table => new - { - Id = table.Column(type: "text", nullable: false), - ClientId = table.Column(type: "character varying(100)", maxLength: 100, nullable: true), - ClientSecret = table.Column(type: "text", nullable: true), - ConcurrencyToken = table.Column(type: "character varying(50)", maxLength: 50, nullable: true), - ConsentType = table.Column(type: "character varying(50)", maxLength: 50, nullable: true), - DisplayName = table.Column(type: "text", nullable: true), - DisplayNames = table.Column(type: "text", nullable: true), - Permissions = table.Column(type: "text", nullable: true), - PostLogoutRedirectUris = table.Column(type: "text", nullable: true), - Properties = table.Column(type: "text", nullable: true), - RedirectUris = table.Column(type: "text", nullable: true), - Requirements = table.Column(type: "text", nullable: true), - Type = table.Column(type: "character varying(50)", maxLength: 50, nullable: true) - }, - constraints: table => - { - table.PrimaryKey("PK_OpenIddictApplications", x => x.Id); - }); - - migrationBuilder.CreateTable( - name: "OpenIddictScopes", - columns: table => new - { - Id = table.Column(type: "text", nullable: false), - ConcurrencyToken = table.Column(type: "character varying(50)", maxLength: 50, nullable: true), - Description = table.Column(type: "text", nullable: true), - Descriptions = table.Column(type: "text", nullable: true), - DisplayName = table.Column(type: "text", nullable: true), - DisplayNames = table.Column(type: "text", nullable: true), - Name = table.Column(type: "character varying(200)", maxLength: 200, nullable: true), - Properties = table.Column(type: "text", nullable: true), - Resources = table.Column(type: "text", nullable: true) - }, - constraints: table => - { - table.PrimaryKey("PK_OpenIddictScopes", x => x.Id); - }); - - migrationBuilder.CreateTable( - name: "ServerCertificate", - columns: table => new - { - Id = table.Column(type: "character varying(128)", maxLength: 128, nullable: false), - PublicCertBase64 = table.Column(type: "text", nullable: true), - PrivateKeyCertBase64 = table.Column(type: "text", nullable: true), - PrivateKeyCertPassword = table.Column(type: "character varying(128)", maxLength: 128, nullable: true) - }, - constraints: table => - { - table.PrimaryKey("PK_ServerCertificate", x => x.Id); - }); - - migrationBuilder.CreateTable( - name: "UserApiKey", - columns: table => new - { - Id = table.Column(type: "character varying(128)", maxLength: 128, nullable: false), - UserName = table.Column(type: "text", nullable: true), - ApiKey = table.Column(type: "character varying(128)", maxLength: 128, nullable: true), - UserId = table.Column(type: "text", nullable: true), - IsActive = table.Column(type: "boolean", nullable: false), - CreatedDate = table.Column(type: "timestamp with time zone", nullable: false), - ModifiedDate = table.Column(type: "timestamp with time zone", nullable: true), - CreatedBy = table.Column(type: "character varying(64)", maxLength: 64, nullable: true), - ModifiedBy = table.Column(type: "character varying(64)", maxLength: 64, nullable: true) - }, - constraints: table => - { - table.PrimaryKey("PK_UserApiKey", x => x.Id); - }); - - migrationBuilder.CreateTable( - name: "AspNetRoleClaims", - columns: table => new - { - Id = table.Column(type: "integer", nullable: false) - .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), - RoleId = table.Column(type: "character varying(128)", maxLength: 128, nullable: false), - ClaimType = table.Column(type: "text", nullable: true), - ClaimValue = table.Column(type: "text", nullable: true) - }, - constraints: table => - { - table.PrimaryKey("PK_AspNetRoleClaims", x => x.Id); - table.ForeignKey( - name: "FK_AspNetRoleClaims_AspNetRoles_RoleId", - column: x => x.RoleId, - principalTable: "AspNetRoles", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateTable( - name: "AspNetUserClaims", - columns: table => new - { - Id = table.Column(type: "integer", nullable: false) - .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), - UserId = table.Column(type: "character varying(128)", maxLength: 128, nullable: false), - ClaimType = table.Column(type: "text", nullable: true), - ClaimValue = table.Column(type: "text", nullable: true) - }, - constraints: table => - { - table.PrimaryKey("PK_AspNetUserClaims", x => x.Id); - table.ForeignKey( - name: "FK_AspNetUserClaims_AspNetUsers_UserId", - column: x => x.UserId, - principalTable: "AspNetUsers", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateTable( - name: "AspNetUserLogins", - columns: table => new - { - LoginProvider = table.Column(type: "character varying(128)", maxLength: 128, nullable: false), - ProviderKey = table.Column(type: "character varying(128)", maxLength: 128, nullable: false), - ProviderDisplayName = table.Column(type: "text", nullable: true), - UserId = table.Column(type: "character varying(128)", maxLength: 128, nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_AspNetUserLogins", x => new { x.LoginProvider, x.ProviderKey }); - table.ForeignKey( - name: "FK_AspNetUserLogins_AspNetUsers_UserId", - column: x => x.UserId, - principalTable: "AspNetUsers", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateTable( - name: "AspNetUserPasswordsHistory", - columns: table => new - { - Id = table.Column(type: "character varying(128)", maxLength: 128, nullable: false), - UserId = table.Column(type: "character varying(128)", maxLength: 128, nullable: true), - PasswordHash = table.Column(type: "text", nullable: false), - CreatedDate = table.Column(type: "timestamp with time zone", nullable: false), - ModifiedDate = table.Column(type: "timestamp with time zone", nullable: true), - CreatedBy = table.Column(type: "character varying(64)", maxLength: 64, nullable: true), - ModifiedBy = table.Column(type: "character varying(64)", maxLength: 64, nullable: true) - }, - constraints: table => - { - table.PrimaryKey("PK_AspNetUserPasswordsHistory", x => x.Id); - table.ForeignKey( - name: "FK_AspNetUserPasswordsHistory_AspNetUsers_UserId", - column: x => x.UserId, - principalTable: "AspNetUsers", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateTable( - name: "AspNetUserRoles", - columns: table => new - { - UserId = table.Column(type: "character varying(128)", maxLength: 128, nullable: false), - RoleId = table.Column(type: "character varying(128)", maxLength: 128, nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_AspNetUserRoles", x => new { x.UserId, x.RoleId }); - table.ForeignKey( - name: "FK_AspNetUserRoles_AspNetRoles_RoleId", - column: x => x.RoleId, - principalTable: "AspNetRoles", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - table.ForeignKey( - name: "FK_AspNetUserRoles_AspNetUsers_UserId", - column: x => x.UserId, - principalTable: "AspNetUsers", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateTable( - name: "AspNetUserTokens", - columns: table => new - { - UserId = table.Column(type: "character varying(128)", maxLength: 128, nullable: false), - LoginProvider = table.Column(type: "text", nullable: false), - Name = table.Column(type: "text", nullable: false), - Value = table.Column(type: "text", nullable: true) - }, - constraints: table => - { - table.PrimaryKey("PK_AspNetUserTokens", x => new { x.UserId, x.LoginProvider, x.Name }); - table.ForeignKey( - name: "FK_AspNetUserTokens_AspNetUsers_UserId", - column: x => x.UserId, - principalTable: "AspNetUsers", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateTable( - name: "OpenIddictAuthorizations", - columns: table => new - { - Id = table.Column(type: "text", nullable: false), - ApplicationId = table.Column(type: "text", nullable: true), - ConcurrencyToken = table.Column(type: "character varying(50)", maxLength: 50, nullable: true), - CreationDate = table.Column(type: "timestamp with time zone", nullable: true), - Properties = table.Column(type: "text", nullable: true), - Scopes = table.Column(type: "text", nullable: true), - Status = table.Column(type: "character varying(50)", maxLength: 50, nullable: true), - Subject = table.Column(type: "character varying(400)", maxLength: 400, nullable: true), - Type = table.Column(type: "character varying(50)", maxLength: 50, nullable: true) - }, - constraints: table => - { - table.PrimaryKey("PK_OpenIddictAuthorizations", x => x.Id); - table.ForeignKey( - name: "FK_OpenIddictAuthorizations_OpenIddictApplications_Application~", - column: x => x.ApplicationId, - principalTable: "OpenIddictApplications", - principalColumn: "Id"); - }); - - migrationBuilder.CreateTable( - name: "OpenIddictTokens", - columns: table => new - { - Id = table.Column(type: "text", nullable: false), - ApplicationId = table.Column(type: "text", nullable: true), - AuthorizationId = table.Column(type: "text", nullable: true), - ConcurrencyToken = table.Column(type: "character varying(50)", maxLength: 50, nullable: true), - CreationDate = table.Column(type: "timestamp with time zone", nullable: true), - ExpirationDate = table.Column(type: "timestamp with time zone", nullable: true), - Payload = table.Column(type: "text", nullable: true), - Properties = table.Column(type: "text", nullable: true), - RedemptionDate = table.Column(type: "timestamp with time zone", nullable: true), - ReferenceId = table.Column(type: "character varying(100)", maxLength: 100, nullable: true), - Status = table.Column(type: "character varying(50)", maxLength: 50, nullable: true), - Subject = table.Column(type: "character varying(400)", maxLength: 400, nullable: true), - Type = table.Column(type: "character varying(50)", maxLength: 50, nullable: true) - }, - constraints: table => - { - table.PrimaryKey("PK_OpenIddictTokens", x => x.Id); - table.ForeignKey( - name: "FK_OpenIddictTokens_OpenIddictApplications_ApplicationId", - column: x => x.ApplicationId, - principalTable: "OpenIddictApplications", - principalColumn: "Id"); - table.ForeignKey( - name: "FK_OpenIddictTokens_OpenIddictAuthorizations_AuthorizationId", - column: x => x.AuthorizationId, - principalTable: "OpenIddictAuthorizations", - principalColumn: "Id"); - }); - - migrationBuilder.CreateIndex( - name: "IX_AspNetRoleClaims_RoleId", - table: "AspNetRoleClaims", - column: "RoleId"); - - migrationBuilder.CreateIndex( - name: "RoleNameIndex", - table: "AspNetRoles", - column: "NormalizedName", - unique: true); - - migrationBuilder.CreateIndex( - name: "IX_AspNetUserClaims_UserId", - table: "AspNetUserClaims", - column: "UserId"); - - migrationBuilder.CreateIndex( - name: "IX_AspNetUserLogins_UserId", - table: "AspNetUserLogins", - column: "UserId"); - - migrationBuilder.CreateIndex( - name: "IX_AspNetUserPasswordsHistory_UserId", - table: "AspNetUserPasswordsHistory", - column: "UserId"); - - migrationBuilder.CreateIndex( - name: "IX_AspNetUserRoles_RoleId", - table: "AspNetUserRoles", - column: "RoleId"); - - migrationBuilder.CreateIndex( - name: "EmailIndex", - table: "AspNetUsers", - column: "NormalizedEmail"); - - migrationBuilder.CreateIndex( - name: "UserNameIndex", - table: "AspNetUsers", - column: "NormalizedUserName", - unique: true); - - migrationBuilder.CreateIndex( - name: "IX_OpenIddictApplications_ClientId", - table: "OpenIddictApplications", - column: "ClientId", - unique: true); - - migrationBuilder.CreateIndex( - name: "IX_OpenIddictAuthorizations_ApplicationId_Status_Subject_Type", - table: "OpenIddictAuthorizations", - columns: new[] { "ApplicationId", "Status", "Subject", "Type" }); - - migrationBuilder.CreateIndex( - name: "IX_OpenIddictScopes_Name", - table: "OpenIddictScopes", - column: "Name", - unique: true); - - migrationBuilder.CreateIndex( - name: "IX_OpenIddictTokens_ApplicationId_Status_Subject_Type", - table: "OpenIddictTokens", - columns: new[] { "ApplicationId", "Status", "Subject", "Type" }); - - migrationBuilder.CreateIndex( - name: "IX_OpenIddictTokens_AuthorizationId", - table: "OpenIddictTokens", - column: "AuthorizationId"); - - migrationBuilder.CreateIndex( - name: "IX_OpenIddictTokens_ReferenceId", - table: "OpenIddictTokens", - column: "ReferenceId", - unique: true); - - migrationBuilder.CreateIndex( - name: "IX_UserApiKey_ApiKey", - table: "UserApiKey", - column: "ApiKey", - unique: true); - } - - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropTable( - name: "AspNetRoleClaims"); - - migrationBuilder.DropTable( - name: "AspNetUserClaims"); - - migrationBuilder.DropTable( - name: "AspNetUserLogins"); - - migrationBuilder.DropTable( - name: "AspNetUserPasswordsHistory"); - - migrationBuilder.DropTable( - name: "AspNetUserRoles"); - - migrationBuilder.DropTable( - name: "AspNetUserTokens"); - - migrationBuilder.DropTable( - name: "OpenIddictScopes"); - - migrationBuilder.DropTable( - name: "OpenIddictTokens"); - - migrationBuilder.DropTable( - name: "ServerCertificate"); - - migrationBuilder.DropTable( - name: "UserApiKey"); - - migrationBuilder.DropTable( - name: "AspNetRoles"); - - migrationBuilder.DropTable( - name: "AspNetUsers"); - - migrationBuilder.DropTable( - name: "OpenIddictAuthorizations"); - - migrationBuilder.DropTable( - name: "OpenIddictApplications"); - } - } -} diff --git a/src/VirtoCommerce.Platform.Security.PostgreSql/Migrations/SecurityDbContextModelSnapshot.cs b/src/VirtoCommerce.Platform.Security.PostgreSql/Migrations/SecurityDbContextModelSnapshot.cs deleted file mode 100644 index b50b1567849..00000000000 --- a/src/VirtoCommerce.Platform.Security.PostgreSql/Migrations/SecurityDbContextModelSnapshot.cs +++ /dev/null @@ -1,685 +0,0 @@ -// -using System; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Storage.ValueConversion; -using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; -using VirtoCommerce.Platform.Security.Repositories; - -#nullable disable - -namespace VirtoCommerce.Platform.Security.PostgreSql.Migrations -{ - [DbContext(typeof(SecurityDbContext))] - partial class SecurityDbContextModelSnapshot : ModelSnapshot - { - protected override void BuildModel(ModelBuilder modelBuilder) - { -#pragma warning disable 612, 618 - modelBuilder - .HasAnnotation("ProductVersion", "6.0.0") - .HasAnnotation("Relational:MaxIdentifierLength", 63); - - NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("ClaimType") - .HasColumnType("text"); - - b.Property("ClaimValue") - .HasColumnType("text"); - - b.Property("RoleId") - .IsRequired() - .HasMaxLength(128) - .HasColumnType("character varying(128)"); - - b.HasKey("Id"); - - b.HasIndex("RoleId"); - - b.ToTable("AspNetRoleClaims", (string)null); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("ClaimType") - .HasColumnType("text"); - - b.Property("ClaimValue") - .HasColumnType("text"); - - b.Property("UserId") - .IsRequired() - .HasMaxLength(128) - .HasColumnType("character varying(128)"); - - b.HasKey("Id"); - - b.HasIndex("UserId"); - - b.ToTable("AspNetUserClaims", (string)null); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin", b => - { - b.Property("LoginProvider") - .HasMaxLength(128) - .HasColumnType("character varying(128)"); - - b.Property("ProviderKey") - .HasMaxLength(128) - .HasColumnType("character varying(128)"); - - b.Property("ProviderDisplayName") - .HasColumnType("text"); - - b.Property("UserId") - .IsRequired() - .HasMaxLength(128) - .HasColumnType("character varying(128)"); - - b.HasKey("LoginProvider", "ProviderKey"); - - b.HasIndex("UserId"); - - b.ToTable("AspNetUserLogins", (string)null); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole", b => - { - b.Property("UserId") - .HasMaxLength(128) - .HasColumnType("character varying(128)"); - - b.Property("RoleId") - .HasMaxLength(128) - .HasColumnType("character varying(128)"); - - b.HasKey("UserId", "RoleId"); - - b.HasIndex("RoleId"); - - b.ToTable("AspNetUserRoles", (string)null); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken", b => - { - b.Property("UserId") - .HasMaxLength(128) - .HasColumnType("character varying(128)"); - - b.Property("LoginProvider") - .HasColumnType("text"); - - b.Property("Name") - .HasColumnType("text"); - - b.Property("Value") - .HasColumnType("text"); - - b.HasKey("UserId", "LoginProvider", "Name"); - - b.ToTable("AspNetUserTokens", (string)null); - }); - - modelBuilder.Entity("OpenIddict.EntityFrameworkCore.Models.OpenIddictEntityFrameworkCoreApplication", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("text"); - - b.Property("ClientId") - .HasMaxLength(100) - .HasColumnType("character varying(100)"); - - b.Property("ClientSecret") - .HasColumnType("text"); - - b.Property("ConcurrencyToken") - .IsConcurrencyToken() - .HasMaxLength(50) - .HasColumnType("character varying(50)"); - - b.Property("ConsentType") - .HasMaxLength(50) - .HasColumnType("character varying(50)"); - - b.Property("DisplayName") - .HasColumnType("text"); - - b.Property("DisplayNames") - .HasColumnType("text"); - - b.Property("Permissions") - .HasColumnType("text"); - - b.Property("PostLogoutRedirectUris") - .HasColumnType("text"); - - b.Property("Properties") - .HasColumnType("text"); - - b.Property("RedirectUris") - .HasColumnType("text"); - - b.Property("Requirements") - .HasColumnType("text"); - - b.Property("Type") - .HasMaxLength(50) - .HasColumnType("character varying(50)"); - - b.HasKey("Id"); - - b.HasIndex("ClientId") - .IsUnique(); - - b.ToTable("OpenIddictApplications", (string)null); - }); - - modelBuilder.Entity("OpenIddict.EntityFrameworkCore.Models.OpenIddictEntityFrameworkCoreAuthorization", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("text"); - - b.Property("ApplicationId") - .HasColumnType("text"); - - b.Property("ConcurrencyToken") - .IsConcurrencyToken() - .HasMaxLength(50) - .HasColumnType("character varying(50)"); - - b.Property("CreationDate") - .HasColumnType("timestamp with time zone"); - - b.Property("Properties") - .HasColumnType("text"); - - b.Property("Scopes") - .HasColumnType("text"); - - b.Property("Status") - .HasMaxLength(50) - .HasColumnType("character varying(50)"); - - b.Property("Subject") - .HasMaxLength(400) - .HasColumnType("character varying(400)"); - - b.Property("Type") - .HasMaxLength(50) - .HasColumnType("character varying(50)"); - - b.HasKey("Id"); - - b.HasIndex("ApplicationId", "Status", "Subject", "Type"); - - b.ToTable("OpenIddictAuthorizations", (string)null); - }); - - modelBuilder.Entity("OpenIddict.EntityFrameworkCore.Models.OpenIddictEntityFrameworkCoreScope", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("text"); - - b.Property("ConcurrencyToken") - .IsConcurrencyToken() - .HasMaxLength(50) - .HasColumnType("character varying(50)"); - - b.Property("Description") - .HasColumnType("text"); - - b.Property("Descriptions") - .HasColumnType("text"); - - b.Property("DisplayName") - .HasColumnType("text"); - - b.Property("DisplayNames") - .HasColumnType("text"); - - b.Property("Name") - .HasMaxLength(200) - .HasColumnType("character varying(200)"); - - b.Property("Properties") - .HasColumnType("text"); - - b.Property("Resources") - .HasColumnType("text"); - - b.HasKey("Id"); - - b.HasIndex("Name") - .IsUnique(); - - b.ToTable("OpenIddictScopes", (string)null); - }); - - modelBuilder.Entity("OpenIddict.EntityFrameworkCore.Models.OpenIddictEntityFrameworkCoreToken", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("text"); - - b.Property("ApplicationId") - .HasColumnType("text"); - - b.Property("AuthorizationId") - .HasColumnType("text"); - - b.Property("ConcurrencyToken") - .IsConcurrencyToken() - .HasMaxLength(50) - .HasColumnType("character varying(50)"); - - b.Property("CreationDate") - .HasColumnType("timestamp with time zone"); - - b.Property("ExpirationDate") - .HasColumnType("timestamp with time zone"); - - b.Property("Payload") - .HasColumnType("text"); - - b.Property("Properties") - .HasColumnType("text"); - - b.Property("RedemptionDate") - .HasColumnType("timestamp with time zone"); - - b.Property("ReferenceId") - .HasMaxLength(100) - .HasColumnType("character varying(100)"); - - b.Property("Status") - .HasMaxLength(50) - .HasColumnType("character varying(50)"); - - b.Property("Subject") - .HasMaxLength(400) - .HasColumnType("character varying(400)"); - - b.Property("Type") - .HasMaxLength(50) - .HasColumnType("character varying(50)"); - - b.HasKey("Id"); - - b.HasIndex("AuthorizationId"); - - b.HasIndex("ReferenceId") - .IsUnique(); - - b.HasIndex("ApplicationId", "Status", "Subject", "Type"); - - b.ToTable("OpenIddictTokens", (string)null); - }); - - modelBuilder.Entity("VirtoCommerce.Platform.Core.Security.ApplicationUser", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasMaxLength(128) - .HasColumnType("character varying(128)"); - - b.Property("AccessFailedCount") - .HasColumnType("integer"); - - b.Property("ConcurrencyStamp") - .IsConcurrencyToken() - .HasColumnType("text"); - - b.Property("CreatedBy") - .HasColumnType("text"); - - b.Property("CreatedDate") - .HasColumnType("timestamp with time zone"); - - b.Property("Email") - .HasMaxLength(256) - .HasColumnType("character varying(256)"); - - b.Property("EmailConfirmed") - .HasColumnType("boolean"); - - b.Property("IsAdministrator") - .HasColumnType("boolean"); - - b.Property("LastPasswordChangeRequestDate") - .HasColumnType("timestamp with time zone"); - - b.Property("LastPasswordChangedDate") - .HasColumnType("timestamp with time zone"); - - b.Property("LockoutEnabled") - .HasColumnType("boolean"); - - b.Property("LockoutEnd") - .HasColumnType("timestamp with time zone"); - - b.Property("MemberId") - .HasMaxLength(128) - .HasColumnType("character varying(128)"); - - b.Property("ModifiedBy") - .HasColumnType("text"); - - b.Property("ModifiedDate") - .HasColumnType("timestamp with time zone"); - - b.Property("NormalizedEmail") - .HasMaxLength(256) - .HasColumnType("character varying(256)"); - - b.Property("NormalizedUserName") - .HasMaxLength(256) - .HasColumnType("character varying(256)"); - - b.Property("PasswordExpired") - .HasColumnType("boolean"); - - b.Property("PasswordHash") - .HasColumnType("text"); - - b.Property("PhoneNumber") - .HasColumnType("text"); - - b.Property("PhoneNumberConfirmed") - .HasColumnType("boolean"); - - b.Property("PhotoUrl") - .HasMaxLength(2048) - .HasColumnType("character varying(2048)"); - - b.Property("SecurityStamp") - .HasColumnType("text"); - - b.Property("Status") - .HasMaxLength(64) - .HasColumnType("character varying(64)"); - - b.Property("StoreId") - .HasMaxLength(128) - .HasColumnType("character varying(128)"); - - b.Property("TwoFactorEnabled") - .HasColumnType("boolean"); - - b.Property("UserName") - .HasMaxLength(256) - .HasColumnType("character varying(256)"); - - b.Property("UserType") - .HasMaxLength(64) - .HasColumnType("character varying(64)"); - - b.HasKey("Id"); - - b.HasIndex("NormalizedEmail") - .HasDatabaseName("EmailIndex"); - - b.HasIndex("NormalizedUserName") - .IsUnique() - .HasDatabaseName("UserNameIndex"); - - b.ToTable("AspNetUsers", (string)null); - }); - - modelBuilder.Entity("VirtoCommerce.Platform.Core.Security.Role", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasMaxLength(128) - .HasColumnType("character varying(128)"); - - b.Property("ConcurrencyStamp") - .IsConcurrencyToken() - .HasColumnType("text"); - - b.Property("Description") - .HasColumnType("text"); - - b.Property("Name") - .HasMaxLength(256) - .HasColumnType("character varying(256)"); - - b.Property("NormalizedName") - .HasMaxLength(256) - .HasColumnType("character varying(256)"); - - b.HasKey("Id"); - - b.HasIndex("NormalizedName") - .IsUnique() - .HasDatabaseName("RoleNameIndex"); - - b.ToTable("AspNetRoles", (string)null); - }); - - modelBuilder.Entity("VirtoCommerce.Platform.Security.Model.ServerCertificateEntity", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasMaxLength(128) - .HasColumnType("character varying(128)"); - - b.Property("PrivateKeyCertBase64") - .HasColumnType("text"); - - b.Property("PrivateKeyCertPassword") - .HasMaxLength(128) - .HasColumnType("character varying(128)"); - - b.Property("PublicCertBase64") - .HasColumnType("text"); - - b.HasKey("Id"); - - b.ToTable("ServerCertificate", (string)null); - }); - - modelBuilder.Entity("VirtoCommerce.Platform.Security.Model.UserApiKeyEntity", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasMaxLength(128) - .HasColumnType("character varying(128)"); - - b.Property("ApiKey") - .HasMaxLength(128) - .HasColumnType("character varying(128)"); - - b.Property("CreatedBy") - .HasMaxLength(64) - .HasColumnType("character varying(64)"); - - b.Property("CreatedDate") - .HasColumnType("timestamp with time zone"); - - b.Property("IsActive") - .HasColumnType("boolean"); - - b.Property("ModifiedBy") - .HasMaxLength(64) - .HasColumnType("character varying(64)"); - - b.Property("ModifiedDate") - .HasColumnType("timestamp with time zone"); - - b.Property("UserId") - .HasColumnType("text"); - - b.Property("UserName") - .HasColumnType("text"); - - b.HasKey("Id"); - - b.HasIndex("ApiKey") - .IsUnique(); - - b.ToTable("UserApiKey", (string)null); - }); - - modelBuilder.Entity("VirtoCommerce.Platform.Security.Model.UserPasswordHistoryEntity", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasMaxLength(128) - .HasColumnType("character varying(128)"); - - b.Property("CreatedBy") - .HasMaxLength(64) - .HasColumnType("character varying(64)"); - - b.Property("CreatedDate") - .HasColumnType("timestamp with time zone"); - - b.Property("ModifiedBy") - .HasMaxLength(64) - .HasColumnType("character varying(64)"); - - b.Property("ModifiedDate") - .HasColumnType("timestamp with time zone"); - - b.Property("PasswordHash") - .IsRequired() - .HasColumnType("text"); - - b.Property("UserId") - .HasMaxLength(128) - .HasColumnType("character varying(128)"); - - b.HasKey("Id"); - - b.HasIndex("UserId"); - - b.ToTable("AspNetUserPasswordsHistory", (string)null); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim", b => - { - b.HasOne("VirtoCommerce.Platform.Core.Security.Role", null) - .WithMany() - .HasForeignKey("RoleId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim", b => - { - b.HasOne("VirtoCommerce.Platform.Core.Security.ApplicationUser", null) - .WithMany() - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin", b => - { - b.HasOne("VirtoCommerce.Platform.Core.Security.ApplicationUser", null) - .WithMany() - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole", b => - { - b.HasOne("VirtoCommerce.Platform.Core.Security.Role", null) - .WithMany("UserRoles") - .HasForeignKey("RoleId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("VirtoCommerce.Platform.Core.Security.ApplicationUser", null) - .WithMany("UserRoles") - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken", b => - { - b.HasOne("VirtoCommerce.Platform.Core.Security.ApplicationUser", null) - .WithMany() - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - }); - - modelBuilder.Entity("OpenIddict.EntityFrameworkCore.Models.OpenIddictEntityFrameworkCoreAuthorization", b => - { - b.HasOne("OpenIddict.EntityFrameworkCore.Models.OpenIddictEntityFrameworkCoreApplication", "Application") - .WithMany("Authorizations") - .HasForeignKey("ApplicationId"); - - b.Navigation("Application"); - }); - - modelBuilder.Entity("OpenIddict.EntityFrameworkCore.Models.OpenIddictEntityFrameworkCoreToken", b => - { - b.HasOne("OpenIddict.EntityFrameworkCore.Models.OpenIddictEntityFrameworkCoreApplication", "Application") - .WithMany("Tokens") - .HasForeignKey("ApplicationId"); - - b.HasOne("OpenIddict.EntityFrameworkCore.Models.OpenIddictEntityFrameworkCoreAuthorization", "Authorization") - .WithMany("Tokens") - .HasForeignKey("AuthorizationId"); - - b.Navigation("Application"); - - b.Navigation("Authorization"); - }); - - modelBuilder.Entity("VirtoCommerce.Platform.Security.Model.UserPasswordHistoryEntity", b => - { - b.HasOne("VirtoCommerce.Platform.Core.Security.ApplicationUser", null) - .WithMany() - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Cascade); - }); - - modelBuilder.Entity("OpenIddict.EntityFrameworkCore.Models.OpenIddictEntityFrameworkCoreApplication", b => - { - b.Navigation("Authorizations"); - - b.Navigation("Tokens"); - }); - - modelBuilder.Entity("OpenIddict.EntityFrameworkCore.Models.OpenIddictEntityFrameworkCoreAuthorization", b => - { - b.Navigation("Tokens"); - }); - - modelBuilder.Entity("VirtoCommerce.Platform.Core.Security.ApplicationUser", b => - { - b.Navigation("UserRoles"); - }); - - modelBuilder.Entity("VirtoCommerce.Platform.Core.Security.Role", b => - { - b.Navigation("UserRoles"); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/src/VirtoCommerce.Platform.Security.PostgreSql/VirtoCommerce.Platform.Security.PostgreSql.csproj b/src/VirtoCommerce.Platform.Security.PostgreSql/VirtoCommerce.Platform.Security.PostgreSql.csproj deleted file mode 100644 index c4065eefed2..00000000000 --- a/src/VirtoCommerce.Platform.Security.PostgreSql/VirtoCommerce.Platform.Security.PostgreSql.csproj +++ /dev/null @@ -1,13 +0,0 @@ - - - - net6.0 - enable - enable - - - - - - - diff --git a/src/VirtoCommerce.Platform.Security/CustomUserManager.cs b/src/VirtoCommerce.Platform.Security/CustomUserManager.cs index f6c9b122fb4..2a4c070a4c2 100644 --- a/src/VirtoCommerce.Platform.Security/CustomUserManager.cs +++ b/src/VirtoCommerce.Platform.Security/CustomUserManager.cs @@ -376,9 +376,6 @@ protected virtual async Task LoadUserDetailsAsync(ApplicationUser user) } } - // Read claims and convert to permissions (compatibility with v2) - user.Permissions = user.Roles.SelectMany(x => x.Permissions).Select(x => x.Name).Distinct().ToArray(); - // Read associated logins var logins = await base.GetLoginsAsync(user); user.Logins = logins.Select(x => new ApplicationUserLogin { LoginProvider = x.LoginProvider, ProviderKey = x.ProviderKey }).ToArray(); diff --git a/src/VirtoCommerce.Platform.Security/Repositories/SecurityDbContext.cs b/src/VirtoCommerce.Platform.Security/Repositories/SecurityDbContext.cs index f2dfe123d70..9b100a9d664 100644 --- a/src/VirtoCommerce.Platform.Security/Repositories/SecurityDbContext.cs +++ b/src/VirtoCommerce.Platform.Security/Repositories/SecurityDbContext.cs @@ -73,10 +73,7 @@ protected override void OnModelCreating(ModelBuilder builder) builder.Entity().Ignore(x => x.Permissions); builder.Entity().Ignore(x => x.Password); builder.Entity().Ignore(x => x.Roles); - builder.Entity().Ignore(x => x.LockoutEndDateUtc); - builder.Entity().Ignore(x => x.Permissions); builder.Entity().Ignore(x => x.Logins); - builder.Entity().Ignore(x => x.UserState); builder.Entity().Property(x => x.UserType).HasMaxLength(stringShort); builder.Entity().Property(x => x.Status).HasMaxLength(stringShort); builder.Entity().Property(x => x.PhotoUrl).HasMaxLength(stringLong); diff --git a/src/VirtoCommerce.Platform.Security/Services/DefaultUserPasswordHasher.cs b/src/VirtoCommerce.Platform.Security/Services/DefaultUserPasswordHasher.cs deleted file mode 100644 index b1efba12005..00000000000 --- a/src/VirtoCommerce.Platform.Security/Services/DefaultUserPasswordHasher.cs +++ /dev/null @@ -1,9 +0,0 @@ -using Microsoft.AspNetCore.Identity; -using VirtoCommerce.Platform.Core.Security; - -namespace VirtoCommerce.Platform.Security.Services -{ - public class DefaultUserPasswordHasher : PasswordHasher, IUserPasswordHasher - { - } -} diff --git a/src/VirtoCommerce.Platform.Security/Services/UserApiKeySearchService.cs b/src/VirtoCommerce.Platform.Security/Services/UserApiKeySearchService.cs index 8c907f2d80b..e35c8f7168f 100644 --- a/src/VirtoCommerce.Platform.Security/Services/UserApiKeySearchService.cs +++ b/src/VirtoCommerce.Platform.Security/Services/UserApiKeySearchService.cs @@ -18,12 +18,6 @@ public UserApiKeySearchService(Func repositoryFactory) _repositoryFactory = repositoryFactory; } - [Obsolete("Use SearchAsync()", DiagnosticId = "VC0005", UrlFormat = "https://docs.virtocommerce.org/products/products-virto3-versions/")] - public Task SearchUserApiKeysAsync(UserApiKeySearchCriteria criteria) - { - return SearchAsync(criteria, clone: true); - } - public async Task SearchAsync(UserApiKeySearchCriteria criteria, bool clone = true) { using (var repository = _repositoryFactory()) diff --git a/src/VirtoCommerce.Platform.Security/VirtoCommerce.Platform.Security.csproj b/src/VirtoCommerce.Platform.Security/VirtoCommerce.Platform.Security.csproj index 7c1c4c73ab3..000ce873cd5 100644 --- a/src/VirtoCommerce.Platform.Security/VirtoCommerce.Platform.Security.csproj +++ b/src/VirtoCommerce.Platform.Security/VirtoCommerce.Platform.Security.csproj @@ -2,7 +2,7 @@ net8.0 - 1591 + 1591;NU5048 Library True ebac378d-6c55-4b03-aa82-57643b6e7a0f @@ -18,10 +18,10 @@ - - - - + + + + diff --git a/src/VirtoCommerce.Platform.Web/Controllers/Api/DynamicPropertiesController.cs b/src/VirtoCommerce.Platform.Web/Controllers/Api/DynamicPropertiesController.cs index 97f42ed586b..5f0ef197dbb 100644 --- a/src/VirtoCommerce.Platform.Web/Controllers/Api/DynamicPropertiesController.cs +++ b/src/VirtoCommerce.Platform.Web/Controllers/Api/DynamicPropertiesController.cs @@ -51,13 +51,29 @@ public ActionResult GetObjectTypes() return Ok(_dynamicPropertyRegistrar.AllRegisteredTypeNames); } + [HttpGet] + [Route("properties")] + public async Task> GetAllDynamicProperties([FromQuery] string id) + { + // The argument name is 'id' for compatibility with existing modules + if (string.IsNullOrEmpty(id)) + { + return Ok(Array.Empty()); + } + + var criteria = AbstractTypeFactory.TryCreateInstance(); + criteria.ObjectType = id; + + var result = await _dynamicPropertySearchService.SearchAllNoCloneAsync(criteria); + return Ok(result); + } + /// /// Get dynamic properties registered for object type /// /// [HttpPost] [Route("properties/search")] - public async Task> SearchDynamicProperties([FromBody] DynamicPropertySearchCriteria criteria) { var result = await _dynamicPropertySearchService.SearchNoCloneAsync(criteria); @@ -140,6 +156,22 @@ public async Task DeletePropertyAsync([FromQuery] string[] propert return NoContent(); } + [HttpGet] + [Route("dictionaryitems")] + public async Task> GetAllDictionaryItems([FromQuery] string propertyId) + { + if (string.IsNullOrEmpty(propertyId)) + { + return Ok(Array.Empty()); + } + + var criteria = AbstractTypeFactory.TryCreateInstance(); + criteria.PropertyId = propertyId; + + var result = await _dynamicPropertyDictionaryItemsSearchService.SearchAllNoCloneAsync(criteria); + return Ok(result); + } + /// /// Get dictionary items /// @@ -203,111 +235,5 @@ public async Task DeleteDictionaryItemAsync([FromQuery] string[] i return NoContent(); } - - - #region Legacy API methods left for backward compatibility - - [ApiExplorerSettings(IgnoreApi = true)] - [Obsolete("use POST api/platform/dynamic/properties/search instead")] - [HttpGet] - [Route("types/{typeName}/properties")] - public async Task> GetProperties([FromRoute] string typeName) - { - var result = await _dynamicPropertySearchService.SearchDynamicPropertiesAsync(new DynamicPropertySearchCriteria { ObjectType = typeName }); - return Ok(result.Results); - } - - [ApiExplorerSettings(IgnoreApi = true)] - [Obsolete("use POST api/platform/dynamic/properties instead")] - [HttpPost] - [Route("types/{typeName}/properties")] - [Authorize(PlatformConstants.Security.Permissions.DynamicPropertiesCreate)] - public async Task> CreateProperty([FromRoute] string typeName, [FromBody] DynamicProperty property) - { - var validationResult = await _dynamicPropertyTypeValidator.ValidateAsync(property); - - if (!validationResult.IsValid) - { - return BadRequest($"Validation failed for property: {validationResult.Errors?.FirstOrDefault()?.ErrorMessage}"); - } - - property.Id = null; - if (string.IsNullOrEmpty(property.ObjectType)) - { - property.ObjectType = typeName; - } - - await _dynamicPropertyService.SaveDynamicPropertiesAsync(new[] { property }); - return Ok(property); - } - - [ApiExplorerSettings(IgnoreApi = true)] - [Obsolete("use PUT api/platform/dynamic/properties instead")] - [HttpPut] - [Route("types/{typeName}/properties/{propertyId}")] - [Authorize(PlatformConstants.Security.Permissions.DynamicPropertiesUpdate)] - [ProducesResponseType(typeof(void), StatusCodes.Status204NoContent)] - public async Task UpdateProperty([FromRoute] string typeName, [FromRoute] string propertyId, [FromBody] DynamicProperty property) - { - property.Id = propertyId; - - if (string.IsNullOrEmpty(property.ObjectType)) - { - property.ObjectType = typeName; - } - await _dynamicPropertyService.SaveDynamicPropertiesAsync(new[] { property }); - return NoContent(); - } - - [ApiExplorerSettings(IgnoreApi = true)] - [HttpDelete] - [Obsolete("use DELETE api/platform/dynamic/properties?propertyIds= instead")] - [Route("types/{typeName}/properties/{propertyId}")] - [Authorize(PlatformConstants.Security.Permissions.DynamicPropertiesDelete)] - [ProducesResponseType(typeof(void), StatusCodes.Status204NoContent)] - public async Task DeleteProperty([FromRoute] string typeName, [FromRoute] string propertyId) - { - await _dynamicPropertyService.DeleteDynamicPropertiesAsync(new[] { propertyId }); - return NoContent(); - } - - [ApiExplorerSettings(IgnoreApi = true)] - [Obsolete("use POST api/platform/dynamic/dictionaryitems/search instead")] - [HttpGet] - [Route("types/{typeName}/properties/{propertyId}/dictionaryitems")] - public async Task> GetDictionaryItems([FromRoute] string typeName, [FromRoute] string propertyId) - { - var result = await _dynamicPropertyDictionaryItemsSearchService.SearchAllNoCloneAsync(new DynamicPropertyDictionaryItemSearchCriteria { PropertyId = propertyId, ObjectType = typeName }); - return Ok(result); - } - - [ApiExplorerSettings(IgnoreApi = true)] - [Obsolete("use POST api/platform/dynamic/dictionaryitems instead")] - [HttpPost] - [Route("types/{typeName}/properties/{propertyId}/dictionaryitems")] - [Authorize(PlatformConstants.Security.Permissions.DynamicPropertiesUpdate)] - [ProducesResponseType(typeof(void), StatusCodes.Status204NoContent)] - public async Task SaveDictionaryItems([FromRoute] string typeName, [FromRoute] string propertyId, [FromBody] DynamicPropertyDictionaryItem[] items) - { - foreach (var item in items) - { - item.PropertyId = propertyId; - } - await _dynamicPropertyDictionaryItemsService.SaveDictionaryItemsAsync(items); - return NoContent(); - } - - [ApiExplorerSettings(IgnoreApi = true)] - [Obsolete("use DELETE api/platform/dynamic/dictionaryitems?ids= instead")] - [HttpDelete] - [Route("types/{typeName}/properties/{propertyId}/dictionaryitems")] - [Authorize(PlatformConstants.Security.Permissions.DynamicPropertiesUpdate)] - [ProducesResponseType(typeof(void), StatusCodes.Status204NoContent)] - public async Task DeleteDictionaryItem([FromRoute] string typeName, [FromRoute] string propertyId, [FromQuery] string[] ids) - { - await _dynamicPropertyDictionaryItemsService.DeleteDictionaryItemsAsync(ids); - return NoContent(); - } - #endregion } } diff --git a/src/VirtoCommerce.Platform.Web/Controllers/Api/PlatformExportImportController.cs b/src/VirtoCommerce.Platform.Web/Controllers/Api/PlatformExportImportController.cs index 90d5d2453b5..847d8380b9e 100644 --- a/src/VirtoCommerce.Platform.Web/Controllers/Api/PlatformExportImportController.cs +++ b/src/VirtoCommerce.Platform.Web/Controllers/Api/PlatformExportImportController.cs @@ -2,7 +2,6 @@ using System.Collections.Generic; using System.IO; using System.Linq; -using System.Net; using System.Net.Http; using System.Threading.Tasks; using Hangfire; @@ -37,7 +36,7 @@ public class PlatformExportImportController : Controller private readonly PlatformOptions _platformOptions; private readonly IHttpClientFactory _httpClientFactory; - private static readonly object _lockObject = new object(); + private static readonly object _lockObject = new(); public PlatformExportImportController( IPlatformExportImportManager platformExportManager, @@ -58,9 +57,9 @@ public PlatformExportImportController( [HttpGet] [Route("sampledata/discover")] [AllowAnonymous] - public async Task> DiscoverSampleData() + public async Task>> DiscoverSampleData() { - return Ok((await InnerDiscoverSampleDataAsync()).ToArray()); + return Ok(await InnerDiscoverSampleDataAsync()); } [HttpPost] @@ -71,7 +70,7 @@ public async Task> TryToAutoInsta var sampleData = (await InnerDiscoverSampleDataAsync()).FirstOrDefault(x => !x.Url.IsNullOrEmpty()); if (sampleData != null) { - return ImportSampleData(sampleData.Url); + return Ok(StartImportSampleData(sampleData.Name)); } return Ok(); @@ -80,27 +79,50 @@ public async Task> TryToAutoInsta [HttpPost] [Route("sampledata/import")] [Authorize(Permissions.PlatformImport)] - public ActionResult ImportSampleData([FromQuery] string url = null) + public async Task> ImportSampleData([FromQuery] string name = null, [FromQuery] string url = null) { + var sampleDataList = await InnerDiscoverSampleDataAsync(); + + SampleDataInfo sampleData = null; + + if (!string.IsNullOrEmpty(name)) + { + sampleData = sampleDataList.FirstOrDefault(x => x.Name == name); + } + else if (!string.IsNullOrEmpty(url)) + { + sampleData = sampleDataList.FirstOrDefault(x => x.Url == url); + } + + if (sampleData != null) + { + return Ok(StartImportSampleData(sampleData.Name)); + } + + return Ok(); + } + + private SampleDataImportPushNotification StartImportSampleData(string name) + { + SampleDataImportPushNotification pushNotification = null; + lock (_lockObject) { var sampleDataState = EnumUtility.SafeParse(_settingsManager.GetValue(PlatformConstants.Settings.Setup.SampleDataState), SampleDataState.Undefined); - if (sampleDataState == SampleDataState.Undefined && Uri.IsWellFormedUriString(url, UriKind.Absolute)) + if (sampleDataState == SampleDataState.Undefined) { _settingsManager.SetValue(PlatformConstants.Settings.Setup.SampleDataState.Name, SampleDataState.Processing); - var pushNotification = new SampleDataImportPushNotification(User.Identity.Name); + pushNotification = new SampleDataImportPushNotification(User.Identity?.Name); pushNotification.Title = "Sample data import process"; _pushNotifier.Send(pushNotification); - var jobId = BackgroundJob.Enqueue(() => SampleDataImportBackgroundAsync(new Uri(url), pushNotification, JobCancellationToken.Null, null)); + var jobId = BackgroundJob.Enqueue(() => SampleDataImportBackgroundAsync(name, pushNotification, JobCancellationToken.Null, null)); pushNotification.JobId = jobId; - - return Ok(pushNotification); } } - return Ok(); + return pushNotification; } /// @@ -133,13 +155,7 @@ public ActionResult LoadExportManifest([FromQuery] strin throw new ArgumentNullException(nameof(fileUrl)); } - var uploadFolderPath = Path.GetFullPath(_platformOptions.LocalUploadFolderPath); - - var localPath = Path.Combine(uploadFolderPath, fileUrl); - if (!localPath.StartsWith(uploadFolderPath)) - { - throw new PlatformException($"Invalid path {localPath}"); - } + var localPath = GetSafeFullPath(_platformOptions.LocalUploadFolderPath, fileUrl); PlatformExportManifest retVal; using (var stream = new FileStream(localPath, FileMode.Open)) @@ -197,11 +213,10 @@ public ActionResult Cancel([FromRoute] string jobId) [Authorize(Permissions.PlatformExport)] public ActionResult DownloadExportFile([FromRoute] string fileName) { - var localTmpFolder = Path.GetFullPath(Path.Combine(_platformOptions.DefaultExportFolder)); - var localPath = Path.Combine(localTmpFolder, Path.GetFileName(fileName)); + var localPath = GetSafeFullPath(_platformOptions.DefaultExportFolder, fileName); //Load source data only from local file system - using (var stream = System.IO.File.Open(localPath, FileMode.Open)) + using (System.IO.File.Open(localPath, FileMode.Open)) { var provider = new FileExtensionContentTypeProvider(); if (!provider.TryGetContentType(localPath, out var contentType)) @@ -212,12 +227,12 @@ public ActionResult DownloadExportFile([FromRoute] string fileName) } } - private async Task> InnerDiscoverSampleDataAsync() + private async Task> InnerDiscoverSampleDataAsync() { var sampleDataUrl = _platformOptions.SampleDataUrl; if (string.IsNullOrEmpty(sampleDataUrl)) { - return Enumerable.Empty(); + return []; } //Direct file mode @@ -225,18 +240,18 @@ private async Task> InnerDiscoverSampleDataAsync() { return new List { - new SampleDataInfo { Url = sampleDataUrl } + new() { Url = sampleDataUrl } }; } //Discovery mode - var manifestUrl = sampleDataUrl + "\\manifest.json"; - using var client = _httpClientFactory.CreateClient(); - await using var stream = await client.GetStreamAsync(new Uri(manifestUrl)); + var manifestUrl = sampleDataUrl + "/manifest.json"; + var httpClient = _httpClientFactory.CreateClient(); + await using var stream = await httpClient.GetStreamAsync(new Uri(manifestUrl)); //Add empty template var result = new List { - new SampleDataInfo { Name = "Empty" } + new() { Name = "Empty" } }; //Need filter unsupported versions and take one most new sample data @@ -267,7 +282,7 @@ private async Task> InnerDiscoverSampleDataAsync() return result; } - public async Task SampleDataImportBackgroundAsync(Uri url, SampleDataImportPushNotification pushNotification, IJobCancellationToken cancellationToken, PerformContext context) + public async Task SampleDataImportBackgroundAsync(string name, SampleDataImportPushNotification pushNotification, IJobCancellationToken cancellationToken, PerformContext context) { void progressCallback(ExportImportProgressInfo x) { @@ -278,6 +293,12 @@ void progressCallback(ExportImportProgressInfo x) try { + var url = (await InnerDiscoverSampleDataAsync()).FirstOrDefault(x => x.Name == name)?.Url; + if (url is null) + { + return; + } + pushNotification.Description = "Start downloading from " + url; await _pushNotifier.SendAsync(pushNotification); @@ -288,17 +309,19 @@ void progressCallback(ExportImportProgressInfo x) Directory.CreateDirectory(tmpPath); } - var tmpFilePath = Path.Combine(tmpPath, Path.GetFileName(url.ToString())); - using (var client = new WebClient()) + var tmpFilePath = Path.Combine(tmpPath, Path.GetFileName(url)); + + await DownloadFileAsync(new Uri(url), tmpFilePath, async (bytesReceived, bytesTotal) => { - client.DownloadProgressChanged += async (sender, args) => + cancellationToken.ThrowIfCancellationRequested(); + var message = $"Sample data {bytesReceived.ToHumanReadableSize()} of {bytesTotal.ToHumanReadableSize()} downloading..."; + if (message != pushNotification.Description) { - pushNotification.Description = string.Format("Sample data {0} of {1} downloading...", args.BytesReceived.ToHumanReadableSize(), args.TotalBytesToReceive.ToHumanReadableSize()); + pushNotification.Description = message; await _pushNotifier.SendAsync(pushNotification); - }; - var task = client.DownloadFileTaskAsync(url, tmpFilePath); - task.Wait(); - } + } + }); + using (var stream = new FileStream(tmpFilePath, FileMode.Open)) { var manifest = _platformExportManager.ReadExportManifest(stream); @@ -318,7 +341,7 @@ void progressCallback(ExportImportProgressInfo x) } finally { - _settingsManager.SetValue(PlatformConstants.Settings.Setup.SampleDataState.Name, SampleDataState.Completed); + await _settingsManager.SetValueAsync(PlatformConstants.Settings.Setup.SampleDataState.Name, SampleDataState.Completed); pushNotification.Description = "Import finished"; pushNotification.Finished = DateTime.UtcNow; await _pushNotifier.SendAsync(pushNotification); @@ -339,14 +362,7 @@ void progressCallback(ExportImportProgressInfo x) { var cancellationTokenWrapper = new JobCancellationTokenWrapper(cancellationToken); - var uploadFolderFullPath = Path.GetFullPath(_platformOptions.LocalUploadFolderPath); - // VP-5353: Checking that the file is inside LocalUploadFolderPath - var localPath = Path.Combine(uploadFolderFullPath, importRequest.FileUrl); - - if (!localPath.StartsWith(uploadFolderFullPath)) - { - throw new PlatformException($"Invalid path {localPath}"); - } + var localPath = GetSafeFullPath(_platformOptions.LocalUploadFolderPath, importRequest.FileUrl); //Load source data only from local file system using (var stream = new FileStream(localPath, FileMode.Open)) @@ -420,5 +436,58 @@ void progressCallback(ExportImportProgressInfo x) await _pushNotifier.SendAsync(pushNotification); } } + + private static string GetSafeFullPath(string basePath, string relativePath) + { + var baseFullPath = Path.GetFullPath(basePath); + var result = Path.GetFullPath(Path.Combine(baseFullPath, relativePath)); + + if (!result.StartsWith(baseFullPath + Path.DirectorySeparatorChar)) + { + throw new PlatformException($"Invalid path {relativePath}"); + } + + return result; + } + + private async Task DownloadFileAsync(Uri uri, string filePath, Func progress) + { + var httpClient = _httpClientFactory.CreateClient(); + + var response = await httpClient.GetAsync(uri, HttpCompletionOption.ResponseHeadersRead); + response.EnsureSuccessStatusCode(); + + var contentLength = response.Content.Headers.ContentLength ?? -1L; + var bytesReceived = 0L; + var bytesTotal = contentLength < 0 ? 0L : contentLength; + + const int defaultBufferSize = 65536; + var bufferSize = contentLength < 0 || contentLength > defaultBufferSize ? defaultBufferSize : (int)contentLength; + var buffer = new byte[bufferSize]; + + await using var readStream = await response.Content.ReadAsStreamAsync(); + await using var writeStream = new FileStream(filePath, FileMode.Create, FileAccess.Write, FileShare.None, bufferSize, FileOptions.Asynchronous); + + while (true) + { + var bytesRead = await readStream.ReadAsync(new Memory(buffer)).ConfigureAwait(false); + + if (bytesRead == 0) + { + break; + } + + bytesReceived += bytesRead; + + if (contentLength < 0) + { + bytesTotal = bytesReceived; + } + + await writeStream.WriteAsync(new ReadOnlyMemory(buffer, 0, bytesRead)).ConfigureAwait(false); + + await progress(bytesReceived, bytesTotal); + } + } } } diff --git a/src/VirtoCommerce.Platform.Web/Controllers/Api/ProfilesController.cs b/src/VirtoCommerce.Platform.Web/Controllers/Api/ProfilesController.cs index ae07845ef59..71063f0c6f5 100644 --- a/src/VirtoCommerce.Platform.Web/Controllers/Api/ProfilesController.cs +++ b/src/VirtoCommerce.Platform.Web/Controllers/Api/ProfilesController.cs @@ -8,7 +8,6 @@ using Microsoft.Extensions.Configuration; using VirtoCommerce.Platform.Core; using VirtoCommerce.Platform.Core.Common; -using VirtoCommerce.Platform.Core.Modularity; using VirtoCommerce.Platform.Core.Security; using VirtoCommerce.Platform.Core.Settings; using VirtoCommerce.Platform.Web.Model.Profiles; @@ -22,15 +21,13 @@ namespace VirtoCommerce.Platform.Web.Controllers.Api public class ProfilesController : Controller { private readonly ISettingsManager _settingsManager; - private readonly ILocalModuleCatalog _moduleCatalog; private readonly UserManager _userManager; private readonly IConfiguration _configuration; - public ProfilesController(UserManager userManager, ISettingsManager settingsManager, ILocalModuleCatalog moduleCatalog, IConfiguration configuration) + public ProfilesController(UserManager userManager, ISettingsManager settingsManager, IConfiguration configuration) { _userManager = userManager; _settingsManager = settingsManager; - _moduleCatalog = moduleCatalog; _configuration = configuration; } @@ -51,9 +48,9 @@ public async Task GetCurrentUserProfileAsync() // Main menu settings at initial boot var nameMainMenuState = PlatformConstants.Settings.UserProfile.MainMenuState.Name; - var nameMainMenuStateSettig = userProfile.Settings.FirstOrDefault(x => x.Name == nameMainMenuState); + var nameMainMenuStateSetting = userProfile.Settings.FirstOrDefault(x => x.Name == nameMainMenuState); - if (nameMainMenuStateSettig != null && nameMainMenuStateSettig.Value == null) + if (nameMainMenuStateSetting != null && nameMainMenuStateSetting.Value == null) { var settingMenuState = new DefaultMainMenuState(); _configuration.GetSection("DefaultMainMenuState").Bind(settingMenuState); @@ -62,7 +59,7 @@ public async Task GetCurrentUserProfileAsync() PropertyNamingPolicy = JsonNamingPolicy.CamelCase, }; var mainMenuState = JsonSerializer.Serialize(settingMenuState, serializeOptions); - nameMainMenuStateSettig.Value = mainMenuState; + nameMainMenuStateSetting.Value = mainMenuState; } return Ok(userProfile); @@ -85,7 +82,7 @@ public async Task UpdateCurrentUserProfileAsync([FromBody] UserPro { return Forbid(); } - using (await AsyncLock.GetLockByKey(userProfile.ToString()).GetReleaserAsync()) + using (await AsyncLock.GetLockByKey(userProfile.ToString()).LockAsync()) { await _settingsManager.DeepSaveSettingsAsync(userProfile); } diff --git a/src/VirtoCommerce.Platform.Web/Controllers/Api/SecurityController.cs b/src/VirtoCommerce.Platform.Web/Controllers/Api/SecurityController.cs index 13c9976ab81..84dd80dc98f 100644 --- a/src/VirtoCommerce.Platform.Web/Controllers/Api/SecurityController.cs +++ b/src/VirtoCommerce.Platform.Web/Controllers/Api/SecurityController.cs @@ -341,20 +341,6 @@ public async Task> SearchUsers([FromBody] UserSea return Ok(result); } - /// - /// Old SearchAsync users by keyword - /// - /// Search criteria. - /// Obsolete, only for backward compatibility with V2 - [HttpPost] - [Route("users")] - [Authorize(PlatformPermissions.SecurityQuery)] - [Obsolete("PT-789 Left only for backward compatibility with V2")] - public Task> SearchUsersOld([FromBody] UserSearchCriteria criteria) - { - return SearchUsers(criteria); - } - /// /// Get user details by user name /// @@ -1067,19 +1053,6 @@ public async Task> VerifyUserToken([FromRoute] string userId, return Ok(success); } - #region PT-788 Obsolete methods - - [Obsolete("use /roles/search instead")] - [HttpPost] - [Route("roles")] - [Authorize(PlatformPermissions.SecurityQuery)] - public Task> SearchRolesObsolete([FromBody] RoleSearchCriteria request) - { - return SearchRoles(request); - } - - #endregion PT-788 Obsolete methods - private bool IsUserEditable(string userName) { return _securityOptions.NonEditableUsers?.FirstOrDefault(x => x.EqualsInvariant(userName)) == null; diff --git a/src/VirtoCommerce.Platform.Web/Controllers/Api/SettingController.cs b/src/VirtoCommerce.Platform.Web/Controllers/Api/SettingController.cs index eb22db28b16..7e08e4854db 100644 --- a/src/VirtoCommerce.Platform.Web/Controllers/Api/SettingController.cs +++ b/src/VirtoCommerce.Platform.Web/Controllers/Api/SettingController.cs @@ -76,7 +76,7 @@ public async Task> GetGlobalSettingAsync(string [ProducesResponseType(typeof(void), StatusCodes.Status204NoContent)] public async Task UpdateAsync([FromBody] ObjectSettingEntry[] objectSettings) { - using (await AsyncLock.GetLockByKey("settings").GetReleaserAsync()) + using (await AsyncLock.GetLockByKey("settings").LockAsync()) { await _settingsManager.SaveObjectSettingsAsync(objectSettings); } diff --git a/src/VirtoCommerce.Platform.Web/PushNotifications/SignalRBuilderExtensions.cs b/src/VirtoCommerce.Platform.Web/PushNotifications/SignalRBuilderExtensions.cs index 9123661b5e2..0d5434b1d8e 100644 --- a/src/VirtoCommerce.Platform.Web/PushNotifications/SignalRBuilderExtensions.cs +++ b/src/VirtoCommerce.Platform.Web/PushNotifications/SignalRBuilderExtensions.cs @@ -4,6 +4,7 @@ using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using Newtonsoft.Json; +using StackExchange.Redis; using VirtoCommerce.Platform.Core.Common; using VirtoCommerce.Platform.Core.PushNotifications; using VirtoCommerce.Platform.Web.PushNotifications.Scalability; @@ -25,7 +26,7 @@ public static ISignalRServerBuilder AddPushNotifications(this ISignalRServerBuil if (scalabilityMode != null && !scalabilityMode.EqualsInvariant("None")) { - //Enable to store in the json the full type information to be able deserialize a push notifications types on the other instances + // Store full type information in JSON to deserialize push notifications on other instances builder.AddNewtonsoftJsonProtocol(jsonOptions => { jsonOptions.PayloadSerializerSettings.TypeNameHandling = TypeNameHandling.Objects; @@ -40,23 +41,23 @@ public static ISignalRServerBuilder AddPushNotifications(this ISignalRServerBuil var azureSignalRConnectionString = configuration["PushNotifications:AzureSignalRService:ConnectionString"]; if (string.IsNullOrEmpty(azureSignalRConnectionString)) { - throw new InvalidOperationException($"PushNotifications:AzureSignalRService:ConnectionString must be set"); + throw new InvalidOperationException("PushNotifications:AzureSignalRService:ConnectionString must be set"); } builder.AddAzureSignalR(o => { - o.Endpoints = new[] { new ServiceEndpoint(azureSignalRConnectionString) }; + o.Endpoints = [new ServiceEndpoint(azureSignalRConnectionString)]; }); } else { var redisConnectionString = configuration.GetConnectionString("RedisConnectionString"); - var redisChannelName = configuration["PushNotifications:RedisBackplane:ChannelName"]; - redisChannelName = string.IsNullOrEmpty(redisChannelName) ? "VirtoCommerceChannel" : redisChannelName; if (string.IsNullOrEmpty(redisConnectionString)) { - throw new InvalidOperationException($"RedisConnectionString must be set"); + throw new InvalidOperationException("RedisConnectionString must be set"); } - builder.AddStackExchangeRedis(redisConnectionString, o => o.Configuration.ChannelPrefix = redisChannelName); + + var redisChannelName = configuration["PushNotifications:RedisBackplane:ChannelName"].EmptyToNull() ?? "VirtoCommerceChannel"; + builder.AddStackExchangeRedis(redisConnectionString, o => o.Configuration.ChannelPrefix = RedisChannel.Literal(redisChannelName)); } } else @@ -66,7 +67,5 @@ public static ISignalRServerBuilder AddPushNotifications(this ISignalRServerBuil return builder; } - - } } diff --git a/src/VirtoCommerce.Platform.Web/Security/Authentication/ApiKeyAuthenticationHandler.cs b/src/VirtoCommerce.Platform.Web/Security/Authentication/ApiKeyAuthenticationHandler.cs index 132fc6dda09..d27a44a15ac 100644 --- a/src/VirtoCommerce.Platform.Web/Security/Authentication/ApiKeyAuthenticationHandler.cs +++ b/src/VirtoCommerce.Platform.Web/Security/Authentication/ApiKeyAuthenticationHandler.cs @@ -22,11 +22,10 @@ public ApiKeyAuthenticationHandler( IOptionsMonitor options, ILoggerFactory logger, UrlEncoder encoder, - ISystemClock clock, UserManager userManager, SignInManager signInManager, IUserApiKeyService userApiKeyService) - : base(options, logger, encoder, clock) + : base(options, logger, encoder) { _userManager = userManager; _signInManager = signInManager; @@ -37,13 +36,13 @@ public ApiKeyAuthenticationHandler( //The logic goes something like this: //If no ApiKey is present on query string -> Return no result, let other handlers (if present) handle the request. //If the api_key is present but null or empty -> Return no result. - //If the provided key does not exists -> Fail the authentication. + //If the provided key does not exist -> Fail the authentication. //If the key is valid, create a new identity based on associated with key user protected override async Task HandleAuthenticateAsync() { //This line is important to correct working the multiple authentication schemes when only cookies are being sent in request //see Authorization:LimitedCookiePermissions setting - if (Context.User?.Identity?.IsAuthenticated ?? false) + if (Context.User.Identity?.IsAuthenticated ?? false) { return AuthenticateResult.Success(new AuthenticationTicket(Context.User, "context.User")); } @@ -73,11 +72,11 @@ protected override async Task HandleAuthenticateAsync() } if (!await _signInManager.CanSignInAsync(user)) { - return AuthenticateResult.Fail($"User { user.UserName } is not allowed to login."); + return AuthenticateResult.Fail($"User {user.UserName} is not allowed to login."); } if (_userManager.SupportsUserLockout && await _userManager.IsLockedOutAsync(user)) { - return AuthenticateResult.Fail($"User { user.UserName } is currently locked out."); + return AuthenticateResult.Fail($"User {user.UserName} is currently locked out."); } var claimsPrincipal = await _signInManager.CreateUserPrincipalAsync(user); var ticket = new AuthenticationTicket(claimsPrincipal, Options.Scheme); diff --git a/src/VirtoCommerce.Platform.Web/Security/Authentication/BasicAuthenticationHandler.cs b/src/VirtoCommerce.Platform.Web/Security/Authentication/BasicAuthenticationHandler.cs index 2b87e772801..aa451dc8b9d 100644 --- a/src/VirtoCommerce.Platform.Web/Security/Authentication/BasicAuthenticationHandler.cs +++ b/src/VirtoCommerce.Platform.Web/Security/Authentication/BasicAuthenticationHandler.cs @@ -19,10 +19,9 @@ public BasicAuthenticationHandler( IOptionsMonitor options, ILoggerFactory logger, UrlEncoder encoder, - ISystemClock clock, UserManager userManager, SignInManager signInManager) - : base(options, logger, encoder, clock) + : base(options, logger, encoder) { _userManager = userManager; _signInManager = signInManager; @@ -73,7 +72,7 @@ private bool TryGetEncodedCredentials(out string encodedCredentials) var headerValue = values.ToString(); const string scheme = "Basic "; - if (headerValue != null && headerValue.StartsWith(scheme, StringComparison.OrdinalIgnoreCase)) + if (headerValue.StartsWith(scheme, StringComparison.OrdinalIgnoreCase)) { encodedCredentials = headerValue.Substring(scheme.Length).Trim(); } diff --git a/src/VirtoCommerce.Platform.Web/Security/ExternalSignInService.cs b/src/VirtoCommerce.Platform.Web/Security/ExternalSignInService.cs index e803617dde9..c26ee3d4ca1 100644 --- a/src/VirtoCommerce.Platform.Web/Security/ExternalSignInService.cs +++ b/src/VirtoCommerce.Platform.Web/Security/ExternalSignInService.cs @@ -185,7 +185,7 @@ private async Task GetDefaultUserType(ExternalLoginInfo externalLoginInf userTypes.Add(userType); userTypesSetting.AllowedValues = userTypes.Select(x => (object)x).ToArray(); - using (await AsyncLock.GetLockByKey("settings").GetReleaserAsync()) + using (await AsyncLock.GetLockByKey("settings").LockAsync()) { await _settingsManager.SaveObjectSettingsAsync([userTypesSetting]); } diff --git a/src/VirtoCommerce.Platform.Web/Security/MultitenantAzureADIssuerValidator.cs b/src/VirtoCommerce.Platform.Web/Security/MultitenantAzureADIssuerValidator.cs deleted file mode 100644 index 9feea3daebb..00000000000 --- a/src/VirtoCommerce.Platform.Web/Security/MultitenantAzureADIssuerValidator.cs +++ /dev/null @@ -1,54 +0,0 @@ -using System; -using System.IdentityModel.Tokens.Jwt; -using System.Linq; -using Microsoft.IdentityModel.Tokens; - -namespace VirtoCommerce.Platform.Web.Security -{ - /// - /// Multitenant Azure AD issuer validation in ASP.NET Core - /// If you use Azure AD authentication and want to allow users from any tenant to connect to your ASP.NET Core application, - /// you need to configure the Azure AD app as multi-tenant, and use a “wildcard” tenant id such as organizations or common in the authority URL. - /// The problem when you do that is that with the default configuration, the token validation will fail because the issuer in the - /// token won’t match the issuer specified in the OpenID metadata. - /// https://thomaslevesque.com/2018/12/24/multitenant-azure-ad-issuer-validation-in-asp-net-core/ - /// - [Obsolete("Moved to VirtoCommerce.AzureAD module.")] - public static class MultitenantAzureADIssuerValidator - { - public static string ValidateIssuerWithPlaceholder(string issuer, SecurityToken token, TokenValidationParameters parameters) - { - // Accepts any issuer of the form "https://login.microsoftonline.com/{tenantid}/v2.0", - // where tenantid is the tid from the token. - - if (token is JwtSecurityToken jwt && - jwt.Payload.TryGetValue("tid", out var value) && - value is string tokenTenantId) - { - var validIssuers = (parameters.ValidIssuers ?? Enumerable.Empty()) - .Append(parameters.ValidIssuer) - .Where(i => !string.IsNullOrEmpty(i)); - - if (validIssuers.Any(i => i.Replace("{tenantid}", tokenTenantId) == issuer)) - return issuer; - } - - // Recreate the exception that is thrown by default - // when issuer validation fails - throw new SecurityTokenInvalidIssuerException($"IDX10205: Issuer validation failed. Issuer: '{issuer}'. Did not match: validationParameters.ValidIssuer: '{parameters.ValidIssuer ?? "null"}' or validationParameters.ValidIssuers: '{GetValidIssuersString(parameters)}'.") - { - InvalidIssuer = issuer - }; - } - - private static string GetValidIssuersString(TokenValidationParameters parameters) - { - if (parameters.ValidIssuers == null) - return "null"; - if (!parameters.ValidIssuers.Any()) - return "empty"; - - return string.Join(", ", parameters.ValidIssuers); - } - } -} diff --git a/src/VirtoCommerce.Platform.Web/Security/ServiceCollectionExtensions.cs b/src/VirtoCommerce.Platform.Web/Security/ServiceCollectionExtensions.cs index 19125091227..1e037a30af0 100644 --- a/src/VirtoCommerce.Platform.Web/Security/ServiceCollectionExtensions.cs +++ b/src/VirtoCommerce.Platform.Web/Security/ServiceCollectionExtensions.cs @@ -48,7 +48,6 @@ public static IServiceCollection AddSecurityServices(this IServiceCollection ser services.AddSingleton>>(provider => () => provider.CreateScope().ServiceProvider.GetService>()); services.AddSingleton>>(provider => () => provider.CreateScope().ServiceProvider.GetService>()); services.AddSingleton>>(provider => () => provider.CreateScope().ServiceProvider.GetService>()); - services.AddSingleton(); //Use custom ClaimsPrincipalFactory to add system roles claims for user principal services.TryAddScoped, CustomUserClaimsPrincipalFactory>(); services.AddTransient(); diff --git a/src/VirtoCommerce.Platform.Web/VirtoCommerce.Platform.Web.csproj b/src/VirtoCommerce.Platform.Web/VirtoCommerce.Platform.Web.csproj index c941a81694e..f2d9c3d2263 100644 --- a/src/VirtoCommerce.Platform.Web/VirtoCommerce.Platform.Web.csproj +++ b/src/VirtoCommerce.Platform.Web/VirtoCommerce.Platform.Web.csproj @@ -16,28 +16,27 @@ - - - - - - - - - - + + + + + + + + + - + - - + + - + - + diff --git a/src/VirtoCommerce.Platform.Web/appsettings.json b/src/VirtoCommerce.Platform.Web/appsettings.json index 0e84f434fd2..49415dd3832 100644 --- a/src/VirtoCommerce.Platform.Web/appsettings.json +++ b/src/VirtoCommerce.Platform.Web/appsettings.json @@ -223,8 +223,7 @@ "CacheEnabled": true, "CacheSlidingExpiration": "0:15:00", "Redis": { - "ChannelName": "VirtoCommerceChannel", - "BusRetryCount": 3 + "ChannelName": "VirtoCommerceChannel" } }, "Crud": { diff --git a/src/VirtoCommerce.Platform.Web/wwwroot/js/app/dynamicProperties/blades/dynamicProperty-detail.js b/src/VirtoCommerce.Platform.Web/wwwroot/js/app/dynamicProperties/blades/dynamicProperty-detail.js index 2f81860eacf..c72ec88e7fa 100644 --- a/src/VirtoCommerce.Platform.Web/wwwroot/js/app/dynamicProperties/blades/dynamicProperty-detail.js +++ b/src/VirtoCommerce.Platform.Web/wwwroot/js/app/dynamicProperties/blades/dynamicProperty-detail.js @@ -90,13 +90,17 @@ angular.module('platformWebApp') $scope.saveChanges = function () { if (blade.isNew) { - dynamicPropertiesApi.save({ id: blade.objectType }, blade.currentEntity, + blade.currentEntity.objectType = blade.objectType; + dynamicPropertiesApi.save({}, blade.currentEntity, function (data) { blade.onChangesConfirmedFn(data); // save dictionary items for new entity if (data.isDictionary) { - dictionaryItemsApi.save({ id: blade.objectType, propertyId: data.id }, - localDictionaryValues, + localDictionaryValues.forEach(function (x) { + x.propertyId = data.id; + }); + + dictionaryItemsApi.save({}, localDictionaryValues, function () { $scope.bladeClose(); blade.parentBlade.refresh(true); @@ -109,7 +113,7 @@ angular.module('platformWebApp') }, function (error) { bladeNavigationService.setError('Error ' + error.status, blade); }); } else { - dynamicPropertiesApi.update({ id: blade.objectType, propertyId: blade.currentEntity.id }, blade.currentEntity, + dynamicPropertiesApi.update({}, blade.currentEntity, function () { angular.copy(blade.currentEntity, blade.origEntity); blade.currentEntity = blade.origEntity; @@ -129,7 +133,7 @@ angular.module('platformWebApp') message: "platform.dialogs.dynamic-property-delete.message", callback: function (remove) { if (remove) { - dynamicPropertiesApi.delete({ id: blade.objectType, propertyId: blade.currentEntity.id }, + dynamicPropertiesApi.delete({ propertyIds: [blade.currentEntity.id] }, function () { $scope.bladeClose(); blade.parentBlade.refresh(true); diff --git a/src/VirtoCommerce.Platform.Web/wwwroot/js/app/dynamicProperties/blades/property-dictionary.js b/src/VirtoCommerce.Platform.Web/wwwroot/js/app/dynamicProperties/blades/property-dictionary.js index 41c7aaf8769..b5414890548 100644 --- a/src/VirtoCommerce.Platform.Web/wwwroot/js/app/dynamicProperties/blades/property-dictionary.js +++ b/src/VirtoCommerce.Platform.Web/wwwroot/js/app/dynamicProperties/blades/property-dictionary.js @@ -12,7 +12,7 @@ angular.module('platformWebApp').controller('platformWebApp.propertyDictionaryCo blade.selectedAll = false; if (blade.isApiSave) { - dictionaryItemsApi.query({ id: blade.currentEntity.objectType, propertyId: blade.currentEntity.id }, + dictionaryItemsApi.query({ propertyId: blade.currentEntity.id }, initializeBlade, function (error) { bladeNavigationService.setError('Error ' + error.status, blade); }); } else { @@ -140,8 +140,11 @@ angular.module('platformWebApp').controller('platformWebApp.propertyDictionaryCo if (blade.isApiSave) { blade.isLoading = true; - dictionaryItemsApi.save({ id: blade.currentEntity.objectType, propertyId: blade.currentEntity.id }, - blade.currentEntities, + blade.currentEntities.forEach(function (x) { + x.propertyId = blade.currentEntity.id; + }); + + dictionaryItemsApi.save({}, blade.currentEntities, function () { refresh(); if (blade.onChangesConfirmedFn) @@ -210,7 +213,7 @@ angular.module('platformWebApp').controller('platformWebApp.propertyDictionaryCo callback: function (remove) { if (remove) { blade.isLoading = true; - dictionaryItemsApi.delete({ id: blade.currentEntity.objectType, propertyId: blade.currentEntity.id, ids: ids }, null, + dictionaryItemsApi.delete({ ids: ids }, null, function () { refresh(); if (blade.onChangesConfirmedFn) diff --git a/src/VirtoCommerce.Platform.Web/wwwroot/js/app/dynamicProperties/blades/propertyValue-list.js b/src/VirtoCommerce.Platform.Web/wwwroot/js/app/dynamicProperties/blades/propertyValue-list.js index d90742e8e4a..68c2bd91701 100644 --- a/src/VirtoCommerce.Platform.Web/wwwroot/js/app/dynamicProperties/blades/propertyValue-list.js +++ b/src/VirtoCommerce.Platform.Web/wwwroot/js/app/dynamicProperties/blades/propertyValue-list.js @@ -145,7 +145,7 @@ angular.module('platformWebApp') ]; $scope.getDictionaryValues = function (property, callback) { - dictionaryItemsApi.query({ id: property.objectType, propertyId: property.id }, callback); + dictionaryItemsApi.query({ propertyId: property.id }, callback); } $scope.switchPropertiesVisibility = function () { @@ -184,7 +184,7 @@ angular.module('platformWebApp') } }); } - }) + }); _.each(blade.currentEntities, function (property) { // required properties and switchers can’t be hidden @@ -192,7 +192,7 @@ angular.module('platformWebApp') property.valueType !== 'Boolean' && allPropertiesEmpty(property.values) ) { - blade.emptyProperties.push(property) + blade.emptyProperties.push(property); } }); } diff --git a/src/VirtoCommerce.Platform.Web/wwwroot/js/app/dynamicProperties/resources/dynamicPropertiesApi.js b/src/VirtoCommerce.Platform.Web/wwwroot/js/app/dynamicProperties/resources/dynamicPropertiesApi.js index 9780ff978de..41a64e72a1e 100644 --- a/src/VirtoCommerce.Platform.Web/wwwroot/js/app/dynamicProperties/resources/dynamicPropertiesApi.js +++ b/src/VirtoCommerce.Platform.Web/wwwroot/js/app/dynamicProperties/resources/dynamicPropertiesApi.js @@ -1,13 +1,15 @@ angular.module('platformWebApp') .factory('platformWebApp.dynamicProperties.api', ['$resource', function ($resource) { - return $resource('api/platform/dynamic/types/:id/properties/:propertyId', {}, { + return $resource('api/platform/dynamic/properties', {}, { queryTypes: { url: 'api/platform/dynamic/types', isArray: true }, update: { method: 'PUT' }, search: { method: 'POST', url: 'api/platform/dynamic/properties/search' }, }); }]) .factory('platformWebApp.dynamicProperties.dictionaryItemsApi', ['$resource', function ($resource) { - return $resource('api/platform/dynamic/types/:id/properties/:propertyId/dictionaryitems'); + return $resource('api/platform/dynamic/dictionaryitems', {}, { + search: { method: 'POST', url: 'api/platform/dynamic/dictionaryitems/search' }, + }); }]) .factory('platformWebApp.dynamicProperties.valueTypesService', function () { var propertyTypes = [ diff --git a/src/VirtoCommerce.Platform.Web/wwwroot/js/app/exportImport/exportImport.js b/src/VirtoCommerce.Platform.Web/wwwroot/js/app/exportImport/exportImport.js index 2443863454e..84096b87aa1 100644 --- a/src/VirtoCommerce.Platform.Web/wwwroot/js/app/exportImport/exportImport.js +++ b/src/VirtoCommerce.Platform.Web/wwwroot/js/app/exportImport/exportImport.js @@ -18,7 +18,7 @@ angular.module('platformWebApp') $stateProvider.state('setupWizard.sampleDataInstallation', { url: '/sampleDataInstallation', templateUrl: '$(Platform)/Scripts/app/exportImport/templates/sampleDataInstallation.tpl.html', - controller: ['$scope', '$state', '$stateParams', 'platformWebApp.exportImport.resource', 'platformWebApp.setupWizard', function ($scope, $state, $stateParams, exportImportResourse, setupWizard) { + controller: ['$scope', '$state', '$stateParams', 'platformWebApp.exportImport.resource', 'platformWebApp.setupWizard', function ($scope, $state, $stateParams, exportImportResource, setupWizard) { $scope.notification = {}; if ($stateParams.notification) { $scope.notification = $stateParams.notification; @@ -43,7 +43,7 @@ angular.module('platformWebApp') $scope.importData = function (sampleData) { if (sampleData.url) { - exportImportResourse.importSampleData({ url: sampleData.url }, function (data) { + exportImportResource.importSampleData({ name: sampleData.name }, function (data) { //need check notification.created because not exist any way to check empty response if (data && data.created) { angular.copy(data, $scope.notification); @@ -60,7 +60,7 @@ angular.module('platformWebApp') function discoverSampleData() { $scope.loading = true; - exportImportResourse.sampleDataDiscover({}, function (sampleDataInfos) { + exportImportResource.sampleDataDiscover({}, function (sampleDataInfos) { $scope.loading = false; //run obvious sample data installation if (angular.isArray(sampleDataInfos) && sampleDataInfos.length > 0) { @@ -83,7 +83,11 @@ angular.module('platformWebApp') }); }]) .run( - ['$rootScope', 'platformWebApp.mainMenuService', 'platformWebApp.widgetService', '$state', 'platformWebApp.pushNotificationTemplateResolver', 'platformWebApp.bladeNavigationService', 'platformWebApp.exportImport.resource', 'platformWebApp.setupWizard', function ($rootScope, mainMenuService, widgetService, $state, pushNotificationTemplateResolver, bladeNavigationService, exportImportResourse, setupWizard) { + [ + '$rootScope', '$state', + 'platformWebApp.mainMenuService', 'platformWebApp.widgetService', 'platformWebApp.bladeNavigationService', + 'platformWebApp.setupWizard', 'platformWebApp.pushNotificationTemplateResolver', + function ($rootScope, $state, mainMenuService, widgetService, bladeNavigationService, setupWizard, pushNotificationTemplateResolver) { var menuItem = { path: 'configuration/exportImport', icon: 'fa fa-database', diff --git a/src/VirtoCommerce.Platform.Web/wwwroot/js/app/exportImport/resources/exportImport.js b/src/VirtoCommerce.Platform.Web/wwwroot/js/app/exportImport/resources/exportImport.js index 8c0785cd77a..f9eaf3acfb5 100644 --- a/src/VirtoCommerce.Platform.Web/wwwroot/js/app/exportImport/resources/exportImport.js +++ b/src/VirtoCommerce.Platform.Web/wwwroot/js/app/exportImport/resources/exportImport.js @@ -8,8 +8,9 @@ angular.module('platformWebApp') loadExportManifest: { url: 'api/platform/export/manifest/load' }, runImport: { method: 'POST', url: 'api/platform/import' }, + sampleDataDiscover: { url: 'api/platform/sampledata/discover', isArray: true }, - importSampleData: { method: 'POST', url: 'api/platform/sampledata/import', params: { url: '@url' } }, + importSampleData: { method: 'POST', url: 'api/platform/sampledata/import', params: { name: '@name' } }, taskCancel: { method: 'POST', url: 'api/platform/exortimport/tasks/:jobId/cancel'} }); diff --git a/tests/VirtoCommerce.Platform.Caching.Tests/MemoryCacheExtensionTests.cs b/tests/VirtoCommerce.Platform.Caching.Tests/MemoryCacheExtensionTests.cs index 0f517778141..5ccd0a9bb73 100644 --- a/tests/VirtoCommerce.Platform.Caching.Tests/MemoryCacheExtensionTests.cs +++ b/tests/VirtoCommerce.Platform.Caching.Tests/MemoryCacheExtensionTests.cs @@ -61,7 +61,7 @@ public void Named_AsyncLock_Exclusive_Access_For_One_Thread() var counter = 0; Parallel.ForEach(Enumerable.Range(1, 10), async i => { - var releaser = await AsyncLock.GetLockByKey((i % 2).ToString()).GetReleaserAsync(); + var releaser = await AsyncLock.GetLockByKey((i % 2).ToString()).LockAsync(); sut.GetOrCreate($@"test-key {i % 2}", cacheEntry => { cacheEntry.SlidingExpiration = TimeSpan.FromSeconds(10); diff --git a/tests/VirtoCommerce.Platform.Caching.Tests/VirtoCommerce.Platform.Caching.Tests.csproj b/tests/VirtoCommerce.Platform.Caching.Tests/VirtoCommerce.Platform.Caching.Tests.csproj index 6fd65fc2613..47e83efe1ed 100644 --- a/tests/VirtoCommerce.Platform.Caching.Tests/VirtoCommerce.Platform.Caching.Tests.csproj +++ b/tests/VirtoCommerce.Platform.Caching.Tests/VirtoCommerce.Platform.Caching.Tests.csproj @@ -11,7 +11,7 @@ all - + diff --git a/tests/VirtoCommerce.Platform.Core.Tests/Common/AsyncLockTests.cs b/tests/VirtoCommerce.Platform.Core.Tests/Common/AsyncLockTests.cs index a437a519a5b..b2043a6f901 100644 --- a/tests/VirtoCommerce.Platform.Core.Tests/Common/AsyncLockTests.cs +++ b/tests/VirtoCommerce.Platform.Core.Tests/Common/AsyncLockTests.cs @@ -1,9 +1,5 @@ -using System; using System.Collections.Generic; using System.Diagnostics; -using System.Linq; -using System.Text; -using System.Threading; using System.Threading.Tasks; using VirtoCommerce.Platform.Core.Common; using Xunit; @@ -14,9 +10,9 @@ namespace VirtoCommerce.Platform.Core.Tests.Common public class AsyncLockTests { [Fact] - public Task AsyncLockExlusiveAccess() + public Task AsyncLockExclusiveAccess() { - int counter = 0; + var counter = 0; var tasks = new List(); for (var threadNumber = 0; threadNumber < 3; threadNumber++) { @@ -24,7 +20,7 @@ public Task AsyncLockExlusiveAccess() { for (var i = 0; i < 10; i++) { - using (await AsyncLock.GetLockByKey("test-key").GetReleaserAsync()) + using (await AsyncLock.GetLockByKey("test-key").LockAsync()) { Debug.WriteLine($"{i} enter"); counter += i; diff --git a/tests/VirtoCommerce.Platform.Core.Tests/VirtoCommerce.Platform.Core.Tests.csproj b/tests/VirtoCommerce.Platform.Core.Tests/VirtoCommerce.Platform.Core.Tests.csproj index 86703107a9e..5d2f323aff1 100644 --- a/tests/VirtoCommerce.Platform.Core.Tests/VirtoCommerce.Platform.Core.Tests.csproj +++ b/tests/VirtoCommerce.Platform.Core.Tests/VirtoCommerce.Platform.Core.Tests.csproj @@ -11,7 +11,7 @@ all - + diff --git a/tests/VirtoCommerce.Platform.Tests/AssemblyInfo.cs b/tests/VirtoCommerce.Platform.Tests/AssemblyInfo.cs deleted file mode 100644 index ee6b0a27df5..00000000000 --- a/tests/VirtoCommerce.Platform.Tests/AssemblyInfo.cs +++ /dev/null @@ -1,3 +0,0 @@ -using Xunit; - -[assembly: TestFramework("Xunit.Extensions.Ordering.TestFramework", "Xunit.Extensions.Ordering")] diff --git a/tests/VirtoCommerce.Platform.Tests/Modularity/ExternalModuleCatalogTests.cs b/tests/VirtoCommerce.Platform.Tests/Modularity/ExternalModuleCatalogTests.cs index c92d60bea4d..c887e131455 100644 --- a/tests/VirtoCommerce.Platform.Tests/Modularity/ExternalModuleCatalogTests.cs +++ b/tests/VirtoCommerce.Platform.Tests/Modularity/ExternalModuleCatalogTests.cs @@ -14,12 +14,10 @@ using VirtoCommerce.Platform.Modules.External; using VirtoCommerce.Platform.Modules.Local; using Xunit; -using Xunit.Extensions.Ordering; namespace VirtoCommerce.Platform.Tests.Modularity { - //the Order is needed for running separate UnitTests where static Platform.CurrentVersion is used - [Collection("Modularity"), Order(1)] + [Collection("Modularity")] public class ExternalModuleCatalogTests { private static Mutex _mutex = new Mutex(); diff --git a/tests/VirtoCommerce.Platform.Tests/Modularity/ModuleInstallerUnitTests.cs b/tests/VirtoCommerce.Platform.Tests/Modularity/ModuleInstallerUnitTests.cs index dad1ed88d94..d0d08ae87db 100644 --- a/tests/VirtoCommerce.Platform.Tests/Modularity/ModuleInstallerUnitTests.cs +++ b/tests/VirtoCommerce.Platform.Tests/Modularity/ModuleInstallerUnitTests.cs @@ -15,12 +15,10 @@ using VirtoCommerce.Platform.Modules; using VirtoCommerce.Platform.Modules.External; using Xunit; -using Xunit.Extensions.Ordering; namespace VirtoCommerce.Platform.Tests.Modularity { - //the Order is needed for running separate UnitTests where static Platform.CurrentVersion is used - [Collection("Modularity"), Order(3)] + [Collection("Modularity")] public class ModuleInstallerUnitTests { private readonly LocalStorageModuleCatalogOptions _options; diff --git a/tests/VirtoCommerce.Platform.Tests/Modularity/ModulePlatformCompatibilityTests.cs b/tests/VirtoCommerce.Platform.Tests/Modularity/ModulePlatformCompatibilityTests.cs index c3528ab6d5f..8dad7c339a7 100644 --- a/tests/VirtoCommerce.Platform.Tests/Modularity/ModulePlatformCompatibilityTests.cs +++ b/tests/VirtoCommerce.Platform.Tests/Modularity/ModulePlatformCompatibilityTests.cs @@ -6,11 +6,10 @@ using VirtoCommerce.Platform.DistributedLock; using VirtoCommerce.Platform.Modules; using Xunit; -using Xunit.Extensions.Ordering; namespace VirtoCommerce.Platform.Tests.Modularity { - [Collection("Modularity"), Order(5)] + [Collection("Modularity")] public class ModulePlatformCompatibilityTests { [Theory] diff --git a/tests/VirtoCommerce.Platform.Tests/VirtoCommerce.Platform.Tests.csproj b/tests/VirtoCommerce.Platform.Tests/VirtoCommerce.Platform.Tests.csproj index cb567dbb62f..6bc9020e636 100644 --- a/tests/VirtoCommerce.Platform.Tests/VirtoCommerce.Platform.Tests.csproj +++ b/tests/VirtoCommerce.Platform.Tests/VirtoCommerce.Platform.Tests.csproj @@ -16,13 +16,12 @@ - + - runtime; build; native; contentfiles; analyzers all diff --git a/tests/VirtoCommerce.Platform.Web.Tests/VirtoCommerce.Platform.Web.Tests.csproj b/tests/VirtoCommerce.Platform.Web.Tests/VirtoCommerce.Platform.Web.Tests.csproj index c21bf9f52d9..9dd508b5916 100644 --- a/tests/VirtoCommerce.Platform.Web.Tests/VirtoCommerce.Platform.Web.Tests.csproj +++ b/tests/VirtoCommerce.Platform.Web.Tests/VirtoCommerce.Platform.Web.Tests.csproj @@ -12,7 +12,7 @@ all - + diff --git a/tests/VirtoCommerce.Testing/VirtoCommerce.Testing.csproj b/tests/VirtoCommerce.Testing/VirtoCommerce.Testing.csproj index 6defe7540ce..94443ad2213 100644 --- a/tests/VirtoCommerce.Testing/VirtoCommerce.Testing.csproj +++ b/tests/VirtoCommerce.Testing/VirtoCommerce.Testing.csproj @@ -2,7 +2,7 @@ net8.0 - 1591 + 1591;NU5048 latest True true