summaryrefslogtreecommitdiff
path: root/Acl.cs
diff options
context:
space:
mode:
authorJake Mannens <jake@asger.xyz>2023-09-18 19:34:14 +1000
committerJake Mannens <jake@asger.xyz>2023-09-18 19:34:14 +1000
commitcb8179b5e5a8d5253d063ed607205f52643410fa (patch)
treeea5ab297ba2876ba4db236ae700b03f5aba0459b /Acl.cs
parent604ef537e0fabfbcc3abf9d7473b22f08dc549a6 (diff)
Initial commit
Diffstat (limited to 'Acl.cs')
-rw-r--r--Acl.cs35
1 files changed, 35 insertions, 0 deletions
diff --git a/Acl.cs b/Acl.cs
new file mode 100644
index 0000000..581a8bc
--- /dev/null
+++ b/Acl.cs
@@ -0,0 +1,35 @@
+namespace HyperBooru;
+
+public enum AclRuleAction {
+ Allow,
+ Deny
+}
+
+public class Acl : HBObject {
+ public HBObject Subject { get; set; }
+ public List<AclRule> Rules { get; set; }
+}
+
+public class Acl<T> : Acl where T : Enum {
+ public Type Type => typeof(T);
+
+ public new List<AclRule<T>> Rules {
+ get => base.Rules.Cast<AclRule<T>>().ToList();
+ set => base.Rules = value.Cast<AclRule>().ToList();
+ }
+}
+
+public class AclRule : HBObject {
+ public HBPrincipal Principal { get; set; }
+ public AclRuleAction Action { get; set; }
+ public ulong Permissions { get; set; }
+}
+
+public class AclRule<T> : AclRule where T : Enum {
+ public Type Type => typeof(T);
+
+ public new T Permissions {
+ get => (T) (object) base.Permissions;
+ set => base.Permissions = (ulong) (object) value;
+ }
+}