Skip to content

Commit

Permalink
try key vault
Browse files Browse the repository at this point in the history
  • Loading branch information
Matthew Herb committed May 6, 2024
1 parent 38c8bc4 commit 2cfa6c5
Showing 1 changed file with 28 additions and 28 deletions.
56 changes: 28 additions & 28 deletions PoMad/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -65,44 +65,44 @@



//string? vaultUriString = builder.Configuration["VaultUri"];
//if (string.IsNullOrEmpty(vaultUriString))
//{
// throw new InvalidOperationException("VaultUri configuration not found.");
//}
//Uri keyVaultEndpoint = new Uri(vaultUriString);
//builder.Configuration.AddAzureKeyVault(keyVaultEndpoint, new DefaultAzureCredential());
string? vaultUriString = builder.Configuration["VaultUri"];
if (string.IsNullOrEmpty(vaultUriString))
{
throw new InvalidOperationException("VaultUri configuration not found.");
}
Uri keyVaultEndpoint = new Uri(vaultUriString);
builder.Configuration.AddAzureKeyVault(keyVaultEndpoint, new DefaultAzureCredential());

//// Build a secret client
//SecretClient client = new SecretClient(keyVaultEndpoint, new DefaultAzureCredential());
// Build a secret client
SecretClient client = new SecretClient(keyVaultEndpoint, new DefaultAzureCredential());

//// Retrieve secrets asynchronously
//var clientId = await client.GetSecretAsync("GoogleClientId");
//var clientSecret = await client.GetSecretAsync("GoogleClientSecret");
// Retrieve secrets asynchronously
var clientId = await client.GetSecretAsync("GoogleClientId");
var clientSecret = await client.GetSecretAsync("GoogleClientSecret");

//// Configure Google authentication with secrets from Azure Key Vault
//builder.Services.AddAuthentication().AddGoogle(options =>
//{
// options.ClientId = clientId.Value.Value;
// options.ClientSecret = clientSecret.Value.Value;
// options.SignInScheme = IdentityConstants.ExternalScheme;
//});
// Configure Google authentication with secrets from Azure Key Vault
builder.Services.AddAuthentication().AddGoogle(options =>
{
options.ClientId = clientId.Value.Value;
options.ClientSecret = clientSecret.Value.Value;
options.SignInScheme = IdentityConstants.ExternalScheme;
});







// Bind Google settings from appsettings.json
builder.Services.Configure<GoogleAuthConfig>(builder.Configuration.GetSection("GoogleAuth"));
builder.Services.AddAuthentication().AddGoogle(googleOptions =>
{
GoogleAuthConfig googleConfig = builder.Configuration.GetSection("GoogleAuth").Get<GoogleAuthConfig>();
googleOptions.ClientId = googleConfig.ClientId;
googleOptions.ClientSecret = googleConfig.ClientSecret;
googleOptions.SignInScheme = IdentityConstants.ExternalScheme;
});
//// Bind Google settings from appsettings.json
//builder.Services.Configure<GoogleAuthConfig>(builder.Configuration.GetSection("GoogleAuth"));
//builder.Services.AddAuthentication().AddGoogle(googleOptions =>
//{
// GoogleAuthConfig googleConfig = builder.Configuration.GetSection("GoogleAuth").Get<GoogleAuthConfig>();
// googleOptions.ClientId = googleConfig.ClientId;
// googleOptions.ClientSecret = googleConfig.ClientSecret;
// googleOptions.SignInScheme = IdentityConstants.ExternalScheme;
//});



Expand Down

0 comments on commit 2cfa6c5

Please sign in to comment.