-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathAuthCredential.cs
More file actions
50 lines (38 loc) · 2.04 KB
/
Copy pathAuthCredential.cs
File metadata and controls
50 lines (38 loc) · 2.04 KB
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
using System;
namespace GeneralUpdate.Tools.Configuration;
/// <summary>
/// Generic authentication credential used for both upload and simulation scenarios.
/// Sensitive fields (passwords, tokens, API keys) are stored encrypted via DPAPI.
/// </summary>
public class AuthCredential
{
/// <summary>Authentication scheme to use.</summary>
public AuthScheme Scheme { get; set; } = AuthScheme.None;
// ── Basic Auth ────────────────────────────────────────────
/// <summary>Username for Basic Authentication.</summary>
public string Username { get; set; } = string.Empty;
/// <summary>DPAPI-encrypted password for Basic Authentication.</summary>
public string EncryptedPassword { get; set; } = string.Empty;
// ── Bearer Token ──────────────────────────────────────────
/// <summary>DPAPI-encrypted bearer token / JWT.</summary>
public string EncryptedToken { get; set; } = string.Empty;
/// <summary>
/// Optional login endpoint URL. When set, the upload service can
/// automatically obtain a fresh token by POSTing credentials to this endpoint.
/// </summary>
public string LoginUrl { get; set; } = string.Empty;
// ── API Key ───────────────────────────────────────────────
/// <summary>Custom HTTP header name for API Key (e.g. "X-API-Key").</summary>
public string ApiKeyHeaderName { get; set; } = "X-API-Key";
/// <summary>DPAPI-encrypted API key value.</summary>
public string EncryptedApiKey { get; set; } = string.Empty;
/// <summary>
/// Repair invalid enum values that may result from manual JSON editing
/// or unknown future scheme values.
/// </summary>
internal void Sanitize()
{
if (!Enum.IsDefined(typeof(AuthScheme), Scheme))
Scheme = AuthScheme.None;
}
}