Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Node.js access keyvault failure #23331

Closed
yzhengamat opened this issue Sep 27, 2022 · 37 comments
Closed

Node.js access keyvault failure #23331

yzhengamat opened this issue Sep 27, 2022 · 37 comments
Assignees
Labels
Azure.Identity bug This issue requires a change to an existing behavior in the product in order to be resolved. Client This issue points to a problem in the data-plane of the library. customer-reported Issues that are reported by GitHub users external to the Azure organization. needs-team-attention Workflow: This issue needs attention from Azure service team or SDK team Service Attention Workflow: This issue is responsible by Azure service team.

Comments

@yzhengamat
Copy link

I followed https://learn.microsoft.com/en-us/azure/key-vault/secrets/quick-create-node and uses latest packages for following packages "@azure/identity": "^2.1.0", "@azure/keyvault-secrets": "^4.5.1".

Code is like below
exports.getKeyValue3 = async function (req, res) {
const url = "";
var secreteResponse;
try {
console.log(process.env["AZURE_TENANT_ID"]);
console.log(process.env["AZURE_CLIENT_ID"]);
console.log(process.env["AZURE_CLIENT_SECRET"]);

const credential = new DefaultAzureCredential();
console.log('DefaultCredential ', credential);
const client = new SecretClient(url, credential);

console.log("SecretClient: created", client);
const secretValue = await client.getSecret('testsecret');
console.log("Retrieved secret: ", secretValue);
secreteResponse = { "message": "Keyvault secrete retrieved successfully", "statusCode": 200, "secret": secretValue};
res.send(secreteResponse);
}
catch (error) {
secreteResponse = { "message": "Keyvault secret retrieval failed \n" + error.message, "statusCode": 500, "secret": null};
res.send(secreteResponse);
}
};

Console.log gives back (including error) is like:

DefaultCredential DefaultAzureCredential {
UnavailableMessage: 'DefaultAzureCredential => failed to retrieve a token from the included credentials. To troubleshoot, visit https://aka.ms/azsdk/js/identity/defaultazurecredential/troubleshoot.',
_sources: [
EnvironmentCredential { _credential: [ClientSecretCredential] },
DefaultManagedIdentityCredential {
isEndpointUnavailable: null,
clientId: '',
identityClient: [IdentityClient],
isAvailableIdentityClient: [IdentityClient]
},
VisualStudioCodeCredential {
cloudName: 'AzureCloud',
identityClient: [IdentityClient],
tenantId: 'common'
},
AzureCliCredential { tenantId: undefined },
AzurePowerShellCredential { tenantId: undefined }
]
}
SecretClient: created SecretClient {
vaultUrl: '',
client: KeyVaultClient {
_requestContentType: 'application/json; charset=utf-8',
_endpoint: '{vaultBaseUrl}',
_allowInsecureConnection: undefined,
_httpClient: NodeHttpClient { cachedHttpsAgents: [WeakMap] },
pipeline: HttpPipeline { _policies: [Array], _orderedPolicies: undefined },
apiVersion: '7.3'
}
}

@xirzec xirzec transferred this issue from Azure/azure-sdk-for-node Sep 27, 2022
@ghost ghost added needs-triage Workflow: This is a new issue that needs to be triaged to the appropriate team. customer-reported Issues that are reported by GitHub users external to the Azure organization. question The issue doesn't require a change to the product in order to be resolved. Most issues start as that labels Sep 27, 2022
@xirzec xirzec added Client This issue points to a problem in the data-plane of the library. KeyVault labels Sep 27, 2022
@ghost ghost removed the needs-triage Workflow: This is a new issue that needs to be triaged to the appropriate team. label Sep 27, 2022
@azure-sdk azure-sdk added Azure.Identity needs-team-triage Workflow: This issue needs the team to triage. labels Sep 27, 2022
@xirzec xirzec removed the needs-team-triage Workflow: This issue needs the team to triage. label Sep 27, 2022
@xirzec
Copy link
Member

xirzec commented Sep 27, 2022

Looks like DefaultAzureCredential wasn't able to retrieve any credentials. Have you tried visiting the identity troubleshooting guide in the error message?

https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/identity/identity/TROUBLESHOOTING.md#troubleshoot-default-azure-credential-authentication-issues

@yzhengamat
Copy link
Author

@xirzec
Yes, I have gone through that link in the error message but it didn’t help me to solve the issue. In my code the console.log shows all the 3 environment variables are retrieved correctly.
Could you point out specifically what is missing or can be modified that cause the code "wasn't able to retrieve any credentials"?

@timovv
Copy link
Member

timovv commented Sep 29, 2022

Hi @yzhengamat!

I may be missing something, but I can't actually see any errors in your output. The line

UnavailableMessage: 'DefaultAzureCredential => failed to retrieve a token from the included credentials. To troubleshoot, visit https://aka.ms/azsdk/js/identity/defaultazurecredential/troubleshoot.',

is not actually an error: it's just a property on DefaultAzureCredential, and it presumably contains the error message that would be returned if an error was indeed thrown (it's set in the source code here).

Regardless, I assume that getting the secret is failing for one reason or another, otherwise you wouldn't be here! Is there any other output that might be of use (e.g. maybe you are catching an error in your try/catch that you can log)?

@xirzec
Copy link
Member

xirzec commented Sep 29, 2022

Whoops, thanks @timovv for pointing out the above logs are literally the DefaultAzureCredential and SecretClient being logged as objects

@yzhengamat
Copy link
Author

@timovv

The catch block get following error.message:

EnvironmentCredential authentication failed. To troubleshoot, visit https://aka.ms/azsdk/js/identity/environmentcredential/troubleshoot. Status code: 400\nMore details:\nendpoints_resolution_error: Error: could not resolve endpoints. Please check network and try again. Detail: ClientConfigurationError: untrusted_authority: The provided authority is not a trusted authority. Please include this authority in the knownAuthorities config parameter.

//The link "https://aka.ms/azsdk/js/identity/environmentcredential/troubleshoot" in the above message was not helpful to me

@xirzec
Copy link
Member

xirzec commented Sep 29, 2022

@yzhengamat there were some recent changes in Identity that I think might be affecting this. Could you try the latest version of
@azure/identity (3.0.0)?

@yzhengamat
Copy link
Author

@xirzec

After updated to version 3.0.0 and npm install again, I still get exact same exception error message as above.

@xirzec
Copy link
Member

xirzec commented Sep 29, 2022

After updated to version 3.0.0 and npm install again, I still get exact same exception error message as above.

Thanks for trying it. My next question is are you using a government cloud?

@yzhengamat
Copy link
Author

@xirzec not goverment cloud

@dyuan-boxlabs
Copy link

Any updates to this? I'm running into the same issue, using EnvironmentCredential and I've verified that AZURE_TENANT_ID, AZURE_CLIENT_ID, AZURE_CLIENT_SECRET is correct.

@xirzec
Copy link
Member

xirzec commented Oct 13, 2022

@KarishmaGhiya @schaabs do either of you know anything about this untrusted_authority: The provided authority is not a trusted authority error message? I'm a little confused about what could be causing it

@xirzec
Copy link
Member

xirzec commented Nov 4, 2022

@yzhengamat @dyuan-boxlabs circling back on this, can you try enabling logging? https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/identity/identity/README.md#logging

When using a ClientSecretCredential against keyvault and setting AZURE_LOG_LEVEL=info in my environment, I was able to see the initial request to my keyvault endpoint which got back a 401 that contained a www-authenticate header:

azure:keyvault-secrets:info Headers: {
  "cache-control": "no-cache",
  "pragma": "no-cache",
  "content-length": "97",
  "content-type": "application/json; charset=utf-8",
  "expires": "-1",
  "www-authenticate": "Bearer authorization=\"https://login.windows.net/72f988bf-86f1-41af-91ab-2d7cd011db47\", resource=\"https://vault.azure.net\"",

whereupon I can see MSAL do the credential request:

azure:identity:info ClientSecretCredential => MSAL Node V2 info message: [Fri, 04 Nov 2022 20:12:15 GMT] : [c3da3ce2-2a19-4b31-b2b4-7182be5ea89a] : @azure/msal-node@1.14.2 : Info - acquireTokenByClientCredential called
azure:core-rest-pipeline retryPolicy:info Retry 0: Attempting to send request a950877e-23d3-4067-9c0f-b4317992921e
azure:core-rest-pipeline:info Request: {
  "url": "https://login.microsoftonline.com/common/discovery/instance?api-version=1.1&authorization_endpoint=REDACTED",

I'm curious if you see a similar auth dance happening and what endpoints are being accessed before the error is thrown.

@xirzec xirzec added the needs-author-feedback Workflow: More information is needed from author to address the issue. label Nov 4, 2022
@dyuan-boxlabs
Copy link

@xirzec

Hi Jeff, here are the logs with AZURE_LOG_INFO set to info

[Nest] 22316 - 11/06/2022, 10:26:06 PM LOG [NestFactory] Starting Nest application...
azure:identity:info EnvironmentCredential => Found the following environment variables: AZURE_TENANT_ID, AZURE_CLIENT_ID, AZURE_CLIENT_SECRET
azure:identity:info EnvironmentCredential => Invoking ClientSecretCredential with tenant ID: ${TENANT_ID}, clientId: ${CLIENT_ID} and clientSecret: [REDACTED]
azure:core-client:warning The baseUri option for SDK Clients has been deprecated, please use endpoint instead.
[Nest] 22316 - 11/06/2022, 10:26:06 PM LOG [InstanceLoader] PrismaModule dependencies initialized +141ms
azure:core-client:warning The baseUri option for SDK Clients has been deprecated, please use endpoint instead.
azure:core-http:info ServiceClient: using custom request policies
azure:core-http:info ServiceClient: using custom request policies
azure:core-http:info ServiceClient: using custom request policies
azure:core-http:info ServiceClient: using custom request policies
azure:core-http:info ServiceClient: using custom request policies
azure:core-http:info ServiceClient: using custom request policies
azure:core-rest-pipeline retryPolicy:info Retry 0: Attempting to send request a5d1854e-64dd-4e63-9eb9-b1dd507e9ecc
azure:keyvault-keys:info Request: {
"url": "https://boxlabs-keyvault-dev.vault.azure.net/keys/boxlabs-supplier-creds-key/?api-version=7.3",
"headers": {
"accept": "application/json",
"accept-encoding": "gzip,deflate",
"user-agent": "azsdk-js-keyvault-keys/4.5.0 azsdk-js-keyvault-keys/4.5.0 core-rest-pipeline/1.9.2 Node/v16.13.0 OS/(x64-Windows_NT-10.0.19044)",
"x-ms-client-request-id": "a5d1854e-64dd-4e63-9eb9-b1dd507e9ecc"
},
"method": "GET",
"timeout": 0,
"disableKeepAlive": false,
"streamResponseStatusCodes": {},
"withCredentials": false,
"tracingOptions": {
"tracingContext": {
"_contextMap": {}
}
},
"requestId": "a5d1854e-64dd-4e63-9eb9-b1dd507e9ecc",
"allowInsecureConnection": false,
"enableBrowserStreams": false
}
azure:core-rest-pipeline:info No cached TLS Agent exist, creating a new Agent
[Nest] 22316 - 11/06/2022, 10:26:06 PM LOG [InstanceLoader] HttpModule dependencies initialized +41ms
[Nest] 22316 - 11/06/2022, 10:26:06 PM LOG [InstanceLoader] ConfigHostModule dependencies initialized +3ms
[Nest] 22316 - 11/06/2022, 10:26:06 PM LOG [InstanceLoader] DiscoveryModule dependencies initialized +0ms
[Nest] 22316 - 11/06/2022, 10:26:06 PM LOG [InstanceLoader] ConfigModule dependencies initialized +4ms
[Nest] 22316 - 11/06/2022, 10:26:06 PM LOG [InstanceLoader] EventEmitterModule dependencies initialized +1ms
[Nest] 22316 - 11/06/2022, 10:26:06 PM LOG [InstanceLoader] ScheduleModule dependencies initialized +1ms
[Nest] 22316 - 11/06/2022, 10:26:06 PM LOG [InstanceLoader] LoggersModule dependencies initialized +3ms
[Nest] 22316 - 11/06/2022, 10:26:06 PM LOG [InstanceLoader] RxModule dependencies initialized +1ms
[Nest] 22316 - 11/06/2022, 10:26:06 PM LOG [InstanceLoader] UserModule dependencies initialized +1ms
[Nest] 22316 - 11/06/2022, 10:26:06 PM LOG [InstanceLoader] DrugsModule dependencies initialized +2ms
[Nest] 22316 - 11/06/2022, 10:26:06 PM LOG [InstanceLoader] DocumentsModule dependencies initialized +1ms
[Nest] 22316 - 11/06/2022, 10:26:06 PM LOG [InstanceLoader] AppModule dependencies initialized +1ms
[Nest] 22316 - 11/06/2022, 10:26:06 PM LOG [InstanceLoader] PosModule dependencies initialized +1ms
[Nest] 22316 - 11/06/2022, 10:26:06 PM LOG [InstanceLoader] PatientModule dependencies initialized +2ms
[Nest] 22316 - 11/06/2022, 10:26:06 PM LOG [InstanceLoader] StoreModule dependencies initialized +1ms
[Nest] 22316 - 11/06/2022, 10:26:06 PM LOG [InstanceLoader] ScheduledTasksModule dependencies initialized +1ms
azure:keyvault-keys:info Response status code: 401
azure:keyvault-keys:info Headers: {
"cache-control": "no-cache",
"pragma": "no-cache",
"content-length": "97",
"content-type": "application/json; charset=utf-8",
"expires": "-1",
"www-authenticate": "Bearer authorization="https://login.windows.net/${TENANT_ID}\", resource="https://vault.azure.net\"",
"x-ms-keyvault-region": "canadacentral",
"x-ms-client-request-id": "a5d1854e-64dd-4e63-9eb9-b1dd507e9ecc",
"x-ms-request-id": "3bdbfc00-03c5-4e50-aad9-21d3c75bb6e0",
"x-ms-keyvault-service-version": "1.9.576.1",
"x-ms-keyvault-network-info": "conn_type=Ipv4;addr=209.141.172.214;act_addr_fam=InterNetwork;",
"x-content-type-options": "nosniff",
"strict-transport-security": "max-age=31536000;includeSubDomains",
"date": "Mon, 07 Nov 2022 03:26:07 GMT"
}
azure:core-rest-pipeline retryPolicy:info Retry 0: Received a response from request a5d1854e-64dd-4e63-9eb9-b1dd507e9ecc
azure:core-rest-pipeline retryPolicy:info Retry 0: Processing 2 retry strategies.
azure:core-rest-pipeline retryPolicy:info Retry 0: Processing retry strategy throttlingRetryStrategy.
azure:core-rest-pipeline retryPolicy:info Retry 0: Skipped.
azure:core-rest-pipeline retryPolicy:info Retry 0: Processing retry strategy exponentialRetryStrategy.
azure:core-rest-pipeline retryPolicy:info Retry 0: Skipped.
azure:core-rest-pipeline retryPolicy:info None of the retry strategies could work with the received response. Returning it.
azure:identity:info ClientSecretCredential => MSAL Node V2 info message: [Mon, 07 Nov 2022 03:26:07 GMT] : @azure/msal-node@1.13.0 : Info - getTokenCache called
azure:identity:info ClientSecretCredential => More than one account was found authenticated for this Client ID and Tenant ID.
However, no "authenticationRecord" has been provided for this credential,
therefore we're unable to pick between these accounts.
A new login attempt will be requested, to ensure the correct account is picked.
To work with multiple accounts for the same Client ID and Tenant ID, please provide an "authenticationRecord" when initializing a credential to prevent this from happening.
azure:identity:info ClientSecretCredential => Silent authentication failed, falling back to interactive method.
azure:identity:info ClientSecretCredential => MSAL Node V2 info message: [Mon, 07 Nov 2022 03:26:07 GMT] : [d4913c53-ae1e-4b3f-a70c-51adda097fbc] : @azure/msal-node@1.13.0 : Info - acquireTokenByClientCredential called
azure:core-rest-pipeline retryPolicy:info Retry 0: Attempting to send request c3cbd1ed-053d-4ca2-b4a0-371517ac9dba
azure:core-rest-pipeline:info Request: {
"url": "https://login.microsoftonline.com/common/discovery/instance?api-version=1.1&authorization_endpoint=REDACTED",
"headers": {
"accept-encoding": "gzip,deflate",
"user-agent": "azsdk-js-identity/3.0.0-beta.1 core-rest-pipeline/1.9.2 Node/v16.13.0 OS/(x64-Windows_NT-10.0.19044)",
"x-ms-client-request-id": "c3cbd1ed-053d-4ca2-b4a0-371517ac9dba"
},
"method": "GET",
"timeout": 0,
"disableKeepAlive": false,A
"withCredentials": false,
"abortSignal": {},
"requestId": "c3cbd1ed-053d-4ca2-b4a0-371517ac9dba",
"allowInsecureConnection": false,
"enableBrowserStreams": false
}
azure:core-rest-pipeline:info Response status code: 200
azure:core-rest-pipeline:info Headers: {
"cache-control": "max-age=86400, private",
"content-type": "application/json; charset=utf-8",
"strict-transport-security": "max-age=31536000; includeSubDomains",
"x-content-type-options": "nosniff",
"access-control-allow-origin": "*",
"access-control-allow-methods": "GET, OPTIONS",
"p3p": "CP="DSP CUR OTPi IND OTRi ONL FIN"",
"x-ms-request-id": "6d783e81-9d05-4533-8515-6502e2ee3900",
"x-ms-ests-server": "2.1.14006.10 - EUS ProdSlices",
"x-xss-protection": "0",
"set-cookie": "fpc=AoID9xHzEcVFsKU4fO9-KvI; expires=Wed, 07-Dec-2022 03:26:07 GMT; path=/; secure; HttpOnly; SameSite=None",
"date": "Mon, 07 Nov 2022 03:26:07 GMT",
"content-length": "980"
}
azure:core-rest-pipeline retryPolicy:info Retry 0: Received a response from request c3cbd1ed-053d-4ca2-b4a0-371517ac9dba
azure:core-rest-pipeline retryPolicy:info Retry 0: Processing 2 retry strategies.
azure:core-rest-pipeline retryPolicy:info Retry 0: Processing retry strategy throttlingRetryStrategy.
azure:core-rest-pipeline retryPolicy:info Retry 0: Skipped.
azure:core-rest-pipeline retryPolicy:info Retry 0: Processing retry strategy exponentialRetryStrategy.
azure:core-rest-pipeline retryPolicy:info Retry 0: Skipped.
azure:core-rest-pipeline retryPolicy:info None of the retry strategies could work with the received response. Returning it.
azure:identity:info ClientSecretCredential => ERROR. Scopes: https://vault.azure.net/.default. Error message: endpoints_resolution_error: Error: could not resolve endpoints. Please check network and try again. Detail: ClientConfigurationError: untrusted_authority: The provided authority is not a trusted authority. Please include this authority in the knownAuthorities config parameter..
azure:identity:info EnvironmentCredential => getToken() => ERROR. Scopes: https://vault.azure.net/.default. Error message: EnvironmentCredential authentication failed. To troubleshoot, visit https://aka.ms/azsdk/js/identity/environmentcredential/troubleshoot. Status code: 400
More details:
endpoints_resolution_error: Error: could not resolve endpoints. Please check network and try again. Detail: ClientConfigurationError: untrusted_authority: The provided authority is not a trusted authority. Please include this authority in the knownAuthorities config parameter..
[Nest] 22316 - 11/06/2022, 10:26:07 PM ERROR [ExceptionHandler] EnvironmentCredential authentication failed. To troubleshoot, visit https://aka.ms/azsdk/js/identity/environmentcredential/troubleshoot. Status code: 400
More details:
endpoints_resolution_error: Error: could not resolve endpoints. Please check network and try again. Detail: ClientConfigurationError: untrusted_authority: The provided authority is not a trusted authority. Please include this authority in the knownAuthorities config parameter.
AuthenticationError: EnvironmentCredential authentication failed. To troubleshoot, visit https://aka.ms/azsdk/js/identity/environmentcredential/troubleshoot. Status code: 400
More details:
endpoints_resolution_error: Error: could not resolve endpoints. Please check network and try again. Detail: ClientConfigurationError: untrusted_authority: The provided authority is not a trusted authority. Please include this authority in the knownAuthorities config parameter.
at C:\Users\yuyuan\Desktop\cube\box_nestjs_backend_v2\node_modules@azure\identity\src\credentials\environmentCredential.ts:143:39
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at Object.withSpan (C:\Users\yuyuan\Desktop\cube\box_nestjs_backend_v2\node_modules@azure\core-tracing\src\tracingClient.ts:70:22)
at tryGetAccessToken (C:\Users\yuyuan\Desktop\cube\box_nestjs_backend_v2\node_modules@azure\core-rest-pipeline\src\util\tokenCycler.ts:71:26)
at beginRefresh (C:\Users\yuyuan\Desktop\cube\box_nestjs_backend_v2\node_modules@azure\core-rest-pipeline\src\util\tokenCycler.ts:82:35)
at Object.authorizeRequestOnChallenge (C:\Users\yuyuan\Desktop\cube\box_nestjs_backend_v2\node_modules@azure\keyvault-common\src\challengeBasedAuthenticationPolicy.ts:120:25)
at Object.sendRequest (C:\Users\yuyuan\Desktop\cube\box_nestjs_backend_v2\node_modules@azure\core-rest-pipeline\src\policies\bearerTokenAuthenticationPolicy.ts:201:35)
at KeyVaultClient.sendOperationRequest (C:\Users\yuyuan\Desktop\cube\box_nestjs_backend_v2\node_modules@azure\core-client\src\serviceClient.ts:207:27)
at KeyVaultClient.sendOperationRequest (C:\Users\yuyuan\Desktop\cube\box_nestjs_backend_v2\node_modules@azure\core-http-compat\src\extendedClient.ts:93:23)
at C:\Users\yuyuan\Desktop\cube\box_nestjs_backend_v2\node_modules@azure\keyvault-keys\src\index.ts:634:24

@timovv timovv removed the needs-author-feedback Workflow: More information is needed from author to address the issue. label Nov 7, 2022
@timovv
Copy link
Member

timovv commented Nov 7, 2022

Hi @dyuan-boxlabs, thanks for providing the logs. Is there anything in your network configuration that could be getting in the way of authentication, e.g. a proxy?

@dyuan-boxlabs
Copy link

@timovv Hi Tim, no there is no proxy. I went through the Azure support desk and a support engineer confirmed that my set up was not using a proxy and sent these logs to the dev team.

@KarishmaGhiya
Copy link
Member

KarishmaGhiya commented Nov 7, 2022

@dyuan-boxlabs Can you try passing in the authorityHost in the options to the credentials and check if you receive the same error?

@xirzec
Copy link
Member

xirzec commented Nov 7, 2022

From the logs we can see this is blowing up inside of MSAL. Looking carefully at the error and noticing that it comes right after we hit the discovery endpoint, I believe it is being thrown from here:

https://github.com/AzureAD/microsoft-authentication-library-for-js/blob/288a777d8958e3ba40e6d3fd2acdf8aad5906a3e/lib/msal-common/src/authority/AuthorityFactory.ts#L46

The inner error I believe is coming from here:

https://github.com/AzureAD/microsoft-authentication-library-for-js/blob/288a777d8958e3ba40e6d3fd2acdf8aad5906a3e/lib/msal-common/src/authority/Authority.ts#L466

Which seems to indicate that it's not getting back the cloud discovery metadata from the network, which means that this method is returning null for some reason:

https://github.com/AzureAD/microsoft-authentication-library-for-js/blob/288a777d8958e3ba40e6d3fd2acdf8aad5906a3e/lib/msal-common/src/authority/Authority.ts#L502

We see the request going out and it is getting back a 200, so at this point I'm not sure why it would be failing without getting our hands on the actual body of that response and seeing what it contains.

@bgavrilMS
Copy link

The root cause seems to be:

azure:identity:info ClientSecretCredential => ERROR. Scopes: https://vault.azure.net/.default. Error message: endpoints_resolution_error: Error: could not resolve endpoints. Please check network and try again. Detail: ClientConfigurationError: untrusted_authority: The provided authority is not a trusted authority. Please include this authority in the knownAuthorities config parameter..

Let me try to describe what endpoint resolution means. There are 2 concepts to be aware of:

  • authority validation, i.e. MSAL tries to protect the user against using a "hacked" authority. So
  • authority aliases, i.e. "login.microsoft.com", "login.microsoftonline.com", "login.windows.net" and "sts.windows.net" all mean the same thing. But without knowing that these are just different names for the same public authority, MSAL would consider them different authorities, which would lead to cache misses. Not really a big deal for this flow, but when logging in users interactively it would lead to repeated prompts.

Anyway, seems like a bug occurs when the list of alisases (as mentioned by @dyuan-boxlabs above) is retrieved.

@bgavrilMS
Copy link

I don't think we have enough info at this point to fully understand what is happning. I would think that this error is thrown wrongly and it simply masks the underlying cause.

Would it be possible to get verbose logs @dyuan-boxlabs ? If you are concerned about PII here on GitHub, please send the logs directly to me - bogavril at microsoft com

@dyuan-boxlabs
Copy link

@bgavrilMS sent you an email with the logs

@Robbie-Microsoft
Copy link

Robbie-Microsoft commented Nov 11, 2022

@dyuan-boxlabs We're taking a look at this, but in the meantime, can you change your DefaultAzureCredential config to look like the following?

const keyVaultCredentials = new DefaultAzureCredential({
    authorityHost: "https://login.microsoftonline.com/REPLACE_WITH_YOUR_TENENT_ID",
});

Re-run your app with this and let me know if you see the same error or a different one. I was looking at this example here for how to add "knownAuthorities" to the config (scroll down to "The following example demonstrates authenticating a SecretClient from the @azure/keyvault-secrets against an Azure Key Vault hosted in Azure Stack.").

@dyuan-boxlabs
Copy link

@Robbie-Microsoft Hi Robbie, tried adding the authorityHost - didn't work. If you give me your microsoft email I can send you the verbose logs.

@Robbie-Microsoft
Copy link

@dyuan-boxlabs Please send it to @bgavrilMS, he will forward it to me.

@dyuan-boxlabs
Copy link

@Robbie-Microsoft sent the logs to @bgavrilMS

@deyaaeldeen
Copy link
Member

What does the following mean exactly?

More than one account was found authenticated for this Client ID and Tenant ID.
However, no "authenticationRecord" has been provided for this credential,
therefore we're unable to pick between these accounts

@bgavrilMS
Copy link

Seems unrelated @deyaaeldeen ? Pls open a new issue.

@deyaaeldeen
Copy link
Member

@bgavrilMS I see it in the log in #23331 (comment).

@xirzec xirzec assigned bgavrilMS and Robbie-Microsoft and unassigned timovv Mar 30, 2023
@xirzec xirzec added bug This issue requires a change to an existing behavior in the product in order to be resolved. Service Attention Workflow: This issue is responsible by Azure service team. and removed question The issue doesn't require a change to the product in order to be resolved. Most issues start as that KeyVault labels Mar 30, 2023
@ghost ghost added the needs-team-attention Workflow: This issue needs attention from Azure service team or SDK team label Mar 30, 2023
@bgavrilMS bgavrilMS removed their assignment Mar 30, 2023
@bgavrilMS
Copy link

@KarishmaGhiya - MSAL JS fixed the underlying issue, it was in the HTTP stack. Next step would be for Azure Identity to bump the version of MSAL I think. Not sure if this will fix it because Azure Identity uses its own HTTP stack. But @Robbie-Microsoft can provide some context on how we fixed it on our side if needed.

@scottaddie
Copy link
Member

@KarishmaGhiya Can you please confirm if this issue has been addressed?

@KarishmaGhiya
Copy link
Member

Looks like I need to bump the version of msal to 1.16.0 and do a bug fix release of @azure/identity. Will update the status here when released., this week

@scottaddie
Copy link
Member

Fixed in #26257

@KarishmaGhiya
Copy link
Member

@yzhengamat Please use @azure/identity version 3.2.3 to get the bug fix. https://www.npmjs.com/package/@azure/identity/v/3.2.3

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Azure.Identity bug This issue requires a change to an existing behavior in the product in order to be resolved. Client This issue points to a problem in the data-plane of the library. customer-reported Issues that are reported by GitHub users external to the Azure organization. needs-team-attention Workflow: This issue needs attention from Azure service team or SDK team Service Attention Workflow: This issue is responsible by Azure service team.
Projects
None yet
Development

No branches or pull requests

10 participants