diff options
author | Rory& <root@rory.gay> | 2023-12-31 12:00:40 +0100 |
---|---|---|
committer | Rory& <root@rory.gay> | 2023-12-31 12:00:40 +0100 |
commit | c5b72e6f002a637d542068be88d70936150c8818 (patch) | |
tree | c7d7a5c99329e88bce47b60b566b8398c0dd4a68 /ModAS.Server/Attributes/UserAuthAttribute.cs | |
parent | Room query (diff) | |
download | ModAS-c5b72e6f002a637d542068be88d70936150c8818.tar.xz |
Add auth, start of commit script
Diffstat (limited to 'ModAS.Server/Attributes/UserAuthAttribute.cs')
-rw-r--r-- | ModAS.Server/Attributes/UserAuthAttribute.cs | 27 |
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 |