-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add fetching of kofuvi addresses for br org (#4)
- Loading branch information
1 parent
d84d058
commit 83671e5
Showing
8 changed files
with
215 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
using System; | ||
using System.Security.Cryptography.X509Certificates; | ||
using System.Threading.Tasks; | ||
using Azure.Identity; | ||
using Azure.Security.KeyVault.Secrets; | ||
|
||
namespace Dan.Plugin.Tilda.Config; | ||
|
||
public class KeyVault | ||
{ | ||
private SecretClient SecretClient { get; } | ||
|
||
/// <summary> | ||
/// Key Vault for Core | ||
/// </summary> | ||
/// <param name="vaultName">Name of the Key Vault</param> | ||
public KeyVault(string vaultName) | ||
{ | ||
SecretClient = new SecretClient(new Uri($"https://{vaultName}.vault.azure.net/"), new DefaultAzureCredential()); | ||
} | ||
|
||
/// <summary> | ||
/// Get a secret from the key vault | ||
/// </summary> | ||
/// <param name="key">Secret name</param> | ||
/// <returns>The secret value</returns> | ||
public async Task<string> Get(string key) | ||
{ | ||
var secret = await SecretClient.GetSecretAsync(key); | ||
return secret.Value.Value; | ||
} | ||
|
||
/// <summary> | ||
/// Get a certificate from the key vault | ||
/// </summary> | ||
/// <param name="key">Certificate name</param> | ||
/// <returns>The certificate</returns> | ||
public async Task<X509Certificate2> GetCertificate(string key) | ||
{ | ||
var base64Certificate = await Get(key); | ||
var certBytes = Convert.FromBase64String(base64Certificate); | ||
|
||
var cert = new X509Certificate2(certBytes, string.Empty, X509KeyStorageFlags.MachineKeySet); | ||
|
||
return await Task.FromResult(cert); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using Newtonsoft.Json; | ||
|
||
namespace Dan.Plugin.Tilda.Models; | ||
|
||
[Serializable] | ||
public class KofuviResponse | ||
{ | ||
[JsonProperty("_embedded")] | ||
public Embedded Embedded { get; set; } | ||
} | ||
|
||
[Serializable] | ||
public class Embedded | ||
{ | ||
[JsonProperty("varsling")] | ||
public Notification Notification { get; set; } | ||
} | ||
|
||
[Serializable] | ||
public class Notification | ||
{ | ||
[JsonProperty("varslingsadresser")] | ||
public List<NotificationAddress> NotificationAddresses { get; set; } | ||
} | ||
|
||
[Serializable] | ||
public class NotificationAddress | ||
{ | ||
[JsonProperty("kontaktinformasjon")] | ||
public ContactInformation ContactInformation { get; set; } | ||
} | ||
|
||
[Serializable] | ||
public class ContactInformation | ||
{ | ||
[JsonProperty("digitalVarslingsinformasjon")] | ||
public DigitalNotificationInformation DigitalNotificationInformation { get; set; } | ||
} | ||
|
||
[Serializable] | ||
public class DigitalNotificationInformation | ||
{ | ||
[JsonProperty("epostadresse")] | ||
public NotificationEmail NotificationEmail { get; set; } | ||
} | ||
|
||
[Serializable] | ||
public class NotificationEmail | ||
{ | ||
[JsonProperty("fullstendigAdresse")] | ||
public string CompleteEmail { get; set; } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters