keyvault-configuration-resolver
Advanced tools
Comparing version 0.9.6 to 0.9.7
@@ -118,12 +118,35 @@ // | ||
if (!client) { | ||
if (!options.clientId) { | ||
throw new Error('Must provide an Azure Active Directory "clientId" value to the key vault resolver.'); | ||
let clientId = null; | ||
let clientSecret = null; | ||
let getClientCredentials = options.getClientCredentials; | ||
if (!getClientCredentials) { | ||
if (!options.clientId) { | ||
throw new Error('Must provide an Azure Active Directory "clientId" value to the key vault resolver.'); | ||
} | ||
if (!options.clientSecret) { | ||
throw new Error('Must provide an Azure Active Directory "clientSecret" value to the key vault resolver.'); | ||
} | ||
clientId = options.clientId; | ||
clientSecret = options.clientSecret; | ||
} | ||
if (!options.clientSecret) { | ||
throw new Error('Must provide an Azure Active Directory "clientSecret" value to the key vault resolver.'); | ||
} | ||
const clientId = options.clientId; | ||
const clientSecret = options.clientSecret; | ||
const authenticator = (challenge, authCallback) => { | ||
const context = new adalNode.AuthenticationContext(challenge.authorization); | ||
// Support optional delayed secret resolution | ||
if (getClientCredentials && (!clientId || !clientSecret)) { | ||
try { | ||
const ret = getClientCredentials(); | ||
if (ret) { | ||
clientId = ret.clientId; | ||
clientSecret = ret.clientSecret; | ||
} | ||
} catch (getClientCredentialsError) { | ||
return authCallback(getClientCredentialsError); | ||
} | ||
if (!clientId || !clientSecret) { | ||
return authCallback(new Error('After calling getClientCredentials, "clientId" and/or "clientSecret" remained unset. These values are required to authenticate with the vault.')); | ||
} | ||
} | ||
return context.acquireTokenWithClientCredentials(challenge.resource, clientId, clientSecret, (tokenAcquisitionError, tokenResponse) => { | ||
@@ -130,0 +153,0 @@ if (tokenAcquisitionError) { |
{ | ||
"name": "keyvault-configuration-resolver", | ||
"version": "0.9.6", | ||
"version": "0.9.7", | ||
"description": "Resolves custom keyvault:// URI values within an object graph using Azure KeyVault for Node.js", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
@@ -121,2 +121,4 @@ # Azure KeyVault configuration secrets resolver | ||
Alternatively, you can pass in a function called `getClientCredentials` that will be called when they are needed. `clientId` and `clientSecret` values are expected at this time. | ||
### With an existing KeyVault credentials instance | ||
@@ -123,0 +125,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
14430
174
157
0