-
Notifications
You must be signed in to change notification settings - Fork 2k
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
[After MSAL 1.3] Pluggable HTTP in identity/msal #7120
Merged
Merged
Changes from all commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
772e2ed
Add HttpPipeline adapter for MSAL IHttpClient
jianghaolu 3d98d5b
Merge branch 'master' of github.com:Azure/azure-sdk-for-java into msa…
jianghaolu 63c16f7
Build backward compatible identity client options
jianghaolu 9c01dba
Fix code styles
jianghaolu 1cd4675
Clean up pom
jianghaolu 06c5f56
Fix netty module version
jianghaolu 0bc580f
Use default when HttpPipeline is not specified
jianghaolu c372959
Update msal4j in eventhubs
jianghaolu 27c34c0
Checkstyle
jianghaolu f9ecc2e
Checkstyle
jianghaolu cace69f
Add azure-core-http-netty to identity pom.service.xml
jianghaolu ed2ac04
Add azure-core-test to identity pom.service.xml
jianghaolu c1c4478
Update MSAL to 1.3.0
jianghaolu 8c23aa6
Merge branch 'master' of github.com:Azure/azure-sdk-for-java into msa…
jianghaolu f91989e
Some cr feedback
jianghaolu 3a95090
Add GSON test dependency to identity
jianghaolu 1617b80
Add back test verification of client certificate
jianghaolu File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
61 changes: 61 additions & 0 deletions
61
...y/azure-identity/src/main/java/com/azure/identity/implementation/HttpPipelineAdapter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT License. | ||
|
||
package com.azure.identity.implementation; | ||
|
||
import com.azure.core.http.HttpHeader; | ||
import com.azure.core.http.HttpHeaders; | ||
import com.azure.core.http.HttpMethod; | ||
import com.azure.core.http.HttpPipeline; | ||
import com.microsoft.aad.msal4j.HttpRequest; | ||
import com.microsoft.aad.msal4j.IHttpClient; | ||
import com.microsoft.aad.msal4j.IHttpResponse; | ||
import reactor.core.publisher.Mono; | ||
|
||
import java.util.Collections; | ||
import java.util.stream.Collectors; | ||
|
||
/** | ||
* Adapts an HttpPipeline to an instance of IHttpClient in the MSAL4j pipeline. | ||
*/ | ||
class HttpPipelineAdapter implements IHttpClient { | ||
private final HttpPipeline httpPipeline; | ||
|
||
HttpPipelineAdapter(HttpPipeline httpPipeline) { | ||
this.httpPipeline = httpPipeline; | ||
} | ||
|
||
@Override | ||
public IHttpResponse send(HttpRequest httpRequest) throws Exception { | ||
// convert request | ||
com.azure.core.http.HttpRequest request = new com.azure.core.http.HttpRequest( | ||
HttpMethod.valueOf(httpRequest.httpMethod().name()), | ||
httpRequest.url()); | ||
if (httpRequest.headers() != null) { | ||
request.setHeaders(new HttpHeaders(httpRequest.headers())); | ||
} | ||
if (httpRequest.body() != null) { | ||
request.setBody(httpRequest.body()); | ||
} | ||
|
||
return httpPipeline.send(request) | ||
.flatMap(response -> response.getBodyAsString() | ||
.map(body -> { | ||
com.microsoft.aad.msal4j.HttpResponse httpResponse = new com.microsoft.aad.msal4j.HttpResponse() | ||
.body(body) | ||
.statusCode(response.getStatusCode()); | ||
httpResponse.headers(response.getHeaders().stream().collect(Collectors.toMap(HttpHeader::getName, | ||
h -> Collections.singletonList(h.getValue())))); | ||
return httpResponse; | ||
}) | ||
// if no body | ||
.switchIfEmpty(Mono.defer(() -> { | ||
com.microsoft.aad.msal4j.HttpResponse httpResponse = new com.microsoft.aad.msal4j.HttpResponse() | ||
.statusCode(response.getStatusCode()); | ||
httpResponse.headers(response.getHeaders().stream().collect(Collectors.toMap(HttpHeader::getName, | ||
h -> Collections.singletonList(h.getValue())))); | ||
return Mono.just(httpResponse); | ||
}))) | ||
.block(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is track 1 event hubs module. Did you intend to update msal version of track 1 module too? This might need service team's validation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems to be only used in tests. And I don't know a way to specify a dependency of 2 different versions across our SDKs.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this because you are using the script to update the external dependency version and it's updating both track 1 and track 2 dependencies?