Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/Wemogy.AspNet/Controllers/ApiGatewayBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@ public abstract class ApiGatewayBase : ControllerBase
protected ApiGatewayBase(string baseUrl, IHttpContextAccessor httpContextAccessor)
{
_httpContextAccessor = httpContextAccessor;
_restClient = new RestClient(baseUrl).UseSystemTextJson(WemogyJson.Options);
_restClient = new RestClient(
baseUrl,
configureSerialization: s => s.UseSystemTextJson(WemogyJson.Options));
}

private ICollection<KeyValuePair<string, string>> GetHeadersMapped()
Expand Down
37 changes: 0 additions & 37 deletions src/Wemogy.AspNet/Startup/StartupExtensions.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
using System;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.ApplicationModels;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using Wemogy.AspNet.FluentValidation;
Expand Down Expand Up @@ -175,40 +173,5 @@ public static void UseDefaultEndpoints(this IApplicationBuilder applicationBuild
}
});
}

/// <summary>
/// Adds Azure Key Vault secrets to the configuration based on one of these authentication methods:
/// Identity: The calling application has an Azure Identity, and can authenticate against Azure Key Vault
/// Service Principal: The calling application has Client ID and Secret of an Azure Service Principal
/// </summary>
/// <param name="builder">An IConfigurationBuilder</param>
/// <param name="azureKeyVaultUri">The URI to the Azure Key Vault</param>
/// <param name="azureKeyVaultClientId">Fill, if you want to authenticate with a Service Principal, leave empty for Identity</param>
/// <param name="azureKeyVaultClientSecret">Secret. Fill, if you want to authenticate with a Service Principal, leave empty for Identity</param>
public static IConfigurationBuilder AddAuthenticatedAzureKeyVault(
this IConfigurationBuilder builder,
string azureKeyVaultUri,
string? azureKeyVaultClientId = null,
string? azureKeyVaultClientSecret = null)
{
// The clientId and clientSecrets fields should be left empty, as we always
// prefer connecting to Azure KeyVault using a manage identity of the system we are
// running on. Only in edge scenarios, we can provide an Client ID and Secret of an
// Azure Service principal that has access to Key Vault.
if (!string.IsNullOrEmpty(azureKeyVaultClientId) && !string.IsNullOrEmpty(azureKeyVaultClientSecret))
{
Console.Write($"Adding Azure KeyVault '{azureKeyVaultUri}' to configuration using credentials...");
builder.AddAzureKeyVault(azureKeyVaultUri, azureKeyVaultClientId, azureKeyVaultClientSecret);
}
else
{
Console.Write($"Adding Azure KeyVault '{azureKeyVaultUri}' to configuration using identity...");
builder.AddAzureKeyVault(azureKeyVaultUri);
}

Console.WriteLine("done.");

return builder;
}
}
}
3 changes: 1 addition & 2 deletions src/Wemogy.AspNet/Wemogy.AspNet.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,9 @@
<PackageReference Include="Microsoft.AspNetCore.Authorization" Version="6.0.5" />
<PackageReference Include="Microsoft.Azure.Services.AppAuthentication" Version="1.6.1" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="6.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.AzureKeyVault" Version="3.1.24" />
<PackageReference Include="Microsoft.Extensions.Configuration.EnvironmentVariables" Version="6.0.1" />
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="6.0.0" />
<PackageReference Include="RestSharp" Version="107.3.0" />
<PackageReference Include="RestSharp" Version="112.1.0" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.7.0" />
<PackageReference Include="Swashbuckle.AspNetCore.Swagger" Version="6.7.0" />
<PackageReference Include="Wemogy.Core" Version="3.2.2" />
Expand Down
Loading