summary refs log tree commit diff
path: root/ModAS.Server/Attributes/UserAuthAttribute.cs
diff options
context:
space:
mode:
Diffstat (limited to '')
-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