Skip to content

Conversation

Avery-Dunn
Copy link
Contributor

@Avery-Dunn Avery-Dunn commented Sep 2, 2025

Refactors behavior related to client credentials and also fixes the regression described in #984

Version 1.23.0 introduced a large refactor to remove usage of third-party dependencies, in particular those from com.nimbusds. Prior to 1.23.0 assertions created for ClientCertificate were given 10 minute expiry time and were only recreated if the old one expired, however the refresh behavior was lost during a refactor in PR #927

In addition, this PR fixes/improves assertion behavior to resolve the issues described in #879 and #977: when using the callback option for assertions the original design only called the callback when the ClientAssertion instance was first created, meaning an app-level assertion was only created once

This PR fixes that regression and refactors the behavior around client credentials to be more in line with other MSALs:

  • Remove locally cached credential fields from ConfidentialClientApplication, and move logic for creating assertion from ConfidentialClientApplication to ClientCertificate
  • Adjusts ClientAssertion and ClientCredentialFactory to properly call callbacks set at the app-level
  • Refactor certain methods in TokenRequestExecutor to use credential fields/methods directly, properly creates assertions when tenants are set at the request-level, and generally improve some complicated logic
  • Adjusts ClientAssertion and ClientCredentialFactory to properly call the app-level callback whenever the assertion is needed
  • Update and expand tests in ClientCertificateTest and ClientCredentialTest to cover the new behavior

Copy link
Member

@bgavrilMS bgavrilMS left a comment

Choose a reason for hiding this comment

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

assertion should be at request level?

@Avery-Dunn Avery-Dunn changed the title Re-add behavior for refreshing assertions Refactor client credential behavior to be per-request Sep 4, 2025
Avery-Dunn and others added 4 commits September 9, 2025 14:20
…ntials

# Conflicts:
#	msal4j-sdk/src/test/java/com/microsoft/aad/msal4j/ClientCredentialTest.java
Improve behavior related to assertions
@Avery-Dunn Avery-Dunn dismissed bgavrilMS’s stale review September 12, 2025 16:42

Requested changes were implemented.

@Avery-Dunn Avery-Dunn merged commit 9c03bc3 into dev Sep 12, 2025
5 checks passed
@Avery-Dunn Avery-Dunn mentioned this pull request Sep 12, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants