Skip to content

Add NTLM Auth - #714

Merged
technoweenie merged 35 commits into
git-lfs:masterfrom
WillHipschman:ntlm
Nov 16, 2015
Merged

technoweenie merged 35 commits into
git-lfs:masterfrom
WillHipschman:ntlm

Conversation

@WillHipschman

Copy link
Copy Markdown

This a first attempt at adding NTLM auth. It addresss the proposal in #617. Please let me know your thoughts.

It uses lfs.{endpoint}.access to toggle NTLM and most ntlm specific logic is in its own class. We store user/pass in the cred helper but could later go get them from AD.

Things that still need to be done:

  1. Add Tests-I can add unit tests but I don't think migrating the whole test infrastructure to support windows environments should block this.
  2. Add documentation.

@WillHipschman

Copy link
Copy Markdown
Author

Checks are failing because I haven't yet included the ntlm auth library. Assuming that folks are ok with this implementation and the libraries used I'll add it in the next iteration.

Comment thread lfs/config.go Outdated

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Remove the ntlm check here--ntlm is private access.

Comment thread lfs/ntlm.go Outdated

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.

Looks like this is hiding a possible error. I think that this function should be private, and should return a possible error that other functions can bubble up.

Comment thread lfs/client.go Outdated

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.

If we read the entire response into memory, large files can definitely crash the client on low memory machines. We could maybe do this if content length is set and it's under some value - but I would really prefer to not do it at all for downloads. This is also ignoring the error.

@rubyist

rubyist commented Oct 8, 2015

Copy link
Copy Markdown
Contributor

Reading the whole body into memory doesn't seem like it's going to help much, because it still takes time to do that. Reading into memory vs reading into a file will probably not differ significantly enough to matter while running concurrent transfers, particularly with groups of files of varying sizes.

I think the way to guarantee that the connection will be reused is to not run it concurrently. This could be done at a higher level by setting the number of workers for the transfer queue to 1. But then I'd have to wonder if that's really worth it vs re-authing connections. What's the cost there? Do we have benchmarks? I'm thinking setting the max idle conns to be >= the number of concurrent workers should limit the number of connections that get tossed.

@sinbad

sinbad commented Oct 9, 2015

Copy link
Copy Markdown
Contributor

If you're reading the entire body in order to try to force the re-use of the authenticated connection, you're just serialising all the transfers anyway, so you might as well make that explicit by disabling concurrency for NTLM. The first request is always issued serially anyway (others are delayed until auth has been performed) so once you've detected NTLM in that first request you could disable parallel requests if you wanted to re-use the connection, without bulk reading into memory all the time.

I'm actually not convinced that the ReadAll is guaranteed not to be interrupted by another goroutine anyway, Go makes no assurances on that, so using it to try to serialise the requests probably isn't 100% watertight - it might be in this Go version but not always. Only deliberately running only one request at a time would do that, and then the regular code paths would ensure the body is read & closed before the next request.

But, I also agree with @rubyist that the proper solution is to allow the parallel transfers and to find a way to do the NTLM auth per connection, although I suspect that needs a to be implemented in a Transport implementation. TBH there's probably a good argument that our existing auth sequence should be in a Transport and not in the calling code.

@sinbad

sinbad commented Oct 9, 2015

Copy link
Copy Markdown
Contributor

there's probably a good argument that our existing auth sequence should be in a Transport and not in the calling code.

.. although the first request would still need to be serialised in order to ensure the user only gets one login prompt.

@WillHipschman

Copy link
Copy Markdown
Author

I think that we were just missing a close in an earlier version somewhere. I removed the body copying and upload works just fine with

ConcurrentTransfers=4
BatchTransfer=true

@WillHipschman

Copy link
Copy Markdown
Author

I lied. Upload works fine, but Download has race conditions where some number of files don't get downloaded depending on interleaving. Setting ConcurrentTransfers=1 works though.

@technoweenie technoweenie mentioned this pull request Oct 19, 2015
7 of 13 tasks
Comment thread lfs/client.go

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.

We shouldn't need this. res comes from doLegacyApiRequest(), which calls decodeApiResponse(). That function parses json and immediately closes the response body. While it doesn't hurt, these lines shouldn't be required.

@technoweenie technoweenie mentioned this pull request Nov 6, 2015
@technoweenie

Copy link
Copy Markdown
Contributor

See #820

@technoweenie
technoweenie merged commit 6599c1f into git-lfs:master Nov 16, 2015
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.

4 participants