summary refs log tree commit diff
path: root/extra/admin-api/Models/Spacebar.Models.Config/SecurityConfiguration.cs
blob: 88681d2dfcfae181513c2668ecfad2c6ba9ee71a (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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
using System.Text.Json.Serialization;

namespace Spacebar.ConfigModel;

public class SecurityConfiguration {
    [JsonPropertyName("captcha")]
    public CaptchaConfiguration Captcha { get; set; } = new();

    [JsonPropertyName("twoFactor")]
    public TwoFactorConfiguration TwoFactor { get; set; } = new();

    [JsonPropertyName("requestSignature")] public string RequestSignature; // {get;set;}=crypto.randomBytes(32).toString("base64");

    [JsonPropertyName("jwtSecret")]
    public string? JwtSecret { get; set; } = null;

    [JsonPropertyName("forwardedFor")]
    public string? ForwardedFor { get; set; } = null;

    [JsonPropertyName("trustedProxies")]
    public string TrustedProxies { get; set; } = null;

    [JsonPropertyName("abuseIpDbApiKey")]
    public string? AbuseIpDbApiKey { get; set; } = null;

    [JsonPropertyName("abuseipdbBlacklistRatelimit")]
    public int AbuseipdbBlacklistRatelimit { get; set; } = 5;

    [JsonPropertyName("abuseipdbConfidenceScoreTreshold")]
    public int AbuseipdbConfidenceScoreTreshold { get; set; } = 50;

    [JsonPropertyName("ipdataApiKey")]
    public string? IpdataApiKey { get; set; } = null;

    [JsonPropertyName("mfaBackupCodeCount")]
    public int MfaBackupCodeCount { get; set; } = 10;

    [JsonPropertyName("statsWorldReadable")]
    public bool StatsWorldReadable { get; set; } = true;

    [JsonPropertyName("defaultRegistrationTokenExpiration")]
    public int DefaultRegistrationTokenExpiration { get; set; } = 1000 * 60 * 60 * 24 * 7;

    [JsonPropertyName("cdnSignUrls")]
    public bool CdnSignUrls { get; set; } = false;

    [JsonPropertyName("cdnSignatureKey")]
    public string CdnSignatureKey { get; set; } = null!; // crypto.randomBytes(32).toString("base64");

    [JsonPropertyName("cdnSignatureDuration")]
    public string CdnSignatureDuration { get; set; } = "24h";

    [JsonPropertyName("cdnSignatureIncludeIp")]
    public bool CdnSignatureIncludeIp { get; set; } = true;

    [JsonPropertyName("cdnSignatureIncludeUserAgent")]
    public bool CdnSignatureIncludeUserAgent { get; set; } = true;
}

public class CaptchaConfiguration {
    [JsonPropertyName("enabled")]
    public bool Enabled { get; set; } = false;

    /// <summary>
    /// One of: null, recaptcha, hcaptcha
    /// </summary>
    [JsonPropertyName("service")]
    public string Service { get; set; } = "none";

    [JsonPropertyName("sitekey")]
    public string? SiteKey { get; set; } = null;

    [JsonPropertyName("secret")]
    public string? Secret { get; set; } = null;
}

public class TwoFactorConfiguration {
    [JsonPropertyName("generateBackupCodes")]
    public bool GenerateBackupCodes { get; set; } = true;
}