Skip to content

Commit

Permalink
clientSecret can now (once again) be provided as undefined (#7209)
Browse files Browse the repository at this point in the history
Fixed a regression accidentally introduced in [Implemented SHA2
Certificate
Functionality](#7192).
`clientSecret` can now (once again) be provided as `undefined`.

added unit test
  • Loading branch information
Robbie-Microsoft authored Aug 8, 2024
1 parent 9b44cb4 commit 4592e9f
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "patch",
"comment": "clientSecret can now (once again) be provided as undefined #7209",
"packageName": "@azure/msal-node",
"email": "[email protected]",
"dependentChangeType": "patch"
}
6 changes: 3 additions & 3 deletions lib/msal-node/src/client/ConfidentialClientApplication.ts
Original file line number Diff line number Diff line change
Expand Up @@ -221,9 +221,9 @@ export class ConfidentialClientApplication
const clientSecretNotEmpty = !!this.config.auth.clientSecret;
const clientAssertionNotEmpty = !!this.config.auth.clientAssertion;
const certificateNotEmpty =
(!!this.config.auth.clientCertificate.thumbprint ||
!!this.config.auth.clientCertificate.thumbprintSha256) &&
!!this.config.auth.clientCertificate.privateKey;
(!!this.config.auth.clientCertificate?.thumbprint ||
!!this.config.auth.clientCertificate?.thumbprintSha256) &&
!!this.config.auth.clientCertificate?.privateKey;

/*
* If app developer configures this callback, they don't need a credential
Expand Down
19 changes: 19 additions & 0 deletions lib/msal-node/test/client/ConfidentialClientApplication.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,25 @@ describe("ConfidentialClientApplication", () => {
expect(client).toBeInstanceOf(ConfidentialClientApplication);
});

test("optional NodeAuthOptions values that are passed in as undefined will not break the application", () => {
let client: ConfidentialClientApplication;

// clientCertificate is already set, by default
config.auth.clientSecret = undefined;
client = new ConfidentialClientApplication(config);
expect(client).toBeInstanceOf(ConfidentialClientApplication);

config.auth.clientSecret = "secret";
config.auth.clientCertificate = undefined;
client = new ConfidentialClientApplication(config);
expect(client).toBeInstanceOf(ConfidentialClientApplication);

// clientSecret defined above
config.auth.clientAssertion = undefined;
client = new ConfidentialClientApplication(config);
expect(client).toBeInstanceOf(ConfidentialClientApplication);
});

describe("auth code flow", () => {
test("acquireTokenByAuthorizationCode", async () => {
const acquireTokenByCodeSpy: jest.SpyInstance = jest.spyOn(
Expand Down

0 comments on commit 4592e9f

Please sign in to comment.