Skip to content

Remove usage of com.nimbusds.oauth2's HTTP classes #927

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

Merged
merged 6 commits into from
Apr 4, 2025

Conversation

Avery-Dunn
Copy link
Collaborator

@Avery-Dunn Avery-Dunn commented Apr 1, 2025

This PR removes usage of several com.nimbusds.oauth2 classes, as per #909

Mainly HTTPRequest, HTTPResponse, and ClientAuthentication were removed, along with some related minor utils. These were essentially just used as a helper for making HTTP requests: managing query parameters, creating assertions for different credentials, etc.

To replace them, this PR does the following:

  • Refactors code in ConfidentialClientApplication related to credentials and assertions, it now mainly deals with assertion/secret Strings, some logic was moved to other classes, and some methods that now had duplicate or unused code
  • Adjusts OAuthHttpRequest and HttpResponse to remove Nimbus classes and add the very minor features we were using from those classes
  • Refactors code in TokenRequestExecutor related to credentials and assertions, simplifying and clarifying the behavior around query parameters and assertions/secrets that are needed in each scenario

@Avery-Dunn Avery-Dunn requested a review from a team as a code owner April 1, 2025 17:13
@Avery-Dunn Avery-Dunn changed the title Remove HTTPRequest, ClientAuthentication, and related classes Remove usage of com.nimbusds.oauth2's HTTP classes Apr 1, 2025
@@ -29,7 +27,6 @@ public abstract class AbstractClientApplicationBase extends AbstractApplicationB
private String applicationName;
private String applicationVersion;
private AadInstanceDiscoveryResponse aadAadInstanceDiscoveryResponse;
protected abstract ClientAuthentication clientAuthentication();
Copy link

Choose a reason for hiding this comment

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

We don't need a replacement for this?

Copy link
Collaborator Author

@Avery-Dunn Avery-Dunn Apr 4, 2025

Choose a reason for hiding this comment

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

Long story short, this was mainly used as a parameter or return type of various nimbus methods. It's utility behavior was fully delegated to other classes:

  • It represented a client assertion/secret/cert, which some existing MSAL classes did as well
  • It was used to add query parameters to an HTTP request, but TokenRequestExecutor.addJWTBearerAssertionParams() now handles that
  • It was passed into some nimbus APIs that are no longer used


final String location = HttpUtils.headerValue(httpResponse.headers(), "Location");
if (!StringHelper.isBlank(location)) {
try {
response.setLocation(new URI(location));
response.addHeader("Location", new URI(location).toString());
Copy link

Choose a reason for hiding this comment

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

Maybe worth it to have an enum/constants for well known headers.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I was planning to do this in a follow up PR that removes various nimbus utility methods, since we'll then have the full picture of what constants and enums would be useful

Avery-Dunn and others added 2 commits April 4, 2025 10:46
Remove usage of com.nimbusds.oauth2's Token classes
@Avery-Dunn Avery-Dunn merged commit 70d4312 into avdunn/nimbus-removal Apr 4, 2025
1 of 2 checks passed
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.

3 participants