allow for basic auth override for non-host matching jit request#58
Open
allow for basic auth override for non-host matching jit request#58
Conversation
There was a problem hiding this comment.
Pull request overview
This PR extends the JIT (Just-In-Time) access token refresh mechanism in the dependabot proxy to support an optional basic auth override. When a jit_access credential includes explicit username and password fields, those are used for HTTP Basic Auth when communicating with the JIT access endpoint, instead of the default $JOB_TOKEN. This enables Azure DevOps environments where the JIT access refresh endpoint requires a different authentication mechanism.
Changes:
- Added
jitAccessConfigstruct to carry endpoint, username, and password together, replacing the previousmap[string]stringthat only stored the endpoint URL - Extended
RequestJITAccessmethod andScopeRequesterinterface to accept optionalusernameandpasswordparameters, applying Basic Auth when both are provided - Added an integration test using
httpmockto verify the full request flow: expired token → JIT refresh with explicit auth → retry with refreshed token
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 5 comments.
| File | Description |
|---|---|
internal/handlers/git_server.go |
Introduces jitAccessConfig struct, updates ScopeRequester interface and plumbing to pass username/password through to RequestJITAccess |
internal/apiclient/client.go |
Adds username/password params to RequestJITAccess; sets Basic Auth when both are provided |
internal/apiclient/client_test.go |
Updates existing test call sites to pass empty strings for the new parameters |
internal/handlers/git_server_test.go |
Updates TestScopeRequester mock; adds end-to-end integration test for explicit auth flow |
Contributor
Author
|
Failing smoke tests appear to be updated dependencies. Will re-cache runs shortly and retry. |
jakecoffman
approved these changes
Mar 6, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When the proxy refreshes a JIT token used to talk to
github.comit communicates with ajit_accessendpoint using the existing$JOB_TOKENvariable. As a member of the Microsoft Azure DevOps dependabot team we run the dependabot updater in Azure DevOps repos and our JIT access refresh endpoint uses a different authentication mechanism than just the original$JOB_TOKEN.This PR allows for an optional username and password to be attached to the
jit_accesscredential and if present basic HTTP auth will be set.The implementation will still use the original
$JOB_TOKENvariable unless the new parameters are explicitly given.The functional change is in
internal/apiclient/client.go. The call toclient.newRequest(...)on line 117 sets the$JOB_TOKENvariable as the authentication mechanism but then on line 122 if and only if both username and password were given is the auth overridden. All other changes are plumbing to allow the extra information to be passed through.The added test is a bit large, but very explicit in what URLs are requested and with what auth and even with what the status code was.