Skip to content

Commit

Permalink
upd SecurityPathRestriction
Browse files Browse the repository at this point in the history
  • Loading branch information
iatsuta committed Nov 18, 2024
1 parent 72d9414 commit 17d0f8f
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@ public SecurityPathRestriction(

public IEnumerable<Type>? SecurityContextTypes => this.SecurityContextRestrictions?.Select(v => v.Type);

public static SecurityPathRestriction Empty { get; } = new(null, Array.Empty<Type>(), []);
public static SecurityPathRestriction Disabled { get; } = new(null, Array.Empty<Type>(), []);

public static SecurityPathRestriction Empty { get; } = new([], Array.Empty<Type>(), []);

public SecurityPathRestriction Add<TSecurityContext>(bool required = false, string? key = null)
where TSecurityContext : ISecurityContext =>
Expand All @@ -43,8 +45,8 @@ public SecurityPathRestriction AddConditionFactory(Type conditionFactoryType) =>
new(this.SecurityContextRestrictions, this.ConditionFactoryTypes.Concat([conditionFactoryType]), this.RelativeConditions);

public static SecurityPathRestriction Create<TSecurityContext>(bool required = false, string? key = null)
where TSecurityContext : ISecurityContext => Empty.Add<TSecurityContext>(required, key);
where TSecurityContext : ISecurityContext => Disabled.Add<TSecurityContext>(required, key);

public static SecurityPathRestriction Create<TDomainObject>(Expression<Func<TDomainObject, bool>> condition) =>
Empty.AddRelativeCondition(condition);
Disabled.AddRelativeCondition(condition);
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ public record SecurityRoleInfo(Guid Id)
{
public HierarchicalExpandType? CustomExpandType { get; init; } = null;

public SecurityPathRestriction Restriction { get; init; } = SecurityPathRestriction.Empty;
public SecurityPathRestriction Restriction { get; init; } = SecurityPathRestriction.Disabled;

public IReadOnlyList<SecurityOperation> Operations { get; init; } = [];

Expand Down
2 changes: 1 addition & 1 deletion src/Framework.SecuritySystem.DiTests/SecurityPathTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ public void EmptySecurityPathRestriction_SecurityPathNotModified()

var testSecurityPath = baseSecurityPath.And(altSecurityPath);

var restriction = SecurityPathRestriction.Empty;
var restriction = SecurityPathRestriction.Disabled;

//Act
var result = service.ApplyRestriction(testSecurityPath, restriction);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,8 @@ public static ISecuritySystemSettings AddSecurityRoles(this ISecuritySystemSetti
SecurityRole.Administrator,
new SecurityRoleInfo(new Guid("d9c1d2f0-0c2f-49ab-bb0b-de13a456169e"))
{
Operations = typeof(SampleSystemSecurityOperation).GetStaticPropertyValueList<SecurityOperation>().ToList()
Operations = typeof(SampleSystemSecurityOperation).GetStaticPropertyValueList<SecurityOperation>().ToList(),
Restriction = SecurityPathRestriction.Empty
});
}

Expand Down
6 changes: 3 additions & 3 deletions src/__SolutionItems/CommonAssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
[assembly: AssemblyCompany("Luxoft")]
[assembly: AssemblyCopyright("Copyright © Luxoft 2009-2024")]

[assembly: AssemblyVersion("22.5.5.0")]
[assembly: AssemblyFileVersion("22.5.5.0")]
[assembly: AssemblyInformationalVersion("22.5.5.0")]
[assembly: AssemblyVersion("22.5.6.0")]
[assembly: AssemblyFileVersion("22.5.6.0")]
[assembly: AssemblyInformationalVersion("22.5.6.0")]

#if DEBUG
[assembly: AssemblyConfiguration("Debug")]
Expand Down

0 comments on commit 17d0f8f

Please sign in to comment.