Skip to content

Commit

Permalink
switch credential
Browse files Browse the repository at this point in the history
  • Loading branch information
damienbod committed Aug 27, 2023
1 parent ac013de commit 081d8d3
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,12 @@ private async Task<X509Certificate2> GetCertificateAsync(string? identitifier)
var vaultBaseUrl = _configuration["CallApi:ClientCertificates:0:KeyVaultUrl"];
vaultBaseUrl ??= "https://damienbod.vault.azure.net";

var secretClient = new SecretClient(vaultUri: new Uri(vaultBaseUrl), credential: new DefaultAzureCredential());
var tenantId = _configuration["CallApi:TenantId"];
var clientId = _configuration["CallApi:ClientId"];
var clientSecretKeyVaultAccess = _configuration["ClientSecretKeyVaultAccess"];

var secretClient = new SecretClient(vaultUri: new Uri(vaultBaseUrl),
credential: new ClientSecretCredential(tenantId, clientId, clientSecretKeyVaultAccess));

// Create a new secret using the secret client.
var secretName = identitifier;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@ public static WebApplication ConfigureServices(this WebApplicationBuilder builde

services.AddControllers();

services.AddSingleton<IAuthorizationHandler, HasServiceApiRoleHandler>();

services.AddAuthorization(options =>
{
options.AddPolicy("ValidateAccessTokenPolicy", validateAccessTokenPolicy =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
else
{
// Add Secrets from UserSecrets for local development
configurationBuilder.AddUserSecrets("9f17b08c-435a-4f50-ba7a-802e68ca8d80");
configurationBuilder.AddUserSecrets("196b270c-b0c0-4b90-8f04-d3108e701d51");
}
});

Expand Down

0 comments on commit 081d8d3

Please sign in to comment.