Skip to content

Introduce httpAuthUsername - #10605

Merged
jedevc merged 11 commits into
dagger:mainfrom
skycaptain:with-authtoken
Jun 18, 2025
Merged

jedevc merged 11 commits into
dagger:mainfrom
skycaptain:with-authtoken

Conversation

@skycaptain

Copy link
Copy Markdown
Contributor

Continuation of #10427.

skycaptain and others added 6 commits June 17, 2025 21:36
Previously, when calling dagger modules from a remote HTTP ref, only
the password/token was passed. However, in some situations (e.g., when
using CI_JOB_TOKENs with GitLab CI), a specific username must be used
for basic authorization. Instead of just passing the token, we now use
the existing authHeader interface to pass a formatted basic auth string
that includes the username received from the git credential helper.

Signed-off-by: Manuel Leonhardt <[email protected]>
…tp auth"

This reverts commit 928fb62b9c5571860c3153f63f4ecfe4c63abfc9.
This introduces an httpAuthUsername field to the core/git API.

Signed-off-by: Guillaume de Rouville <[email protected]>
Signed-off-by: Guillaume de Rouville <[email protected]>
Signed-off-by: Guillaume de Rouville <[email protected]>
Signed-off-by: Guillaume de Rouville <[email protected]>
@skycaptain

Copy link
Copy Markdown
Contributor Author

DCO complained about the revert commit not being signed-off. I suggest removing these commits since they have no functional impact.

@jedevc jedevc left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Couple of tiny nits, otherwise looks perfect! Thanks!

Any chance you could add a changelog entry using changie new?

Comment thread core/git.go Outdated

AuthToken dagql.Instance[*Secret]
AuthHeader dagql.Instance[*Secret]
AuthUsername dagql.String

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: can just be

Suggested change
AuthUsername dagql.String
AuthUsername string

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done to my best knowledge in top-most commit. This also required changing the API (changing the default value from nil to ""). Please have a look.

Comment thread core/git.go Resolved
Comment thread core/schema/git.go
Value: dagql.Opt(dagql.NewID[*core.Secret](authToken.ID())),
},
}
// Omit blank username; adding it would change the selector hash and kill cache hits.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: I would remove this comment, up to you! It follows a similar pattern as the surrounding code, don't know if it needs to be specifically called out.

@jedevc
jedevc merged commit 1c4cc14 into dagger:main Jun 18, 2025
@skycaptain
skycaptain deleted the with-authtoken branch June 18, 2025 14:05
@daniel-naegele

Copy link
Copy Markdown

As far as I can tell, this only adds the internal capability of the httpAuthUsername to the general code, but not the general capability of reading it from git, right?

I am trying to clone private repositories in GitLab with the CI_JOB_TOKEN (I don't want to create a long-lived SSH key), with the following .gitlab-ci.yaml example

.dagger:
  extends: [.docker]
  before_script:
    - apk add curl
    - curl -fsSL https://dl.dagger.io/dagger/install.sh | DAGGER_COMMIT=head BIN_DIR=/usr/local/bin sh
    - export MODULE_URL="..."
    - echo -e "https://gitlab-ci-token:[email protected]" > ~/.git-credentials
    - git config --global credential.helper store
    - git clone $MODULE_URL # Works flawlessly
    - dagger call ...

@skycaptain

Copy link
Copy Markdown
Contributor Author

As far as I can tell, this only adds the internal capability of the httpAuthUsername to the general code, but not the general capability of reading it from git, right?

I am trying to clone private repositories in GitLab with the CI_JOB_TOKEN (I don't want to create a long-lived SSH key), with the following .gitlab-ci.yaml example

.dagger:
  extends: [.docker]
  before_script:
    - apk add curl
    - curl -fsSL https://dl.dagger.io/dagger/install.sh | DAGGER_COMMIT=head BIN_DIR=/usr/local/bin sh
    - export MODULE_URL="..."
    - echo -e "https://gitlab-ci-token:[email protected]" > ~/.git-credentials
    - git config --global credential.helper store
    - git clone $MODULE_URL # Works flawlessly
    - dagger call ...

You're right - funny we missed that. My initial commit already had this, but the part where we initialize httpAuthUsername from credentials.Username got lost during the refactorings. I'll open a PR asap.

@grouville

Copy link
Copy Markdown
Member

You're right - funny we missed that. My initial commit already had this, but the part where we initialize httpAuthUsername from credentials.Username got lost during the refactorings. I'll open a PR asap.

Thank you 🙏 My bad ahah

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants