Skip to content

Commit

Permalink
Pass through correct scope per Azure environment (#594)
Browse files Browse the repository at this point in the history
  • Loading branch information
timja authored Jul 12, 2024
1 parent 1aadf23 commit 7e7931d
Showing 1 changed file with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import hudson.util.Secret;
import io.jenkins.plugins.azuresdk.HttpClientRetriever;
import java.net.URI;
import java.util.Collections;
import jenkins.model.Jenkins;
import jenkins.util.JenkinsJVM;
import okhttp3.Credentials;
Expand All @@ -24,6 +25,7 @@
import static com.microsoft.jenkins.azuread.AzureEnvironment.getAuthorityHost;
import static com.microsoft.jenkins.azuread.AzureEnvironment.getGraphResource;
import static com.microsoft.jenkins.azuread.AzureEnvironment.getServiceRoot;
import static java.util.Collections.singletonList;

public class GraphClientCache {

Expand All @@ -35,7 +37,12 @@ public class GraphClientCache {
private static GraphServiceClient<Request> createGraphClient(GraphClientCacheKey key) {
final ClientSecretCredential clientSecretCredential = getClientSecretCredential(key);

final TokenCredentialAuthProvider authProvider = new TokenCredentialAuthProvider(clientSecretCredential);
String graphResource = AzureEnvironment.getGraphResource(key.getAzureEnvironmentName());

final TokenCredentialAuthProvider authProvider = new TokenCredentialAuthProvider(
singletonList(graphResource + ".default"),

Check warning on line 43 in src/main/java/com/microsoft/jenkins/azuread/GraphClientCache.java

View check run for this annotation

ci.jenkins.io / Code Coverage

Not covered lines

Lines 40-43 are not covered by tests
clientSecretCredential
);

OkHttpClient.Builder builder = HttpClients.createDefault(authProvider)
.newBuilder();
Expand Down

0 comments on commit 7e7931d

Please sign in to comment.