Repository navigation
Allow for an access mechanism to be specified in the .lfsconfig file - #1122
Merged
Merged
Conversation
Contributor
|
Looks great, just needs a test :) diff --git a/test/test-config.sh b/test/test-config.sh
index b185396..b6438a8 100755
--- a/test/test-config.sh
+++ b/test/test-config.sh
@@ -15,12 +15,25 @@ begin_test "default config"
git config --file=.gitconfig lfs.url http://gitconfig-file-ignored
git config --file=.lfsconfig lfs.url http://lfsconfig-file
+ git config --file=.lfsconfig lfs.http://lfsconfig-file.access lfsconfig
git lfs env | tee env.log
- grep "Endpoint=http://lfsconfig-file (auth=none)" env.log
+ grep "Endpoint=http://lfsconfig-file (auth=lfsconfig)" env.log
+ # new endpoint url from local git config
+ # access setting no longer applied
git config lfs.url http://local-lfsconfig
git lfs env | tee env.log
grep "Endpoint=http://local-lfsconfig (auth=none)" env.log
+
+ # add the access setting to lfsconfig
+ git config --file=.lfsconfig lfs.http://local-lfsconfig.access lfsconfig
+ git lfs env | tee env.log
+ grep "Endpoint=http://local-lfsconfig (auth=lfsconfig)" env.log
+
+ # add the access setting to git config¡
+ git config lfs.http://local-lfsconfig.access config
+ git lfs env | tee env.log
+ grep "Endpoint=http://local-lfsconfig (auth=config)" env.log
)
end_testThis is a failing test on master that should work with this PR. |
Contributor
Author
|
Thanks for providing the example test. I added it (with just a minor change). I verified that it fails without my proposed change to config.go, and succeeds with the change. |
Contributor
|
Awesome, thanks 🤘 |
chrisd8088
added a commit
that referenced
this pull request
Oct 22, 2026
By default, when the Git LFS client receives a 401 status code response to an HTTP request, it records the type of authentication required by the remote host in a local Git configuration option named "lfs.<url>.access". On subsequent invocations of the client, it checks this option's value before making any HTTP requests to the remote host, and if the option is set, attempts to acquire and send the appropriate credentials for the host with its first request. By doing so, the client avoids the need to send a preliminary request without credentials each time it runs, since such requests are likely to just receive 401 status code responses. Users may set "lfs.<url>.access" configuration options in advance if they know the type of authentication required by a remote host, and in commit dc4dc8e of PR #1122 we introduced support for the inclusion of "lfs.<url>.access" options in ".lfsconfig" files. If an ".lfsconfig" file appears in the top level of a repository, the Git LFS client will read and parse the file as a Git configuration file. For security reasons, though, only a small subset of options are accepted from ".lfsconfig" files, and all other options are ignored. However, in commit dc4dc8e, when we intended to add the "lfs.<url>.access" option to the subset of options that are permitted to appear in an ".lfsconfig" file, we failed to properly constrain the option's name to the "lfs" configuration section. Fortunately, there are no other options defined by Git or Git LFS with a "*.<url>.access" name pattern, so this oversight does not constitute a security vulnerability on its own. The situation would change, though, if support for a new option which matched the "*.<url>.access" pattern were to be introduced in the future. To resolve this concern, we adjust the readGitConfig() function in our "config" package so that when it parses options from an ".lfsconfig" file, it only accepts those whose final component matches the string "access" if their initial component matches the section name "lfs". We then expand the Go test function we added in a prior commit and also add a shell integration test to confirm that our changes are effective and that options of the form "*.<url>.access" are ignored in ".lfsconfig" files if they do not appear in the "lfs" configuration section. Co-authored-by: Aniket Gupta <[email protected]>
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.
I don't know if you want a change this simple, as I don't know the original intent, but as mentioned in issue #1121, I was hoping to describe the access of my LFS URL as "private" in the same .lfsconfig as where I define the URL itself. I think it makes the most sense to have this data be co-resident. However, git-lfs won't allow me to put this content in the .lfsconfig. This simple change allows me to define it there.