Skip to content

Conversation

@rubyist
Copy link
Contributor

@rubyist rubyist commented Oct 7, 2015

This PR adds support for using netrc for LFS API requests. The priority becomes:

  1. Check the LFS URL for authentication. Ex: http://user:pass@example.com
  2. Check netrc for authentication.
  3. Check the Git remote URL for authentication IF it's the same scheme and host of the LFS URL.
  4. Ask 'git credential' to fill in the password from one of the above URLs.

TODO:

  • Add netrc support
  • Add automated tests
  • What happens on Windows? Does netrc work there?

//cc #705

@rubyist rubyist added the wip label Oct 7, 2015
Copy link
Contributor

Choose a reason for hiding this comment

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

Do you think it's worth caching this in the global lfs.Config object? Looks like this is called for every API request, so it could be used multiple times in a single git-lfs process (especially with the legacy API).

@technoweenie technoweenie mentioned this pull request Oct 19, 2015
13 tasks
@technoweenie
Copy link
Contributor

I added central caching of the *netrc.Netrc object in Config. Also added a platform specific netrcBasename var that's set to .netrc everywhere except windows, which uses _netrc.

@technoweenie
Copy link
Contributor

This looks good, but script/integration is hanging locally after the last test. The "master" and even the latest "cred-fixes" branches both work flawlessly for me.

I'm going to hold it back from v1.1 until that can be checked out, and the netrc feature itself can be tested a bit more. Should be a shoe-in for v1.2 though.

@rubyist
Copy link
Contributor Author

rubyist commented Nov 18, 2015

It hangs because netrcBasename is blank because go on osx won't build the file config_linux.go, even if the build tag tells it to. You have to name it something that isn't a platform name:

Naming a file dns_windows.go will cause it to be included only when building the package for Windows; similarly, math_386.s will be included only when building the package for 32-bit x86.

I think I usually see them as _nix or _unix.

@technoweenie
Copy link
Contributor

Doh, good catch.

On Wed, Nov 18, 2015 at 11:47 AM, Scott Barron notifications@github.com
wrote:

It hangs because netrcBasename is blank because go on osx won't build the
file config_linux.go, even if the build tag tells it to. You have to name
it something that isn't a platform name:

Naming a file dns_windows.go will cause it to be included only when building the package for Windows; similarly, math_386.s will be included only when building the package for 32-bit x86.

I think I usually see them as _nix or _unix.


Reply to this email directly or view it on GitHub
#715 (comment).

Rick Olson

@technoweenie technoweenie mentioned this pull request Nov 19, 2015
17 tasks
Instead of a blank var in the main config with values set by init() in
build flag protected files, the build flagged files should create the
var. This prevents cases where no build flagged file builds leaving an
empty netrc basename causing auth failures.

This also renames the file config_linux.go to config_nix.go because it
should build on all unix-y platforms.
@rubyist
Copy link
Contributor Author

rubyist commented Nov 21, 2015

I pushed a change that renames the file, but also changes the way the variable is set. Instead of a var + init() in the build flagged files, the build flagged files should define the variable. With this pattern, the build would have failed immediately because nothing defined netrcBasename.

technoweenie added a commit that referenced this pull request Mar 3, 2016
Add netrc support for LFS API requests
@technoweenie technoweenie merged commit 2cf082f into master Mar 3, 2016
@technoweenie technoweenie deleted the netrc branch March 3, 2016 18:03
chrisd8088 added a commit to chrisd8088/git-lfs that referenced this pull request May 21, 2025
Support for reading and parsing ".netrc" files (or "_netrc" files on
Windows) was first added to the Git LFS client in PR git-lfs#715, and the
parsing code was later moved into our "config" package in PR git-lfs#1226.

Subsequently, almost identical parsing code was also added to our
"lfsapi" package in commit 2275188
of PR git-lfs#1839, which was later moved to its current location in our
"creds" package in PR git-lfs#3307.

Meanwhile, the only caller of the original ".netrc" parser, which
was implemented in the parseNetrc() method of the Configuration structure
in our "config" package, was removed in commit
afcd211 PR git-lfs#1846.

As a consequence, since PR git-lfs#1846 the parseNetrc() method in the "config"
package has remained unused, along with the related "netrcfinder"
interface and associated structure and method in the same source file,
so we can simply delete that file now.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants