summary refs log tree commit diff
path: root/ModAS.Server/Attributes/UserAuthAttribute.cs
diff options
context:
space:
mode:
authorRory& <root@rory.gay>2023-12-31 12:00:40 +0100
committerRory& <root@rory.gay>2023-12-31 12:00:40 +0100
commitc5b72e6f002a637d542068be88d70936150c8818 (patch)
treec7d7a5c99329e88bce47b60b566b8398c0dd4a68 /ModAS.Server/Attributes/UserAuthAttribute.cs
parentRoom query (diff)
downloadModAS-c5b72e6f002a637d542068be88d70936150c8818.tar.xz
Add auth, start of commit script
Diffstat (limited to 'ModAS.Server/Attributes/UserAuthAttribute.cs')
-rw-r--r--ModAS.Server/Attributes/UserAuthAttribute.cs27
1 files changed, 27 insertions, 0 deletions
diff --git a/ModAS.Server/Attributes/UserAuthAttribute.cs b/ModAS.Server/Attributes/UserAuthAttribute.cs
new file mode 100644
index 0000000..ef8295a
--- /dev/null
+++ b/ModAS.Server/Attributes/UserAuthAttribute.cs
@@ -0,0 +1,27 @@
+using System.Text.Json;
+using System.Text.Json.Serialization;
+
+namespace ModAS.Server.Attributes;
+
+public class UserAuthAttribute : Attribute {
+    public AuthType AuthType { get; set; }
+    public AuthRoles AnyRoles { get; set; }
+
+    public string ToJson() => JsonSerializer.Serialize(new {
+        AuthType,
+        AnyRoles
+    });
+}
+
+[JsonConverter(typeof(JsonStringEnumConverter))]
+public enum AuthType {
+    User,
+    Server
+}
+
+[JsonConverter(typeof(JsonStringEnumConverter))]
+[Flags]
+public enum AuthRoles {
+    Administrator = 1 << 0,
+    Developer = 1 << 1,
+}
\ No newline at end of file