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

clientSecret can now (once again) be provided as undefined #7209

Merged
merged 8 commits into from
Aug 8, 2024

Conversation

Robbie-Microsoft
Copy link
Collaborator

Fixed a regression accidentally introduced in Implemented SHA2 Certificate Functionality. clientSecret can now (once again) be provided as undefined.

added unit test

@github-actions github-actions bot added the msal-node Related to msal-node package label Jul 18, 2024
@yuezk
Copy link

yuezk commented Jul 19, 2024

Hi,

I'm from #7201 and am curious about the root cause since the code has been strongly typed.

Looks like this is a runtime error and the root cause is as @RoelVB said in #7201 (comment).

Though this PR can fix #7201, I'm afraid we may run into similar issues if it is not fixed from the root.

Related:

Copy link

@maorleger maorleger left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We chatted offline a bit. Here's what I think:

  • Agree that there's a larger issue here with the spread operator. There is always a disconnect between your defined types and what you actually get at runtime especially when it comes to your external API
  • IMO, fixing this correctly requires some additional thought. While I agree that you could fix the cert key specifically by spreading it out ala clientCertificate: { ...DEFAULT_AUTH_OPTIONS.clientCertificate, ...auth.clientCertificate } }, that still requires discipline whenever objects are added to the config and is an easy trap to fall into. Consider creating a separate issue to track the larger fix and linking to it in your PR
  • You may also play around with exactOptionalPropertyTypes which may not help your users but it will help you catch errors internally where possible like this playground - again, it's not perfect especially with spread
  • I would also check if config.auth.clientCertificate is used anywhere else in the code just to confirm

LGTM for the immediate future, and a separate issue can be created to address the troubles with the spread operator here. That's at least what I would do!

@Robbie-Microsoft
Copy link
Collaborator Author

Thanks @maorleger!

@RoelVB I agree with your analysis about what the root cause is. However, this behavior (root cause) already existed before the regression this PR addresses was introduced.

@yuezk I'm going to keep this PR as is, and create a new GitHub issue for "larger refactoring to remove the ambiguity for deeply nested properties".

@yuezk
Copy link

yuezk commented Jul 26, 2024

Thanks for explaining this. I agree with your decision.

@Robbie-Microsoft
Copy link
Collaborator Author

@Robbie-Microsoft Robbie-Microsoft merged commit 4592e9f into dev Aug 8, 2024
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
msal-node Related to msal-node package
Projects
None yet
Development

Successfully merging this pull request may close these issues.

setClientCredential() errors when no clientCertificate property is set
5 participants