Support azure oidc using github token#2113
Conversation
📝 WalkthroughWalkthroughThis PR adds GitHub Actions OIDC federation support to Azure authentication in the Defang platform. The changes introduce a new authentication pathway that exchanges GitHub-issued OIDC tokens for Azure credentials when running in GitHub Actions CI, with appropriate fallback to existing credential paths if the new pathway is not applicable. ChangesGitHub OIDC for Azure Authentication
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 golangci-lint (2.12.2)level=warning msg="The linter 'gomodguard' is deprecated (since v2.12.0) due to: new major version. Replaced by gomodguard_v2." Tip 💬 Introducing Slack Agent: The best way for teams to turn conversations into code.Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.
Built for teams:
One agent for your entire SDLC. Right inside Slack. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
src/pkg/clouds/azure/login.go (1)
285-287: ⚡ Quick winWrap error with context for better debuggability.
The error from
testAzureCredentialis returned unwrapped. Adding context would help identify that this failure occurred specifically in the GitHub OIDC path during debugging.♻️ Suggested fix
if err := testAzureCredential(ctx, a.SubscriptionID, cred); err != nil { - return nil, err + return nil, fmt.Errorf("GitHub-OIDC credential failed subscription validation: %w", err) }As per coding guidelines: "Wrap errors with context using fmt.Errorf with %w verb".
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/pkg/clouds/azure/login.go` around lines 285 - 287, The call returning the error from testAzureCredential is returning the raw error; update the return to wrap that error with context (e.g., using fmt.Errorf) so it indicates the failure happened while testing Azure credentials in the GitHub OIDC path; specifically wrap the error returned from testAzureCredential(ctx, a.SubscriptionID, cred) (referencing testAzureCredential, a.SubscriptionID and cred) using fmt.Errorf("testing Azure credential for GitHub OIDC: %w", err) and return that wrapped error.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@src/pkg/clouds/azure/login.go`:
- Around line 285-287: The call returning the error from testAzureCredential is
returning the raw error; update the return to wrap that error with context
(e.g., using fmt.Errorf) so it indicates the failure happened while testing
Azure credentials in the GitHub OIDC path; specifically wrap the error returned
from testAzureCredential(ctx, a.SubscriptionID, cred) (referencing
testAzureCredential, a.SubscriptionID and cred) using fmt.Errorf("testing Azure
credential for GitHub OIDC: %w", err) and return that wrapped error.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: f510e263-bbeb-44b3-8062-d1ffd46e77e6
📒 Files selected for processing (2)
src/pkg/clouds/azure/login.gosrc/pkg/clouds/azure/login_test.go
Description
Support azure oidc using github token
Linked Issues
https://github.com/DefangLabs/portal/issues/728
Checklist
Summary by CodeRabbit
New Features
Tests