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

Support Azure sovereign cloud environments #871

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: 4 additions & 0 deletions charts/kubernetes-external-secrets/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ env:
# AWS_SSM_ENDPOINT: http://ssm-fips.us-east-1.amazonaws.com
# AWS_SM_ENDPOINT: http://secretsmanager-fips.us-east-1.amazonaws.com

# Use Azure Environment-oriented KeyVault endpoints
# AZURE_ENVIRONMENT: AzureUSGovernment
# AZURE_KEY_VAULT_DNS_SUFFIX: vault.usgovcloudapi.net

# Create environment variables from existing k8s secrets
envVarsFromSecret: {}
# AWS_ACCESS_KEY_ID:
Expand Down
13 changes: 11 additions & 2 deletions config/azure-config.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,23 @@
'use strict'

const { DefaultAzureCredential } = require('@azure/identity')
const { DefaultAzureCredential, AzureAuthorityHosts } = require('@azure/identity')
// DefaultAzureCredential expects the following three environment variables:
// - AZURE_TENANT_ID: The tenant ID in Azure Active Directory
// - AZURE_CLIENT_ID: The application (client) ID registered in the AAD tenant
// - AZURE_CLIENT_SECRET: The client secret for the registered application
// An optional environment variable AZURE_ENVIRONMENT may be provided to specify cloud environment

const authorityHostMap = new Map()
authorityHostMap.set('AzureCloud', AzureAuthorityHosts.AzurePublicCloud)
authorityHostMap.set('AzureChinaCloud', AzureAuthorityHosts.AzureChina)
authorityHostMap.set('AzureGermanCloud', AzureAuthorityHosts.AzureGermany)
authorityHostMap.set('AzureUSGovernment', AzureAuthorityHosts.AzureGovernment)

module.exports = {
azureKeyVault: () => {
const credential = new DefaultAzureCredential()
const env = process.env.AZURE_ENVIRONMENT || 'AzureCloud'
const host = authorityHostMap.get(env)
const credential = new DefaultAzureCredential({ authorityHost: host })
return credential
}
}
3 changes: 2 additions & 1 deletion lib/backends/azure-keyvault-backend.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,11 @@ class AzureKeyVaultBackend extends KVBackend {
constructor ({ credential, logger }) {
super({ logger })
this._credential = credential
this._endpointSuffix = process.env.AZURE_KEY_VAULT_DNS_SUFFIX || 'vault.azure.net'
}

_keyvaultClient ({ keyVaultName }) {
const url = `https://${keyVaultName}.vault.azure.net`
const url = `https://${keyVaultName}.${this._endpointSuffix}`
const client = new SecretClient(url, this._credential)
return client
}
Expand Down