Repository navigation
Add Azure DevOps workload identity support - #3272
ryanjbaxter merged 6 commits into
Conversation
There was a problem hiding this comment.
Pull request overview
Adds Azure DevOps (dev.azure.com) workload identity authentication to Spring Cloud Config Server’s JGit transport customization path, driven by new git properties (client-id, managed-identity-enabled) and an optional Azure Identity dependency.
Changes:
- Introduces
AzureDevOpsWorkloadIdentitySupportto acquire managed identity tokens and injectAuthorization: Bearer …into JGit HTTP transport for Azure DevOps repos. - Extends transport callback selection to prefer Azure DevOps workload identity when enabled (while preserving existing custom callback / GCP / SSH fallback behavior).
- Adds configuration + unit tests and wires an optional
azure-identitydependency.
Reviewed changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| spring-cloud-config-server/src/main/java/org/springframework/cloud/config/server/support/TransportConfigCallbackFactory.java | Adds Azure DevOps workload identity callback selection ahead of SSH fallback. |
| spring-cloud-config-server/src/main/java/org/springframework/cloud/config/server/support/AzureDevOpsWorkloadIdentitySupport.java | New helper to detect dev.azure.com HTTP(S) repos and inject bearer tokens into JGit HTTP transport. |
| spring-cloud-config-server/src/main/java/org/springframework/cloud/config/server/environment/JGitEnvironmentProperties.java | Adds clientId and managedIdentityEnabled configuration properties. |
| spring-cloud-config-server/src/main/java/org/springframework/cloud/config/server/config/EnvironmentRepositoryConfiguration.java | Wires optional Azure DevOps support into the JGit factory configuration and imports Azure configuration. |
| spring-cloud-config-server/src/main/java/org/springframework/cloud/config/server/config/AzureDevOpsWorkloadIdentityConfiguration.java | Conditional configuration that exposes AzureDevOpsWorkloadIdentitySupport when Azure Identity + JGit are present. |
| spring-cloud-config-server/src/test/java/org/springframework/cloud/config/server/support/TransportConfigCallbackFactoryTests.java | New tests for callback selection behavior (Azure vs disabled vs other repo). |
| spring-cloud-config-server/src/test/java/org/springframework/cloud/config/server/support/AzureDevOpsWorkloadIdentitySupportTests.java | New tests for URI handling and header injection behavior. |
| spring-cloud-config-server/src/test/java/org/springframework/cloud/config/server/config/EnvironmentRepositoryConfigurationTests.java | Adds a context test asserting the Azure support bean is present. |
| spring-cloud-config-server/pom.xml | Adds optional com.azure:azure-identity dependency. |
| pom.xml | Adds ${azure-identity.version} property. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| when(properties.getUri()).thenReturn(AZURE_DEVOPS_REPO); | ||
| when(properties.isManagedIdentityEnabled()).thenReturn(false); | ||
| when(azureSupport.canHandle(AZURE_DEVOPS_REPO)).thenReturn(true); | ||
|
|
| TransportConfigCallback createTransportConfigCallback(TokenCredential credential) { | ||
| return transport -> { | ||
| if (transport instanceof TransportHttp && canHandle(transport.getURI().toString())) { | ||
| AccessToken accessToken = credential.getToken(new TokenRequestContext().addScopes(AZURE_DEVOPS_SCOPE)) | ||
| .block(); |
|
Hi @ryanjbaxter / @spencergibb, Just following up on this PR. All review items have been addressed (including ensuring optional dependency safety without Azure SDK class-loading issues when disabled), and the full test suite passes locally (952 tests, 0 failures). Whenever you have a moment, could you please approve the workflow run so CI checks can execute against |
f9a9972 to
25a9940
Compare
Signed-off-by: abhiramaab <abhiram.b@icloud.com> Signed-off-by: Abhirama <abhiram.b@icloud.com>
…pport - Remove TokenCredential from package-private API in AzureDevOpsWorkloadIdentitySupport using Supplier<String> to prevent NoClassDefFoundError when optional azure-identity dependency is missing. - Make clientId optional in createTransportConfigCallback to use system-assigned managed identity when clientId is null/blank. - Update test cases in AzureDevOpsWorkloadIdentitySupportTests and TransportConfigCallbackFactoryTests to properly stub properties and verify method interactions. Signed-off-by: abhiramaab <abhiram.b@icloud.com> Signed-off-by: Abhirama <abhiram.b@icloud.com>
… interface Addresses ryanjbaxter's review: instead of accumulating cloud-provider specific fields in TransportConfigCallbackFactory, introduce a GitTransportConfigCallbackProvider strategy interface. - Add GitTransportConfigCallbackProvider interface with canHandle() and createTransportConfigCallback() methods - GoogleCloudSourceSupport implements GitTransportConfigCallbackProvider - AzureDevOpsWorkloadIdentitySupport implements GitTransportConfigCallbackProvider (canHandle checks both host and managedIdentityEnabled flag) - TransportConfigCallbackFactory takes List<GitTransportConfigCallbackProvider> and iterates; new providers can be added as beans without touching the factory - Wire providers via ObjectProvider in EnvironmentRepositoryConfiguration - Update TransportConfigCallbackFactoryTests to use new constructor Signed-off-by: Abhirama <abhiram.b@icloud.com>
…ort callback refactoring - Move Azure properties into nested namespace 'spring.cloud.config.server.git.azure.*' (clientId and managedIdentityEnabled) - Gracefully handle null or empty URIs in canHandle to avoid NullPointerException - Refactor GoogleCloudSourceSupport to implement GitTransportConfigCallbackProvider, eliminating custom constructor parameter in TransportConfigCallbackFactory - Update unit tests and test imports accordingly Signed-off-by: Abhirama <abhiram.b@icloud.com>
25a9940 to
44af7f3
Compare
…eCloudSourceSupportTests - Move clientId and managedIdentityEnabled under AzureProperties.Identity subclass - Update AzureDevOpsWorkloadIdentitySupport and test cases for azure.identity property access - Restore dropped verifyDoesNothingForNonHttpTransports test in GoogleCloudSourceSupportTests Signed-off-by: Abhirama <abhiram.b@icloud.com>
ryanjbaxter
left a comment
There was a problem hiding this comment.
The code is looking good!
The last thing we need are some docs on this new functionality.
Add documentation for Azure DevOps Git authentication using Azure managed identity in git-backend.adoc, covering top-level and per-repository configuration. Signed-off-by: Abhirama <abhiram.b@icloud.com>
|
Hi @ryanjbaxter, I have added the documentation for Azure DevOps Workload Identity authentication to git-backend.adoc (covering both top-level and per-repository configurations, as well as the optional dependency note) and pushed the commit. Thanks! |
Closes #3270
This adds workload identity authentication for Git repositories hosted on Azure DevOps (dev.azure.com), using the proposed client-id and managed-identity-enabled configuration properties.
Implementation includes:
Validation: