microsoft-authentication-library-for-js: setClientCredential() errors when no `clientCertificate` property is set

Core Library

MSAL Node (@azure/msal-node)

Core Library Version

2.11.0

Wrapper Library

Not Applicable

Wrapper Library Version

None

Public or Confidential Client?

Confidential

Description

This commit stops checking if config.auth.clientCertificate is actually defined. CC: @Robbie-Microsoft

Error Message

TypeError: Cannot read properties of undefined (reading ‘thumbprint’)

MSAL Logs

No response

Network Trace (Preferrably Fiddler)

  • Sent
  • Pending

MSAL Configuration

auth: {
    authority: 'url',
    clientId: 'guid',
    clientSecret: 'secret',
}

Relevant Code Snippets

N/A

Reproduction Steps

Try authenticating without setting the clientCertificate property in the auth

Expected Behavior

Auth using clientSecret

Identity Provider

Entra ID (formerly Azure AD) / MSA

Browsers Affected (Select all that apply)

None (Server)

Regression

2.10.0

Source

External (Customer)

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Reactions: 2
  • Comments: 16

Most upvoted comments

So this method should transform Configuration to NodeConfiguration, but it’s not guaranteed: https://github.com/AzureAD/microsoft-authentication-library-for-js/blob/22651b30bce9244cce2d7ffcfa1a81e4c44be133/lib/msal-node/src/config/Configuration.ts#L210-L243

In my case this line:

auth: { ...DEFAULT_AUTH_OPTIONS, ...auth },

Actually does this:

auth: { ...{clientCertificate: {/* default config */}}, ...{clientCertificate: undefined} },

Which results in:

auth: { clientCertificate: undefined },

A fix for this could be:

auth: { ...DEFAULT_AUTH_OPTIONS, ...auth, clientCertificate: { ...DEFAULT_AUTH_OPTIONS.clientCertificate, ...auth.clientCertificate } },

But to be sure, you would also have to do this for DEFAULT_AUTH_OPTIONS.azureCloudOptions and the same for DEFAULT_TELEMETRY_OPTIONS.application