Skip to content
This repository was archived by the owner on Jul 26, 2022. It is now read-only.

Commit 148e5ce

Browse files
feat(azure): Support Azure sovereign cloud environments (#871)
* Support Azure sovereign cloud environments Support providing Azure Environment-oriented KeyVault endpoints * Fix style issues * fix: js types Signed-off-by: Markus Maga <[email protected]> * refactor: one liners🤷 Signed-off-by: Markus Maga <[email protected]> Co-authored-by: Markus Maga <[email protected]>
1 parent 12f1d3e commit 148e5ce

File tree

3 files changed

+17
-3
lines changed

3 files changed

+17
-3
lines changed

charts/kubernetes-external-secrets/values.yaml

+4
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,10 @@ env:
3232
# AWS_SSM_ENDPOINT: http://ssm-fips.us-east-1.amazonaws.com
3333
# AWS_SM_ENDPOINT: http://secretsmanager-fips.us-east-1.amazonaws.com
3434

35+
# Use Azure Environment-oriented KeyVault endpoints
36+
# AZURE_ENVIRONMENT: AzureUSGovernment
37+
# AZURE_KEY_VAULT_DNS_SUFFIX: vault.usgovcloudapi.net
38+
3539
# Create environment variables from existing k8s secrets
3640
envVarsFromSecret: {}
3741
# AWS_ACCESS_KEY_ID:

config/azure-config.js

+11-2
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,23 @@
11
'use strict'
22

3-
const { DefaultAzureCredential } = require('@azure/identity')
3+
const { DefaultAzureCredential, AzureAuthorityHosts } = require('@azure/identity')
44
// DefaultAzureCredential expects the following three environment variables:
55
// - AZURE_TENANT_ID: The tenant ID in Azure Active Directory
66
// - AZURE_CLIENT_ID: The application (client) ID registered in the AAD tenant
77
// - AZURE_CLIENT_SECRET: The client secret for the registered application
8+
// An optional environment variable AZURE_ENVIRONMENT may be provided to specify cloud environment
9+
10+
const authorityHostMap = new Map()
11+
authorityHostMap.set('AzureCloud', AzureAuthorityHosts.AzurePublicCloud)
12+
authorityHostMap.set('AzureChinaCloud', AzureAuthorityHosts.AzureChina)
13+
authorityHostMap.set('AzureGermanCloud', AzureAuthorityHosts.AzureGermany)
14+
authorityHostMap.set('AzureUSGovernment', AzureAuthorityHosts.AzureGovernment)
815

916
module.exports = {
1017
azureKeyVault: () => {
11-
const credential = new DefaultAzureCredential()
18+
const env = process.env.AZURE_ENVIRONMENT || 'AzureCloud'
19+
const host = authorityHostMap.get(env)
20+
const credential = new DefaultAzureCredential({ authorityHost: host })
1221
return credential
1322
}
1423
}

lib/backends/azure-keyvault-backend.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,11 @@ class AzureKeyVaultBackend extends KVBackend {
1414
constructor ({ credential, logger }) {
1515
super({ logger })
1616
this._credential = credential
17+
this._endpointSuffix = process.env.AZURE_KEY_VAULT_DNS_SUFFIX || 'vault.azure.net'
1718
}
1819

1920
_keyvaultClient ({ keyVaultName }) {
20-
const url = `https://${keyVaultName}.vault.azure.net`
21+
const url = `https://${keyVaultName}.${this._endpointSuffix}`
2122
const client = new SecretClient(url, this._credential)
2223
return client
2324
}

0 commit comments

Comments
 (0)