Skip to content

fix: keep git provider tokens out of clone URLs - #5619

Closed
Souvik-Cyclic wants to merge 1 commit into
Dokploy:canaryfrom
Souvik-Cyclic:fix/git-token-in-submodule-logs-5618
Closed

Souvik-Cyclic wants to merge 1 commit into
Dokploy:canaryfrom
Souvik-Cyclic:fix/git-token-in-submodule-logs-5618

Conversation

@Souvik-Cyclic

@Souvik-Cyclic Souvik-Cyclic commented Oct 8, 2026 •

Copy link
Copy Markdown
Contributor

What is this PR about?

The GitHub, GitLab and Gitea providers clone with the token in the URL (https://oauth2:<token>@host/owner/repo.git). When Enable Submodules is on and .gitmodules uses relative URLs, git resolves each submodule URL against that remote, so the submodule URL carries the token and git prints it while registering the submodule. The token ends up in every build log (#5618), and it is also stored in the cloned repo's .git/config.

This keeps the clone URL clean and passes the token as an Authorization: Basic header scoped to the clone host (git -c http.<origin>/.extraHeader=...). It is the same header git already sends for oauth2:<token>@ URLs, and the -c setting reaches the submodule clones, so private relative submodules keep working. Nothing after the clone needs the token in the remote URL.

Verified with a local git server that requires auth and a repo with a private relative submodule: on canary the log contains Submodule '...' (http://oauth2:<token>@...); with this change the clone and the submodule clone succeed for all three providers and the token appears neither in the output nor in .git/config. Also added tests for the generated clone commands.

Checklist

Before submitting this PR, please make sure that:

  • You created a dedicated branch based on the canary branch.
  • You have read the suggestions in the CONTRIBUTING.md file https://github.com/Dokploy/dokploy/blob/canary/CONTRIBUTING.md#pull-request
  • You have tested this PR in your local instance. If you have not tested it yet, please do so before submitting. This helps avoid wasting maintainers' time reviewing code that has not been verified by you.

Issues related (if applicable)

closes #5618

Screenshots (if applicable)

N/A

RetriggerConfidence Score: 5/5

The PR appears safe to merge; no actionable issues were found.

Summary

The PR removes tokens from GitHub, GitLab, and Gitea clone URLs. It sends the same credentials through a host-scoped Git header instead.

  • Recursive clones receive the header without storing the token in the remote URL.
  • New tests check header construction and clean clone URLs for all three providers.
  • Existing GitHub host tests now expect URLs without credentials.

Reviews (1) · Last reviewed commit: "fix: keep git provider tokens out of clo..." · Reviewed by Greptile

AminDhouib added a commit to DevinoSolutions/dokploy-community that referenced this pull request Oct 12, 2026
fix: keep git provider tokens out of clone URLs (port of Dokploy#5619)
decryptedchaos pushed a commit to decryptedchaos/dokploy-community that referenced this pull request Oct 22, 2026
Ports Dokploy#5619 (0d8bf3b).

The GitHub, GitLab and Gitea providers cloned with the token in the URL, so
git printed it while registering relative submodules and stored it in
.git/config. Pass the token as a host-scoped Authorization header instead.
decryptedchaos pushed a commit to decryptedchaos/dokploy-community that referenced this pull request Oct 22, 2026
…remotes

Extends the header-based clone credentials from Dokploy#5619 to the paths the
upstream change does not reach in this fork:

- Bitbucket (API token and username/app password) now sends Basic credentials
  in a host-scoped http.extraHeader instead of the clone URL.
- Preview head-ref checkouts (github/gitlab/gitea) add the header to the two
  fetches and the submodule update and register a credential-free origin, so
  the token is no longer stored in .git/config.
- getGitBasicAuthConfig generalises the helper to any username/secret pair;
  getGitTokenAuthConfig keeps the oauth2 form.

Tests cover each provider (plain and head-ref), compose and remote-server
clones, a hostile password staying a single argument, and redaction of the
header in command errors.
@narcisonunez narcisonunez mentioned this pull request Oct 22, 2026
3 tasks done
@narcisonunez

Copy link
Copy Markdown
Collaborator

This was already fixed. Thanks.

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.

GitHub App installation token is written to build logs when an app uses private submodules

2 participants