This repository has been archived by the owner on Jul 26, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 404
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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]>
- Loading branch information
1 parent
12f1d3e
commit 148e5ce
Showing
3 changed files
with
17 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters