diff --git a/src/Framework.SecuritySystem.Abstract/SecurityRule/SecurityRule.cs b/src/Framework.SecuritySystem.Abstract/SecurityRule/SecurityRule.cs index ba08ed74..83f83955 100644 --- a/src/Framework.SecuritySystem.Abstract/SecurityRule/SecurityRule.cs +++ b/src/Framework.SecuritySystem.Abstract/SecurityRule/SecurityRule.cs @@ -27,5 +27,9 @@ public abstract record SecurityRule public record ModeSecurityRule(string Name) : SecurityRule { public override string ToString() => this.Name; + + public DomainSecurityRule.DomainModeSecurityRule ToDomain() => this.ToDomain(typeof(TDomainObject)); + + public DomainSecurityRule.DomainModeSecurityRule ToDomain(Type domainType) => new(domainType, this); } } diff --git a/src/Framework.SecuritySystem/DependencyInjection/DomainSecurityServiceBuilder/DomainSecurityServiceBuilder.cs b/src/Framework.SecuritySystem/DependencyInjection/DomainSecurityServiceBuilder/DomainSecurityServiceBuilder.cs index 3ec9033d..ee6756fa 100644 --- a/src/Framework.SecuritySystem/DependencyInjection/DomainSecurityServiceBuilder/DomainSecurityServiceBuilder.cs +++ b/src/Framework.SecuritySystem/DependencyInjection/DomainSecurityServiceBuilder/DomainSecurityServiceBuilder.cs @@ -36,7 +36,7 @@ public override void Register(IServiceCollection services) { foreach (var domainObjectSecurityPair in this.domainObjectSecurityDict) { - services.AddSingleton(new DomainModeSecurityRuleInfo(new DomainSecurityRule.DomainModeSecurityRule(this.DomainType, domainObjectSecurityPair.Key), domainObjectSecurityPair.Value)); + services.AddSingleton(new DomainModeSecurityRuleInfo(domainObjectSecurityPair.Key.ToDomain(this.DomainType), domainObjectSecurityPair.Value)); } if (this.securityPath != null) diff --git a/src/Framework.SecuritySystem/DependencyInjection/DomainSecurityServiceBuilder/DomainSecurityServiceWithFunctor.cs b/src/Framework.SecuritySystem/DependencyInjection/DomainSecurityServiceBuilder/DomainSecurityServiceWithFunctor.cs index db1d4d72..6d13b0ba 100644 --- a/src/Framework.SecuritySystem/DependencyInjection/DomainSecurityServiceBuilder/DomainSecurityServiceWithFunctor.cs +++ b/src/Framework.SecuritySystem/DependencyInjection/DomainSecurityServiceBuilder/DomainSecurityServiceWithFunctor.cs @@ -11,7 +11,7 @@ public class DomainSecurityServiceWithFunctor CreateSecurityProvider(SecurityRule.ModeSecurityRule securityRule) { - var actualSecurityRule = (SecurityRule?)securityRuleExpander.TryExpand(new DomainSecurityRule.DomainModeSecurityRule(typeof(TDomainObject), securityRule)) ?? securityRule; + var actualSecurityRule = (SecurityRule?)securityRuleExpander.TryExpand(securityRule.ToDomain()) ?? securityRule; var originalSecurityProvider = originalDomainSecurityService.GetSecurityProvider(actualSecurityRule); diff --git a/src/Framework.SecuritySystem/DomainServices/DependencySecurity/_Base/DependencyDomainSecurityServiceBase.cs b/src/Framework.SecuritySystem/DomainServices/DependencySecurity/_Base/DependencyDomainSecurityServiceBase.cs index 7b2ed72b..b186a134 100644 --- a/src/Framework.SecuritySystem/DomainServices/DependencySecurity/_Base/DependencyDomainSecurityServiceBase.cs +++ b/src/Framework.SecuritySystem/DomainServices/DependencySecurity/_Base/DependencyDomainSecurityServiceBase.cs @@ -10,8 +10,7 @@ public abstract class DependencyDomainSecurityServiceBase CreateSecurityProvider(SecurityRule securityRule) { if (securityRule is SecurityRule.ModeSecurityRule modeSecurityRule - && securityRuleExpander.TryExpand(new DomainSecurityRule.DomainModeSecurityRule(typeof(TDomainObject), modeSecurityRule)) is - { } customSecurityRule) + && securityRuleExpander.TryExpand(modeSecurityRule.ToDomain()) is { } customSecurityRule) { return this.CreateSecurityProvider(customSecurityRule); } diff --git a/src/Framework.SecuritySystem/DomainServices/DomainSecurityService.cs b/src/Framework.SecuritySystem/DomainServices/DomainSecurityService.cs index a1722725..e041eab4 100644 --- a/src/Framework.SecuritySystem/DomainServices/DomainSecurityService.cs +++ b/src/Framework.SecuritySystem/DomainServices/DomainSecurityService.cs @@ -38,7 +38,7 @@ protected sealed override ISecurityProvider CreateSecurityProvide protected virtual ISecurityProvider CreateSecurityProvider(SecurityRule.ModeSecurityRule securityRule) { - return this.GetSecurityProvider(new DomainModeSecurityRule(typeof(TDomainObject), securityRule)); + return this.GetSecurityProvider(securityRule.ToDomain()); } protected virtual ISecurityProvider CreateSecurityProvider(OperationSecurityRule securityRule) diff --git a/src/_DomainDriven/Framework.DomainDriven.ServiceModel.IAD.LegacyContext/ServiceCollectionExtensions.cs b/src/_DomainDriven/Framework.DomainDriven.ServiceModel.IAD.LegacyContext/ServiceCollectionExtensions.cs index 8d806921..3869492b 100644 --- a/src/_DomainDriven/Framework.DomainDriven.ServiceModel.IAD.LegacyContext/ServiceCollectionExtensions.cs +++ b/src/_DomainDriven/Framework.DomainDriven.ServiceModel.IAD.LegacyContext/ServiceCollectionExtensions.cs @@ -114,7 +114,7 @@ public static IServiceCollection RegisterProjectionDomainSecurityServices(this I if (pair.CustomViewSecurityRule != null) { - services.AddSingleton(new DomainModeSecurityRuleInfo(new DomainSecurityRule.DomainModeSecurityRule(pair.DomainType, SecurityRule.View), pair.CustomViewSecurityRule)); + services.AddSingleton(new DomainModeSecurityRuleInfo(SecurityRule.View.ToDomain(pair.DomainType), pair.CustomViewSecurityRule)); } } diff --git a/src/_SampleSystem/SampleSystem.Security/SampleSystemSecuritySystemExtensions.cs b/src/_SampleSystem/SampleSystem.Security/SampleSystemSecuritySystemExtensions.cs index 591bf76b..2ea12cd0 100644 --- a/src/_SampleSystem/SampleSystem.Security/SampleSystemSecuritySystemExtensions.cs +++ b/src/_SampleSystem/SampleSystem.Security/SampleSystemSecuritySystemExtensions.cs @@ -110,7 +110,7 @@ public static ISecuritySystemSettings AddSecurityRules(this ISecuritySystemSetti SecurityRule.Disabled.And((TestRestrictionObject v) => v.RestrictionHandler)) .AddSecurityRule( SampleSystemSecurityGroup.TestGroup, - new DomainSecurityRule.DomainModeSecurityRule(typeof(Employee), SecurityRule.View)); + SecurityRule.View.ToDomain()); } public static ISecuritySystemSettings AddCustomSecurityOperations(this ISecuritySystemSettings settings) diff --git a/src/__SolutionItems/CommonAssemblyInfo.cs b/src/__SolutionItems/CommonAssemblyInfo.cs index f38cc617..2470b711 100644 --- a/src/__SolutionItems/CommonAssemblyInfo.cs +++ b/src/__SolutionItems/CommonAssemblyInfo.cs @@ -4,9 +4,9 @@ [assembly: AssemblyCompany("Luxoft")] [assembly: AssemblyCopyright("Copyright © Luxoft 2009-2024")] -[assembly: AssemblyVersion("22.4.2.0")] -[assembly: AssemblyFileVersion("22.4.2.0")] -[assembly: AssemblyInformationalVersion("22.4.2.0")] +[assembly: AssemblyVersion("22.4.3.0")] +[assembly: AssemblyFileVersion("22.4.3.0")] +[assembly: AssemblyInformationalVersion("22.4.3.0")] #if DEBUG [assembly: AssemblyConfiguration("Debug")]