From bedcb6b176130fc2c6bd4657c8af4d407b64c970 Mon Sep 17 00:00:00 2001 From: Jake Mannens Date: Thu, 28 Sep 2023 03:14:35 +1000 Subject: Updated DB schema and configured ACLs to use SIDs --- HBContext.cs | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) (limited to 'HBContext.cs') diff --git a/HBContext.cs b/HBContext.cs index 4334495..2bb477e 100644 --- a/HBContext.cs +++ b/HBContext.cs @@ -9,10 +9,13 @@ enum HBObjectId { AdminUser = -3 } -public class HBContext : DbContext { +public static class HBObjectGuid { public static readonly Guid NsfwTag = new("EBDAD4F8-455A-4351-8017-1D4854D6FA38"); public static readonly Guid IngestTag = new("EA212801-5BCC-4C0E-814F-FB9D30DB58BC"); + public static readonly Guid AdminUser = new("0623F137-F9D7-456C-A79F-C866B556FBF6"); +} +public class HBContext : DbContext { public DbSet Objects { get; set; } public DbSet TagDefinitions { get; set; } public DbSet Tags { get; set; } @@ -47,19 +50,20 @@ public class HBContext : DbContext { modelBuilder.Entity().ToTable("Tags"); modelBuilder.Entity().ToTable("Media"); modelBuilder.Entity().ToTable("UploadedFiles"); + modelBuilder.Entity().ToTable("SecurityPrincipals"); // Seed internal tag definitions // These should NEVER change modelBuilder.Entity().HasData(new TagDefinition[] { new() { ObjectId = (int) HBObjectId.NsfwTag, - Guid = NsfwTag, + Guid = HBObjectGuid.NsfwTag, Source = TagSource.Internal, Name = "nsfw" }, new() { ObjectId = (int) HBObjectId.IngestTag, - Guid = IngestTag, + Guid = HBObjectGuid.IngestTag, Source = TagSource.Internal, Name = "ingest" } @@ -69,7 +73,9 @@ public class HBContext : DbContext { modelBuilder.Entity().HasData(new User[] { new() { ObjectId = (int) HBObjectId.AdminUser, + Guid = HBObjectGuid.AdminUser, Name = "admin", + Sid = new SecurityIdentifier("S-1-5-18"), PasswordHash = UserService.HashPassword("admin") } }); @@ -85,4 +91,10 @@ public class HBContext : DbContext { .WithOne() .HasForeignKey("CurrentUploadedFileId"); } + + protected override void ConfigureConventions(ModelConfigurationBuilder configurationBuilder) { + configurationBuilder + .Properties() + .HaveConversion(); + } } \ No newline at end of file -- cgit v1.3