31 lines
1.2 KiB
C#
31 lines
1.2 KiB
C#
using System.Text.RegularExpressions;
|
|
using Microsoft.EntityFrameworkCore;
|
|
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
|
|
|
namespace Authinator.Backend.Database.Tables;
|
|
|
|
public record ACL {
|
|
public int Id { get; set; }
|
|
public string Name { get; set; } = null!;
|
|
public bool Enabled { get; set; } = true;
|
|
public string Target { get; set; } = null!;
|
|
public bool TargetIsRegex { get; set; }
|
|
public List<User> Users { get; set; } = new();
|
|
public List<Group> Groups { get; set; } = new();
|
|
public List<Network> Networks { get; set; } = new();
|
|
|
|
public class Configuration : IEntityTypeConfiguration<ACL> {
|
|
public void Configure(EntityTypeBuilder<ACL> acl) {
|
|
acl.ToTable("ACLs");
|
|
acl.HasKey(p => p.Id);
|
|
acl.Property(b => b.Name).HasColumnName("Name").IsRequired();
|
|
acl.Property(p => p.Target).HasColumnName("Target").IsRequired();
|
|
acl.Property(p => p.Enabled).HasColumnName("Enabled").IsRequired();
|
|
acl.Property(p => p.TargetIsRegex).HasColumnName("TargetIsRegex").HasDefaultValue(false);
|
|
acl.HasMany(p => p.Networks).WithMany();
|
|
acl.HasMany(p => p.Groups).WithMany();
|
|
acl.HasMany(p => p.Users).WithMany();
|
|
}
|
|
}
|
|
}
|