Repository navigation
[release/11.0] Backport refreshable Helix Entra authentication - #17561
missymessa merged 5 commits into
Conversation
Copilot-Session: e890b71a-c1aa-416c-a15c-be8da9fdd9b4 Copilot-Session: 0e1a942f-a44f-4e3a-8d35-af3fe8bee535 Co-authored-by: Copilot <[email protected]>
Copilot-Session: a6ad3a92-2023-4c67-8948-f6d34de1a67c Copilot-Session: 521e657d-a005-4f60-bcff-25a05ebcc390 Co-authored-by: Copilot <[email protected]>
Co-authored-by: Copilot <[email protected]> Copilot-Session: 4aa6b2e8-2313-40c0-92f6-1d578db0af15 Copilot-Session: a891597e-6dca-4706-8628-004c5837d0c9
There was a problem hiding this comment.
🟡 Changes recommended
The existing public constructor changes behavior for custom TokenCredential consumers and requires compatibility handling.
Get a fresh assessment by requesting another Copilot review.
Pull request overview
Backports refreshable Helix Entra authentication to the release/11.0 branch.
Changes:
- Adds Entra token scopes, refresh, and authentication modes.
- Propagates authentication through SDK tasks, Job Monitor, and pipelines.
- Adds tests, source-build guards, and documentation.
File summaries
| File | Description |
|---|---|
src/Microsoft.DotNet.Helix/Sdk/tools/Microsoft.DotNet.Helix.Sdk.props |
Defines authentication properties. |
src/Microsoft.DotNet.Helix/Sdk/tools/Microsoft.DotNet.Helix.Sdk.MultiQueue.targets |
Propagates authentication to multi-queue tasks. |
src/Microsoft.DotNet.Helix/Sdk/tools/Microsoft.DotNet.Helix.Sdk.MonoQueue.targets |
Propagates authentication to job submission. |
src/Microsoft.DotNet.Helix/Sdk/tools/download-results/DownloadFromResultsContainer.targets |
Propagates authentication to result downloads. |
src/Microsoft.DotNet.Helix/Sdk/SendHelixJob.cs |
Validates authenticated job submission. |
src/Microsoft.DotNet.Helix/Sdk/Readme.md |
Documents Entra configuration. |
src/Microsoft.DotNet.Helix/Sdk/Microsoft.DotNet.Helix.Sdk.csproj |
Adds integration dependencies and source-build guards. |
src/Microsoft.DotNet.Helix/Sdk/HelixTask.cs |
Creates PAT, anonymous, or Entra clients. |
src/Microsoft.DotNet.Helix/Sdk/GetHelixWorkItems.cs |
Handles authentication for work-item retrieval. |
src/Microsoft.DotNet.Helix/Sdk/CancelHelixJob.cs |
Supports authenticated cancellation. |
src/Microsoft.DotNet.Helix/Sdk.Tests/Microsoft.DotNet.Helix.Sdk.Tests/QueueStatsLoggingTests.cs |
Tests creator validation. |
src/Microsoft.DotNet.Helix/Sdk.Tests/Microsoft.DotNet.Helix.Sdk.Tests/Microsoft.DotNet.Helix.Sdk.Tests.csproj |
Updates test project references. |
src/Microsoft.DotNet.Helix/Sdk.Tests/Microsoft.DotNet.Helix.Sdk.Tests/HelixApiAuthenticationTests.cs |
Tests scopes, refresh, and authentication selection. |
src/Microsoft.DotNet.Helix/JobMonitor/Microsoft.DotNet.Helix.JobMonitor.csproj |
Adds integration dependencies and source-build guards. |
src/Microsoft.DotNet.Helix/JobMonitor/JobMonitorRunner.cs |
Adds Entra client creation and warnings. |
src/Microsoft.DotNet.Helix/JobMonitor/JobMonitorOptions.cs |
Adds Entra monitor configuration. |
src/Microsoft.DotNet.Helix/Client/CSharp/HelixApiOptions.cs |
Adds authentication modes, scopes, and bearer policy. |
src/Microsoft.DotNet.Helix/Client/CSharp/ApiFactory.cs |
Adds Entra client factories. |
eng/common/core-templates/steps/send-to-helix.yml |
Configures pipeline Entra authentication. |
eng/common/core-templates/job/job.yml |
Clarifies legacy token handling. |
eng/common/core-templates/job/helix-job-monitor.yml |
Configures monitor-job Entra authentication. |
Documentation/AzureDevOps/SendingJobsToHelix.md |
Documents authentication setup. |
Review details
- Files reviewed: 22/22 changed files
- Comments generated: 1
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Keep existing TokenCredential constructors on the token authentication policy and use explicit scopes only through the new Entra factories. Add coverage for custom-host legacy credentials. Co-authored-by: Copilot <[email protected]> Copilot-Session: 4aa6b2e8-2313-40c0-92f6-1d578db0af15
Co-authored-by: Copilot <[email protected]>
There was a problem hiding this comment.
🔵 Needs a closer look
Two moderate Entra-mode URL issues remain unresolved; source-build guidance also needs updating.
Review details
Suppressed comments (3)
src/Microsoft.DotNet.Helix/Sdk/Readme.md:32
- This new guidance omits the source-build limitation:
Microsoft.DotNet.Helix.Sdkdeliberately excludesMicrosoft.DotNet.ArcadeAzureIntegrationfor source-only builds andCreateEntraHelixApithrowsPlatformNotSupportedExceptionthere. Without noting that limitation, source-build users are told that Entra is an available alternative but will get a runtime failure.
- `HelixUseEntraAuthentication=true` with an available `DefaultIdentityTokenCredential`, or
src/Microsoft.DotNet.Helix/Sdk/tools/Microsoft.DotNet.Helix.Sdk.MonoQueue.targets:86
- When Entra is enabled while a legacy
HelixAccessTokenis still present, this new auth path still reaches the target's_AccessTokenSuffixlogic, which checks only whetherHelixAccessTokenis nonempty. The subsequent 'Sent Helix Job' URL therefore includes a PAT placeholder even though Entra is active and the PAT is intentionally ignored. Make the suffix conditional onHelixUseEntraAuthenticationbeing false.
UseEntraAuthentication="$(HelixUseEntraAuthentication)"
src/Microsoft.DotNet.Helix/Sdk/tools/Microsoft.DotNet.Helix.Sdk.MultiQueue.targets:104
- Entra mode still permits a legacy
HelixAccessTokento be present (the newHelixTaskpath only warns and ignores it for API authentication).CheckHelixJobStatusis passed that token and builds its failure-log URL suffix fromAccessTokenalone, so an Entra-authenticated failure advertises a PAT-style?access_token={Get this from helix.dot.net}link that cannot authenticate via Entra. Gate that suffix on!UseEntraAuthentication(or otherwise clear the token for this task).
UseEntraAuthentication="$(HelixUseEntraAuthentication)"
- Files reviewed: 22/22 changed files
- Comments generated: 0 new
- Review effort level: Lite
There was a problem hiding this comment.
🔵 Needs a closer look
Address the two moderate token-cache issues and the two diagnostic URL suffix nits before approval.
Review details
Suppressed comments (4)
src/Microsoft.DotNet.Helix/JobMonitor/JobMonitorRunner.cs:825
- This path constructs
DefaultIdentityTokenCredentialwith its default short cache. That wrapper caches the returnedAccessTokenfor a fixed three minutes without consideringAccessToken.ExpiresOn(seesrc/Microsoft.DotNet.ArcadeAzureIntegration/TokenCredentialShortCache.cs:74-80), so if an identity returns a token with less than three minutes remaining,BearerTokenAuthenticationPolicycan request a refresh but receive the same expired token and Helix requests fail. Disable the short cache for this expiry-aware API client, or make the cache honor the token expiry, and cover the production credential path with a short-lived token test.
return ApiFactory.GetAuthenticatedWithEntra(
baseUri,
new DefaultIdentityTokenCredential());
src/Microsoft.DotNet.Helix/Sdk/HelixTask.cs:100
- This path constructs
DefaultIdentityTokenCredentialwith its default short cache. That wrapper caches the returnedAccessTokenfor a fixed three minutes without consideringAccessToken.ExpiresOn(seesrc/Microsoft.DotNet.ArcadeAzureIntegration/TokenCredentialShortCache.cs:74-80), so if an identity returns a token with less than three minutes remaining,BearerTokenAuthenticationPolicycan request a refresh but receive the same expired token and Helix requests fail. Disable the short cache for this expiry-aware API client, or make the cache honor the token expiry, and cover the production credential path with a short-lived token test.
return ApiFactory.GetAuthenticatedWithEntra(
baseUri,
new DefaultIdentityTokenCredential());
src/Microsoft.DotNet.Helix/Sdk/tools/Microsoft.DotNet.Helix.Sdk.MonoQueue.targets:86
- This opt-in can still leave
HelixAccessTokenpopulated, but the_AccessTokenSuffixbelow is conditioned only on that property. As a result, Entra-enabled submissions with a legacy token produce a misleading PAT-style work-items URL even though the token is ignored. Also require$(HelixUseEntraAuthentication) != 'true'when creating the suffix.
UseEntraAuthentication="$(HelixUseEntraAuthentication)"
src/Microsoft.DotNet.Helix/Sdk/tools/Microsoft.DotNet.Helix.Sdk.MultiQueue.targets:104
- When Entra is enabled while a legacy
HelixAccessTokenis still present,CheckHelixJobStatusstill derives its failure-log URL suffix solely fromAccessToken, so it emits a PAT-style?access_token={Get this from helix.dot.net}link even though the task explicitly ignores that token. Gate that suffix on!UseEntraAuthentication(and cover the mixed-input case) so diagnostics match the selected authentication mode.
UseEntraAuthentication="$(HelixUseEntraAuthentication)"
- Files reviewed: 22/22 changed files
- Comments generated: 0 new
- Review effort level: Lite
Summary
Backports refreshable Helix Entra authentication to
release/11.0for AB#12269.Validation
Build.cmd -configuration Release -projects src\Microsoft.DotNet.Helix\Sdk.Tests\Microsoft.DotNet.Helix.Sdk.Tests\Microsoft.DotNet.Helix.Sdk.Tests.csproj -testMicrosoft.DotNet.Helix.JobMonitorbuilt successfully as a referenced project