summary refs log tree commit diff
path: root/ModAS.Server/Attributes/UserAuthAttribute.cs
blob: ef8295aa227731cc5f6436a519705c7a3ee589ca (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
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,
}