Skip to content

Commit 3f19954

Browse files
committed
Fixed build
1 parent 3a631b1 commit 3f19954

File tree

8 files changed

+43
-27
lines changed

8 files changed

+43
-27
lines changed

src/Backend/src/Authoring.Core/Publishing/Services/PublishingService.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
using Confix.Authoring.Store;
99
using Confix.Common.Exceptions;
1010
using Confix.CryptoProviders;
11-
using Confix.CryptoProviders.AzureKeyVault;
1211
using GreenDonut;
1312
using static Confix.Authentication.Authorization.Permissions;
1413

src/Backend/src/Tooling/Tooling.csproj

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,14 @@
1313

1414

1515
<ItemGroup>
16-
<PackageReference Include="System.CommandLine"/>
17-
<PackageReference Include="Spectre.Console"/>
18-
<PackageReference Include="Spectre.Console.Json"/>
19-
<PackageReference Include="Microsoft.Extensions.Configuration"/>
20-
<PackageReference Include="Microsoft.Extensions.Configuration.Json"/>
21-
<PackageReference Include="Microsoft.Extensions.DependencyInjection"/>
22-
<PackageReference Include="Microsoft.Extensions.Http"/>
23-
<PackageReference Include="StrawberryShake.Server"/>
16+
<PackageReference Include="System.CommandLine" />
17+
<PackageReference Include="Spectre.Console" />
18+
<PackageReference Include="Spectre.Console.Json" />
19+
<PackageReference Include="Microsoft.Extensions.Configuration" />
20+
<PackageReference Include="Microsoft.Extensions.Configuration.Json" />
21+
<PackageReference Include="Microsoft.Extensions.DependencyInjection" />
22+
<PackageReference Include="Microsoft.Extensions.Http" />
23+
<PackageReference Include="StrawberryShake.Server" />
2424
</ItemGroup>
2525

2626
</Project>

src/Backend/src/Vault.Abstractions/Configuration/Transport/CypherAndIv.cs

Lines changed: 0 additions & 3 deletions
This file was deleted.

src/Backend/src/Vault.Abstractions/Configuration/Transport/GetConfigurationResponse.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,14 @@
22

33
namespace Vault.Host.Configuration.Transport;
44

5-
public record GetConfigurationResponse(CypherAndIv? Configuration, string? Error)
5+
public record GetConfigurationResponse(JsonDocument? Configuration, string? Error)
66
{
77
public static GetConfigurationResponse FromError(string error)
88
{
99
return new GetConfigurationResponse(null, error);
1010
}
1111

12-
public static GetConfigurationResponse FromSuccess(CypherAndIv content)
12+
public static GetConfigurationResponse FromSuccess(JsonDocument content)
1313
{
1414
return new GetConfigurationResponse(content, null);
1515
}

src/Backend/src/Vault.Client/ConfigurationClient.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ public async Task RefreshAsync(
7575
await RequestAsync<RefreshConfigurationResponse>(client, request, cancellationToken);
7676
}
7777

78-
public async Task<CypherAndIv?> GetAsync(
78+
public async Task<JsonDocument?> GetAsync(
7979
string applicationName,
8080
string applicationPartName,
8181
string environmentName,

src/Backend/src/Vault.Client/IConfigurationClient.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
using System.Text.Json;
22
using Confix.Vault.Abstractions;
3-
using Vault.Host.Configuration.Transport;
43

54
namespace Confix.Vault.Client;
65

@@ -13,7 +12,7 @@ Task<TokenPair> CreateAsync(
1312
string configuration,
1413
CancellationToken cancellationToken);
1514

16-
Task<CypherAndIv?> GetAsync(
15+
Task<JsonDocument?> GetAsync(
1716
string applicationName,
1817
string applicationPartName,
1918
string environmentName,

src/Backend/src/Vault.Configuration/VaulConfigurationProvider.cs

Lines changed: 29 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -180,11 +180,7 @@ private static void UpdateLocalConfiguration(
180180
// we use the vault client to load the configuration from the vault. The configuration
181181
// provider only has a synchronous interface so we need to use the GetAwaiter().GetResult().
182182
// Not nice but it works.
183-
var client = VaultClientFactory.CreateClient(vaultToken);
184-
var response = client
185-
.GetAsync(applicationName, partName, environment, vaultToken, CancellationToken.None)
186-
.GetAwaiter()
187-
.GetResult();
183+
var response = FetchVaultConfig(applicationName, partName, environment, vaultToken);
188184

189185
if (response is not var (cypher, iv))
190186
{
@@ -203,6 +199,34 @@ private static void UpdateLocalConfiguration(
203199

204200
return null;
205201
}
202+
203+
static CypherAndIv? FetchVaultConfig(
204+
string applicationName,
205+
string partName,
206+
string environment,
207+
string vaultToken)
208+
{
209+
try
210+
{
211+
var client = VaultClientFactory.CreateClient(vaultToken);
212+
var ct = CancellationToken.None;
213+
var response = client
214+
.GetAsync(applicationName, partName, environment, vaultToken, ct)
215+
.GetAwaiter()
216+
.GetResult();
217+
218+
if (response is null)
219+
{
220+
return null;
221+
}
222+
223+
return response.Deserialize<CypherAndIv>();
224+
}
225+
catch
226+
{
227+
return null;
228+
}
229+
}
206230
}
207231

208232
private static IDataProtector CreateProtector() => new ServiceCollection().AddDataProtection()

src/Backend/src/Vault.Console/Program.cs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,8 @@
2828
var token = ReadLine(cancellationToken);
2929

3030
Console.WriteLine("Fetching...");
31-
using var response = await client.GetAsync(applicationName,
32-
applicationPartName,
33-
environmentName,
34-
token,
35-
cancellationToken);
31+
using var response = await client
32+
.GetAsync(applicationName, applicationPartName, environmentName, token, cancellationToken);
3633

3734
Console.WriteLine("Response...");
3835

0 commit comments

Comments
 (0)