Repository navigation
fix(core/git): ensure HTTP auth is propagated to submodules - #10855
Merged
Merged
Conversation
grouville
marked this pull request as ready for review
August 8, 2025 00:30
marcosnils
reviewed
Aug 8, 2025
marcosnils
reviewed
Aug 8, 2025
grouville
force-pushed
the
git-submodules
branch
4 times, most recently
from
August 9, 2025 01:52
513f112 to
8ac538e
Compare
jedevc
reviewed
Aug 11, 2025
jedevc
reviewed
Aug 11, 2025
grouville
marked this pull request as draft
August 12, 2025 08:04
grouville
force-pushed
the
git-submodules
branch
from
August 12, 2025 19:21
8ac538e to
556ecc6
Compare
grouville
marked this pull request as ready for review
August 12, 2025 20:34
jedevc
reviewed
Aug 13, 2025
jedevc
reviewed
Aug 13, 2025
jedevc
reviewed
Aug 13, 2025
jedevc
reviewed
Aug 13, 2025
jedevc
reviewed
Aug 13, 2025
jedevc
reviewed
Aug 13, 2025
grouville
force-pushed
the
git-submodules
branch
from
August 14, 2025 19:10
556ecc6 to
9cce89a
Compare
Member
Author
|
Failing because of: #10878 |
jedevc
reviewed
Aug 18, 2025
grouville
force-pushed
the
git-submodules
branch
2 times, most recently
from
August 19, 2025 05:39
c80d112 to
ca6b0fe
Compare
jedevc
approved these changes
Aug 19, 2025
jedevc
left a comment
Contributor
There was a problem hiding this comment.
Nice! 🎉
Thanks for splitting out to the helpers, now that's a really nice interface we can use in the future as well!
Contributor
|
@grouville just needs a brief oneline changelog, then feel free to merge! |
…auth Previously we passed `http.<remote>.extraheader` via `-c` CLI args. That only applies to the top-level `git` process, so `git submodule update --init --recursive` did not inherit the `Authorization` header and submodule fetches failed under HTTP(S) auth. This change injects the header through `GIT_CONFIG_*` environment variables for every git invocation, appending a host-scoped key: http.<scheme>://<host>/.extraheader = Authorization: <value> Using env-config makes nested `git` processes inherit the same auth, which fixes submodule clones that resolve relative to the parent’s host. Notes: - `AuthHeader` continues to be the header *value* (e.g., `Basic …` / `Bearer …`); we add the `Authorization: ` prefix at injection time. - `AuthToken` still builds `basic <base64(user:pass)>` with host defaults (`x-access-token`, or `x-token-auth` for Bitbucket). - We scope by `scheme://host` to avoid leaking headers to other hosts. Limitation: - Cross-host submodules are still unauthenticated; addressing that requires API support (see dagger#10863). Signed-off-by: Guillaume de Rouville <[email protected]>
Introduce gitSmartHTTPServiceDirAuth — a tiny lighttpd+git-http-backend helper (optional Basic auth) that serves a directory of bare repos. Add TestSubmoduleAuth: - Creates bare /srv/submodule.git and /srv/parent.git - Adds submodule via absolute file:// then rewrites .gitmodules to a relative URL (../submodule.git) to mirror real repos - Serves over smart-HTTP and clones parent with HTTPAuthToken - Verifies both parent and submodule files are fetched - Negative case without auth fails Why smart-HTTP? `git submodule update --depth=1` performs a shallow fetch; dumb HTTP can’t advertise shallow capability, so the test must use smart-HTTP. This test reproduces the original bug (submodules didn’t inherit http.extraheader) and now passes with env-based injection. Signed-off-by: Guillaume de Rouville <[email protected]>
…HTTP git submodule update --init --recursive now attempts a shallow update first (--depth=1) and, if the fetch fails with an error indicating the server “does not support shallow” (i.e., dumb HTTP), retries without the depth flag. Signed-off-by: Guillaume de Rouville <[email protected]>
Follow-up addressing maintainer review:
- core/git: Capitalize HTTP Authorization scheme as "Basic" (fix typo)
- core/integration/git_test: Replace uuid.NewString() with identity.NewID() + check on exact error message ("git error", "Authentication failed")
- core/integration/services_test: Replace previous lighttpd CGI setup with simpler nginx+fcgiwrap solution for smart-HTTP git backend
- util/gitutil/config_env_test.go: Introduce parseKeyLine helper function to avoid repeated parsing logic
Signed-off-by: Guillaume de Rouville <[email protected]>
Following Justin's feedback, this commit encapsulates HTTPS authorization header and configuration logic within gitutil itself. This approach simplifies callers by abstracting internal details, ensuring consistent handling of authentication across git operations, including nested commands such as submodule fetches. Key reasoning: - Centralizes the logic for building HTTP authorization headers and ensures submodule clones inherit authentication. Signed-off-by: Guillaume de Rouville <[email protected]>
Signed-off-by: Guillaume de Rouville <[email protected]>
grouville
force-pushed
the
git-submodules
branch
from
August 19, 2025 15:17
ca6b0fe to
1dd78ea
Compare
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.
Fixes https://discord.com/channels/707636530424053791/1397694731496067194/1397694731496067194
Previously, HTTP(S) authentication worked only for the parent repository clone. Submodule clones failed because the auth header (http.:///.extraheader) passed via CLI args (-c) wasn’t inherited by nested Git processes (git submodule update). By injecting the header through the GIT_CONFIG_* environment variables instead, the auth configuration propagates to submodules automatically, fixing the inheritance issue and ensuring consistent authentication.
Update 2025-08-12
Since opening this PR, I’ve made a few adjustments: