You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
✨ Enable pass-through of private Git credentials to containers #9858
I want to use my host's configured Git credentials within containers in Dagger.
Why is this important to you?
I want to be able to git fetch additional branches to what is already checked out within a git context. This is important for tools like SonarQube where it requires the context of the reference branch to do the analysis. There may be other use cases which require a fetch/pull from remote when working with current git directories. This is easy to do when you don't have to Auth to git (OSS repos). But for Enterprise use cases, it's not ergonomic.
How are you currently working around this?
The current workaround to this is re-authenticating each container with the PAT. An example:
This is cumbersome especially given that Dagger engine already has the Git credentials loaded in. For example, dagger passes through proxy, docker and CA certificates to the subsequent containers from the host. The same should happen with git credentials when private Git is involved.
Hm, I'm struggling to come up with how this would be ergonomic + secure - if the GitRef.tree is being mounted into a Container, we're not really able to auto-transfer a secret like that.
It feels a little bit like the automatic-credential injection is part of the problem here - e.g. instead imagine a dag.SSHAgent or a dag.GitPAT function. Then you could easily just grab the credentials from there.
The problem is this feels terrible from a security perspective. While today, the user ssh agent can be accessed from any WithExec (this is fine, because the keys themselves aren't actually ending up in the container), injecting a PAT like this would be a pretty bad security issue.
Maybe this is linked to the more general "user-environment credentials" problem?
Alternatively, maybe this is fixable by continuing to enhance the Git api, so we're not forced to fallback to WithExecs.
injecting a PAT like this would be a pretty bad security issue.
By "this" do you mean what I'm doing above or what you are kind of suggesting?
Alternatively, maybe this is fixable by continuing to enhance the Git api, so we're not forced to fallback to WithExecs.
This is basically what I'm looking for :). I am not concerned much with the how. This is not an issue for a public repo where creds aren't required. But here, I know Dagger already has my host git config but I am doing my own auth flow using gh CLI to get that into a container. IF the git config can be pulled into a container I'd be satisfied. I don't think I'm concerned about having it in a specific directory for example with src.AsGit.
The auth piece in my example is entirely in the context of the container and not a directory.
Activity
jedevc commentedon Apr 24, 2025
Hm, I'm struggling to come up with how this would be ergonomic + secure - if the
GitRef.treeis being mounted into aContainer, we're not really able to auto-transfer a secret like that.It feels a little bit like the automatic-credential injection is part of the problem here - e.g. instead imagine a
dag.SSHAgentor adag.GitPATfunction. Then you could easily just grab the credentials from there.The problem is this feels terrible from a security perspective. While today, the user ssh agent can be accessed from any
WithExec(this is fine, because the keys themselves aren't actually ending up in the container), injecting a PAT like this would be a pretty bad security issue.Maybe this is linked to the more general "user-environment credentials" problem?
Alternatively, maybe this is fixable by continuing to enhance the
Gitapi, so we're not forced to fallback toWithExecs.nipuna-perera commentedon Apr 24, 2025
By "this" do you mean what I'm doing above or what you are kind of suggesting?
This is basically what I'm looking for :). I am not concerned much with the how. This is not an issue for a public repo where creds aren't required. But here, I know Dagger already has my host git config but I am doing my own auth flow using
ghCLI to get that into a container. IF the git config can be pulled into a container I'd be satisfied. I don't think I'm concerned about having it in a specific directory for example withsrc.AsGit.The auth piece in my example is entirely in the context of the container and not a directory.