Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 16 additions & 16 deletions src/Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,24 @@
<ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally>
</PropertyGroup>
<ItemGroup>
<PackageVersion Include="IvAt.CommonFramework.GenericRepository" Version="2.1.14" />
<PackageVersion Include="IvAt.CommonFramework.IdentitySource.Abstractions" Version="2.1.14" />
<PackageVersion Include="IvAt.CommonFramework.RelativePath" Version="2.1.14" />
<PackageVersion Include="IvAt.CommonFramework.VisualIdentitySource" Version="2.1.14" />
<PackageVersion Include="IvAt.CommonFramework.VisualIdentitySource.Abstractions" Version="2.1.14" />
<PackageVersion Include="IvAt.GenericQueryable.Abstractions" Version="2.1.14" />
<PackageVersion Include="IvAt.GenericQueryable.EntityFramework" Version="2.1.14" />
<PackageVersion Include="IvAt.HierarchicalExpand" Version="2.1.14" />
<PackageVersion Include="IvAt.HierarchicalExpand.Abstractions" Version="2.1.14" />
<PackageVersion Include="Microsoft.AspNetCore.Authentication.Negotiate" Version="10.0.2" />
<PackageVersion Include="IvAt.CommonFramework.GenericRepository" Version="2.2.1" />
<PackageVersion Include="IvAt.CommonFramework.IdentitySource.Abstractions" Version="2.2.1" />
<PackageVersion Include="IvAt.CommonFramework.RelativePath" Version="2.2.1" />
<PackageVersion Include="IvAt.CommonFramework.VisualIdentitySource" Version="2.2.1" />
<PackageVersion Include="IvAt.CommonFramework.VisualIdentitySource.Abstractions" Version="2.2.1" />
<PackageVersion Include="IvAt.GenericQueryable.Abstractions" Version="2.2.1" />
<PackageVersion Include="IvAt.GenericQueryable.EntityFramework" Version="2.2.1" />
<PackageVersion Include="IvAt.HierarchicalExpand" Version="2.2.1" />
<PackageVersion Include="IvAt.HierarchicalExpand.Abstractions" Version="2.2.1" />
<PackageVersion Include="Microsoft.AspNetCore.Authentication.Negotiate" Version="10.0.3" />
<PackageVersion Include="Microsoft.AspNetCore.Http" Version="2.3.9" />
<PackageVersion Include="Microsoft.EntityFrameworkCore" Version="9.0.6" />
<PackageVersion Include="Microsoft.EntityFrameworkCore.Proxies" Version="10.0.2" />
<PackageVersion Include="Microsoft.EntityFrameworkCore.Sqlite" Version="10.0.2" />
<PackageVersion Include="Microsoft.Extensions.Configuration.Abstractions" Version="10.0.2" />
<PackageVersion Include="Microsoft.Extensions.DependencyInjection" Version="10.0.2" />
<PackageVersion Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="10.0.2" />
<PackageVersion Include="Microsoft.Extensions.Logging.Abstractions" Version="10.0.2" />
<PackageVersion Include="Microsoft.EntityFrameworkCore.Proxies" Version="10.0.3" />
<PackageVersion Include="Microsoft.EntityFrameworkCore.Sqlite" Version="10.0.3" />
<PackageVersion Include="Microsoft.Extensions.Configuration.Abstractions" Version="10.0.3" />
<PackageVersion Include="Microsoft.Extensions.DependencyInjection" Version="10.0.3" />
<PackageVersion Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="10.0.3" />
<PackageVersion Include="Microsoft.Extensions.Logging.Abstractions" Version="10.0.3" />
<PackageVersion Include="Swashbuckle.AspNetCore" Version="10.1.2" />
</ItemGroup>
<!-- Tests -->
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
namespace SecuritySystem.ExternalSystem.Management;
using System.Collections.Immutable;

namespace SecuritySystem.ExternalSystem.Management;

public record ManagedPermissionData
{
Expand All @@ -8,7 +10,9 @@ public record ManagedPermissionData

public string Comment { get; init; } = "";

public IReadOnlyDictionary<Type, Array> Restrictions { get; init; } = new Dictionary<Type, Array>();
public ImmutableDictionary<Type, Array> Restrictions { get; init; } = [];

public ImmutableDictionary<string, object> ExtendedData { get; init; } = [];

public static implicit operator ManagedPermissionData(SecurityRole securityRole) => new() { SecurityRole = securityRole };
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
using System.Collections.Immutable;

namespace SecuritySystem.ExternalSystem.Management;

public static class ManagedPermissionDataExtensions
{
public static TManagedPermissionData WithExtendedData<TManagedPermissionData>(this TManagedPermissionData managedPermissionData, string key, object value)
where TManagedPermissionData : ManagedPermissionData
{
var newExtendedData = managedPermissionData.ExtendedData.ToDictionary();

newExtendedData[key] = value;

return managedPermissionData with { ExtendedData = newExtendedData.ToImmutableDictionary() };
}
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
namespace SecuritySystem.ExternalSystem.Management;

public record ManagedPrincipalHeader(SecurityIdentity Identity, string Name, bool IsVirtual);
public record ManagedPrincipalHeader(SecurityIdentity Identity, string Name, bool IsVirtual);
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
using Microsoft.AspNetCore.Http;
using CommonFramework;

using Microsoft.AspNetCore.Http;

using SecuritySystem.Attributes;
using SecuritySystem.Configurator.Interfaces;
Expand Down Expand Up @@ -64,7 +66,7 @@ from restriction in permission.Contexts
SecurityRole = securityRoleSource.GetSecurityRole(new UntypedSecurityIdentity(permission.RoleId)),
Period = new PermissionPeriod(permission.StartDate, permission.EndDate),
Comment = permission.Comment,
Restrictions = restrictionsRequest.ToDictionary()
Restrictions = restrictionsRequest.ToImmutableDictionary()
};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace SecuritySystem.DiTests.Services;

public class ExamplePermissionSource(TestPermissionData data, DomainSecurityRule.ExpandedRoleGroupSecurityRule securityRule) : IPermissionSource
public class ExamplePermissionSource(TestPermissions data, DomainSecurityRule.ExpandedRoleGroupSecurityRule securityRule) : IPermissionSource
{
public bool HasAccess() => throw new NotImplementedException();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

namespace SecuritySystem.DiTests.Services;

public class ExamplePermissionSystem(ISecurityRuleExpander securityRuleExpander, TestPermissionData data) : IPermissionSystem
public class ExamplePermissionSystem(ISecurityRuleExpander securityRuleExpander, TestPermissions data) : IPermissionSystem
{
public Type PermissionType => throw new NotImplementedException();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

namespace SecuritySystem.DiTests.Services;

public class ExamplePermissionSystemFactory(ISecurityRuleExpander securityRuleExpander, TestPermissionData data) : IPermissionSystemFactory
public class ExamplePermissionSystemFactory(ISecurityRuleExpander securityRuleExpander, TestPermissions data) : IPermissionSystemFactory
{
public IPermissionSystem Create(SecurityRuleCredential securityRuleCredential) =>
new ExamplePermissionSystem(securityRuleExpander, data);
Expand Down
3 changes: 0 additions & 3 deletions src/SecuritySystem.DiTests/Services/TestPermissionData.cs

This file was deleted.

3 changes: 3 additions & 0 deletions src/SecuritySystem.DiTests/Services/TestPermissions.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
namespace SecuritySystem.DiTests.Services;

public record TestPermissions(List<TestPermission> Permissions);
2 changes: 1 addition & 1 deletion src/SecuritySystem.DiTests/TestBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,6 @@ protected virtual IServiceCollection CreateServices(IServiceCollection serviceCo
.AddRelativeDomainPath((Employee employee) => employee)
.AddSingleton(typeof(TestCheckboxConditionFactory<>))

.AddSingleton(_ => new TestPermissionData(this.GetPermissions().ToList()));
.AddSingleton(_ => new TestPermissions(this.GetPermissions().ToList()));
}
}
Loading
Loading