Skip to content

Add Azure DevOps workload identity support - #3272

Merged
ryanjbaxter merged 6 commits into
spring-cloud:mainfrom
abhiramaab:fix/azure-devops-workload-identity
Sep 17, 2026
Merged

ryanjbaxter merged 6 commits into
spring-cloud:mainfrom
abhiramaab:fix/azure-devops-workload-identity

Conversation

@abhiramaab

Copy link
Copy Markdown
Contributor

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:

  • Azure Identity dependency and conditional configuration
  • Azure managed identity token acquisition for Azure DevOps
  • Bearer token injection into JGit HTTP transport
  • Git property binding for client-id and managed-identity-enabled
  • Transport callback selection with existing SSH fallback behavior
  • Unit and configuration tests

Validation:

  • Full spring-cloud-config-server test suite: 952 tests, 0 failures, 0 errors, 9 skipped

Copilot AI lite review requested due to automatic review settings August 13, 2026 17:06

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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 AzureDevOpsWorkloadIdentitySupport to acquire managed identity tokens and inject Authorization: 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-identity dependency.

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.

Comment on lines +64 to +67
when(properties.getUri()).thenReturn(AZURE_DEVOPS_REPO);
when(properties.isManagedIdentityEnabled()).thenReturn(false);
when(azureSupport.canHandle(AZURE_DEVOPS_REPO)).thenReturn(true);

Comment on lines +51 to +55
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();
@abhiramaab

Copy link
Copy Markdown
Contributor Author

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 main? Happy to adjust anything to align with upcoming milestone requirements. Thank you!

@abhiramaab
abhiramaab force-pushed the fix/azure-devops-workload-identity branch 2 times, most recently from f9a9972 to 25a9940 Compare September 16, 2026 04:28
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>
@abhiramaab
abhiramaab force-pushed the fix/azure-devops-workload-identity branch from 25a9940 to 44af7f3 Compare September 16, 2026 16:06
…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 ryanjbaxter left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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>
@abhiramaab

Copy link
Copy Markdown
Contributor Author

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!

@ryanjbaxter
ryanjbaxter merged commit 82efc71 into spring-cloud:main Sep 17, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

workload identity authentication for azure devops git

4 participants