aboutsummaryrefslogtreecommitdiffstats
path: root/code/api/src/Models/Misc/AppConfiguration.cs
blob: 9ed6fe4d0af51c44aa8e7e227db16f93a0d1d28b (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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
using System.Security.Cryptography.X509Certificates;

namespace IOL.GreatOffice.Api.Models.Models;

public class AppConfiguration
{
    /// <summary>
    /// An reachable ip address or url that points to a postgres database.
    /// </summary>
    public string DB_HOST { get; set; }

    /// <summary>
    /// The port number to use with DB_HOST to point to the postgres database.
    /// </summary>
    public string DB_PORT { get; set; }

    /// <summary>
    /// The database user to authenticate against postgres with.
    /// </summary>
    public string DB_USER { get; set; }

    /// <summary>
    /// The password for the database user to authenticate against postgres with.
    /// </summary>
    public string DB_PASSWORD { get; set; }

    /// <summary>
    /// The name of the main app database.
    /// </summary>
    public string DB_NAME { get; set; }

    /// <summary>
    /// An reachable ip address or url that points to a postgres(quartz) database.
    /// </summary>
    public string QUARTZ_DB_HOST { get; set; }

    /// <summary>
    /// The port number to use with QUARTZ_DB_HOST to point to the postgres(quartz) database.
    /// </summary>
    public string QUARTZ_DB_PORT { get; set; }

    /// <summary>
    /// The database user to authenticate against postgres(quartz) with.
    /// </summary>
    public string QUARTZ_DB_USER { get; set; }

    /// <summary>
    /// The password for the database user to authenticate against postgres(quartz) with.
    /// </summary>
    public string QUARTZ_DB_PASSWORD { get; set; }

    /// <summary>
    /// The name of the quartz database.
    /// </summary>
    public string QUARTZ_DB_NAME { get; set; }

    /// <summary>
    /// API key to use when pushing logs to SEQ
    /// </summary>
    public string SEQ_API_KEY { get; set; }

    /// <summary>
    /// Url pointing to the seq instance that processes server logs
    /// </summary>
    public string SEQ_API_URL { get; set; }

    /// <summary>
    /// A token used when sending email via Postmakr
    /// </summary>
    public string POSTMARK_TOKEN { get; set; }

    /// <summary>
    /// The address to send emails from, needs to be setup as a sender in postmark
    /// </summary>
    public string EMAIL_FROM_ADDRESS { get; set; }

    /// <summary>
    /// The absolute url to the frontend app
    /// </summary>
    public string CANONICAL_FRONTEND_URL { get; set; }

    /// <summary>
    /// The absolute url to the backend api
    /// </summary>
    public string CANONICAL_BACKEND_URL { get; set; }

    /// <summary>
    /// A random string used to encrypt/decrypt for general purposes
    /// </summary>
    public string APP_AES_KEY { get; set; }

    /// <summary>
    /// A base64 string containing a passwordless pfx cert
    /// </summary>
    public string APP_CERT { get; set; }

    public X509Certificate2 CERT1() => new(Convert.FromBase64String(APP_CERT));

    public object GetPublicObject()
    {
        return new
        {
            DB_HOST,
            DB_PORT,
            DB_USER,
            DB_PASSWORD = DB_PASSWORD.Obfuscate() ?? "",
            QUARTZ_DB_HOST,
            QUARTZ_DB_PORT,
            QUARTZ_DB_USER,
            QUARTZ_DB_PASSWORD = QUARTZ_DB_PASSWORD.Obfuscate() ?? "",
            SEQ_API_KEY = SEQ_API_KEY.Obfuscate() ?? "",
            SEQ_API_URL,
            POSTMARK_TOKEN = POSTMARK_TOKEN.Obfuscate() ?? "",
            EMAIL_FROM_ADDRESS,
            APP_AES_KEY = APP_AES_KEY.Obfuscate() ?? "",
            CERT1 = CERT1().PublicKey.Oid.FriendlyName,
            CANONICAL_FRONTEND_URL
        };
    }
}