From aa0b68f7648bd5a7c14b64737a4f8d3e402bfce5 Mon Sep 17 00:00:00 2001 From: Jake Mannens Date: Wed, 4 Oct 2023 15:59:52 +1100 Subject: Fix SID equality and WellKnownSid mappings --- HBContext.cs | 2 +- HBObject.cs | 2 +- Pages/Component/AclDialog.razor | 57 ++++++++++++-------- Pages/Component/AclDialog.razor.css | 30 ++++++++++- Pages/Component/Dialog.razor | 14 +++-- Pages/Component/Switch.razor.css | 8 +-- PrincipalProviders/LocalPrincipalProvider.cs | 8 +++ SecurityIdentifier.cs | 79 ++++++++++++++++++++++------ Services/PrincipalProvider.cs | 17 ++++++ 9 files changed, 168 insertions(+), 49 deletions(-) diff --git a/HBContext.cs b/HBContext.cs index 2e78b5a..dee100d 100644 --- a/HBContext.cs +++ b/HBContext.cs @@ -57,7 +57,7 @@ public class HBContext : DbContext { modelBuilder.Entity() .Property(o => o.Owner) - .HasDefaultValue(new SecurityIdentifier(WellKnownSidType.WorldSid)); + .HasDefaultValue(WellKnownSid.WorldSid); // Seed internal tag definitions // These should NEVER change diff --git a/HBObject.cs b/HBObject.cs index df60ed0..eecb3f5 100644 --- a/HBObject.cs +++ b/HBObject.cs @@ -15,5 +15,5 @@ public class HBObject { [ForeignKey("AclId")] public Acl? Acl { get; set; } public SecurityIdentifier Owner { get; set; } = - new SecurityIdentifier(WellKnownSidType.WorldSid); + WellKnownSid.WorldSid; } \ No newline at end of file diff --git a/Pages/Component/AclDialog.razor b/Pages/Component/AclDialog.razor index 8116f04..87fbd6e 100644 --- a/Pages/Component/AclDialog.razor +++ b/Pages/Component/AclDialog.razor @@ -2,35 +2,46 @@ @inject IDbContextFactory dbFactory; @implements IDialog - - @if(obj?.Acl is not null) { - - - - - - - - @foreach(var rule in obj.Acl.Rules.OrderByDescending(r => r.Action)) { - - - - - - + +
+
+ @if(obj?.Acl is not null) { +
ActionSubjectPermissions
@rule.Principal.ToString()@GetActivePermissions(rule) - 🖉 - -
+ + + + + + @foreach(var rule in obj.Acl.Rules.OrderByDescending(r => r.Action)) { + + + + + + + } +
ActionSubjectPermissions
+ @(WellKnownSid.TranslateSid(rule.Principal) ?? rule.Principal.ToString()) + @GetActivePermissions(rule) + 🖉 + +
+
+
Add new
+ } else { +
This item does not have any permissions set!
} - -
-
Add new
+ +
+

Click Edit next to an ACL to edit it's permissions

+
+ + @if(obj?.Acl is not null) { } else { -
This item does not have any permissions set!
diff --git a/Pages/Component/AclDialog.razor.css b/Pages/Component/AclDialog.razor.css index f1b7931..b98cc6d 100644 --- a/Pages/Component/AclDialog.razor.css +++ b/Pages/Component/AclDialog.razor.css @@ -1,4 +1,28 @@ -table p { +div.container { + display: flex; + flex-direction: row; +} + +div.container > div { + width: 50%; +} + +div.container > div:first-child { + border-right: 1px solid white; + padding-right: 15px; +} + +div.container > div:last-child { + padding-left: 15px; + height: stretch; +} + +div.container > div:last-child p { + vertical-align: middle; + text-align: center; +} + +table p { margin: 8px 0 8px 0; } @@ -17,6 +41,10 @@ table td:last-child { font-size: 12pt; } +table td:nth-last-child(2) { + border-right: none !important; +} + table tr:nth-child(2n+1) td:not(:first-child) { background: rgba(255, 255, 255, 0.1); } diff --git a/Pages/Component/Dialog.razor b/Pages/Component/Dialog.razor index 673ec2f..8e8ddca 100644 --- a/Pages/Component/Dialog.razor +++ b/Pages/Component/Dialog.razor @@ -4,7 +4,7 @@