Repository navigation
fix: use git credential helper's username for modules with http auth - #10427
skycaptain wants to merge 0 commit into
Conversation
|
Thanks for this PR 🙏 Given that all the tests pass, it seems to be a working implementation. I'll dig a bit more tomorrow on the implications (haven't thoroughly checked yet). I'll add a corresponding test too in the meantime. Privileges on the test repo are mandatory for the implementation of this test ahah, so no worries 😇 Thanks again ! PS: regarding having the PAT inside the ref, I worry that we couldn't ensure 0 leak of information in case the token gets cached |
Sure! I absolutely understand that a change like this needs to be thought through and tested thoroughly to avoid breaking existing functionality or leaking sensitive data. Let me know, if I can help out.
Thanks! |
| Value: dagql.NewString(remote.String()), | ||
| }, | ||
| { | ||
| Name: "httpAuthToken", |
There was a problem hiding this comment.
I would say we can add a new httpAuthUsername here that does what you suggest.
There was a problem hiding this comment.
I’m completely fine adding the httpAuthUsername field. Given this involves an API change, do you think we should include Solomon for the API design review?
Would you prefer extending this PR or handling it as a separate follow-up? I’m impressed by how elegantly this contribution solves the issue, although it means tokens are always sent as headers instead of traditional tokens—this is acceptable, but it does trigger my correctness alert. Still, I’m comfortable moving forward if we agree it’s not critical.
|
LGTM, we need a test though. @grouville why do we need to make changes to the test repo here? This should just be possible to test just using There's no tests that cover the behavior of the auto-loading credentials for just plain git clones (only for modules). dagger/core/integration/module_test.go Lines 5774 to 5800 in 84dc5b3 We should adapt the above to |
|
Hey @jedevc, I’m not 100% sure I’ve fully grasped all your points here 🙏👼 Just to confirm my understanding clearly:
My initial intent was testing the specific GitLab edge case (CI_JOB_TOKEN requires explicit username). But your suggestion seems broader: instead of an integration test using a real token, you’d prefer spinning up a local git server with ExperimentalServiceHost and checking credentials locally. Did I get that right?
Could you clarify what you mean by “plain git clones”? Currently, dag.Git() calls within module functions intentionally don’t auto-load credentials unless explicitly passed (see Discord ref). So, your comment made me a bit unsure. Let me know if I missed something! |
|
This PR is stale because it has been open 14 days with no activity. Remove stale label or comment or this will be closed in 7 days. |
|
I have a pending PR with the requested changes -- will push them after this week 🙏 |
|
@skycaptain I tried to push my branch with a few commits on top of your fork's main (as this is the reference of this PR) by force pushing (you only had a commit [that I have on my fork], so it felt safe) -- it worked to update the main branch's HEAD, but I'm getting errors atm, due to branch permissions. This updated your fork's main: Can you please pick the commits from this branch: https://github.com/grouville/dagger/tree/with-authtoken and reopen the PR please ? I don't have the rights 🙏 Your commit is still present cc @jedevc |
|
😮 Yeah, I see that force-pushing somehow removed my commit and might have auto-closed this PR. Since I don't have permission to reopen it, I created a new one: #10605. Since my commit was reverted anyway, starting with a fresh PR containing only our changes would have probably been easier though 😀. |

In #8989, an issue emerged with GitLab CI's
CI_JOB_TOKENs: Right now, when accessing remote modules via HTTP authentication usingdagger call -m gitlab.com/..., the username is hardcoded tox-access-token(except for bitbucket.com). However, as specified in GitLab’s documentation, usernamegitlab-ci-tokenis required when using basic authentication withCI_JOB_TOKEN. In the discussion, we recognized that not only receiving the secret but also the username from the git credential helper would solve the issue best.Several potential solutions came to my mind:
httpAuthUsernametoRemoteGitRepositoryand pass the username alongsidehttpAuthToken. It would also change the interface ofGitRepository, and while this isn't related to the original problem, it makes it easier to set the username when calling a git repo from within a module (currently, thehttpAuthHeaderarg must be composed manually). This was my first approach until I realized I could solve the issue without extensive code refactoring. However, I was considering adding two helper functions toGitRepository:.WithHttpAuthHeaderFromBasicAuth(username, password)and.WithHttpAuthHeaderFromBearerAuth(token)to simplifyhttpAuthHeaderformatting.httpAuthHeaderinstead ofhttpAuthTokento leverage existing code with minimal refactoring. While this solution works for the PR, it reveals overlapping logic betweencore.RemoteGitRepository.setupandcore.schema.gitSchema.git. Further refactoring may be beneficial to address this duplication.Currently, this PR doesn't address another desirable CLI feature: being able to pass credentials within the URL. At present, username and password parameters in URLs are ignored to best of my knowledge. Adding this capability would allow using the format
dagger call -m https://gitlab-ci-token:${CI_JOB_TOKEN}@gitlab.com/...and also passing repositories as directories from the command line in general. This would eliminate the need to set up a git credential helper, which can be cumbersome in some CI environments. However, during implementation, I discovered that additional refactoring is needed to make this work. Therefore, this PR only addresses the GitLab CI issue from #8989.Finally, do you have any suggestions for how to write test for these changes?