Skip to content

Initial NTLM Proposal - #617

Closed
WillHipschman wants to merge 1 commit into
git-lfs:masterfrom
WillHipschman:master
Closed

WillHipschman wants to merge 1 commit into
git-lfs:masterfrom
WillHipschman:master

Conversation

@WillHipschman

Copy link
Copy Markdown

Here's an initial proposal for NTLM auth in git lfs.

I need to update it with specifics on the Client interface but I want to wait until #611 is merged to do that.

Let me know if you have thoughts or questions.

Hacked together implementation of push here https://github.com/WillHipschman/git-lfs/tree/ntlm

@technoweenie

Copy link
Copy Markdown
Contributor

Does Git support NTLM authentication without having to go through an HTTP proxy? This is the only non-proxy info that I could find. I'm guessing you're trying to do the same thing here.

@WillHipschman

Copy link
Copy Markdown
Author

Yeah, I'm trying to do something similar. The link above points to a change made by some of my colleagues, to accomplish the same thing I'm trying to do for git-lfs.

@technoweenie

Copy link
Copy Markdown
Contributor

I'm not in favor of users setting the lfs.ntlm config value. This is an extra configuration step that I'd like to avoid if possible. The 401 response from the API should tell you what it needs to authenticate. For instance, the spec says to send a header like WWW-Authenticate: Basic realm="myRealm". What if the LFS server could send back WWW-Authenticate: NTLM or something?

Also, I think instead of lfs.ntlm, we could have a configurable auth type:

$ git config lfs.auth [ ntlm | basic ]

Note to self: the current API probably isn't returning WWW-Authenticate. I think it only really matters for web browsers, but we should include it in the spec anyway.

@technoweenie

Copy link
Copy Markdown
Contributor

Noticed that the ntlm spec you linked uses that header too:

    2: C <--  S   401 Unauthorized
                  WWW-Authenticate: NTLM

@WillHipschman

Copy link
Copy Markdown
Author

Definitely agree with deciding the auth type based on the server response. So we then have:

  1. The client is configured by default to use basic auth using the lfs.auth switch. If we see an NTLM server response during this time we can fault into NTLM mode (or should we fail?)
  2. If the user sets their client to use NTLM using the lfs.auth switch we immediately go into ntlm mode and skip the extra hop.

@technoweenie

Copy link
Copy Markdown
Contributor

The batch API client should automatically skip this extra hop (if you're referring to the initial auth-less request that returns 401). Check out the PrivateAccess() and SetPrivateAccess() methods.

Maybe we can set lfs.{endpoint}.access to basic or ntlm, instead of private. The fact that it requires any auth at all means it's not public.

@whoisj

whoisj commented Aug 31, 2015

Copy link
Copy Markdown

For performance reasons, it would be nice to have the optional config which says "hey, I know this will be NTLM so skip the failed auth challenge and proceed directly to Go and collection $200".

This can be hyper critical in fast build scenarios where build machines do not have branch or even repo affinity.

@technoweenie

Copy link
Copy Markdown
Contributor

@whoisj The batch API client already uses the lfs.{endpoint}.access git config key for that. Check out my previous reply.

@WillHipschman

Copy link
Copy Markdown
Author

I agree we can use the lfs.{endpoint}.access key. The hop I'm referring to is below.

Without ntlm set

1: C  --> S   GET ...   (This request is unnecessary if we know we are ntlm)
2: C <--  S   401 Unauthorized
              WWW-Authenticate: NTLM
3: C  --> S   GET ...
              Authorization: NTLM <base64-encoded type-1-message>
4: C <--  S   401 Unauthorized
              WWW-Authenticate: NTLM <base64-encoded type-2-message>
5: C  --> S   GET ...
              Authorization: NTLM <base64-encoded type-3-message>
6: C <--  S   200 Ok

With ntlm set

1: C  --> S   GET ...
              Authorization: NTLM <base64-encoded type-1-message>
2: C <--  S   401 Unauthorized
              WWW-Authenticate: NTLM <base64-encoded type-2-message>
3: C  --> S   GET ...
              Authorization: NTLM <base64-encoded type-3-message>
4: C <--  S   200 Ok

@WillHipschman

Copy link
Copy Markdown
Author

It's also worth noting that once we do the above exchange once, every request sent through that same httpClient won't have to re-authenticate, so this will be efficient from a batching perspective.

@technoweenie

Copy link
Copy Markdown
Contributor

Yes, that's handled here.

@technoweenie

Copy link
Copy Markdown
Contributor

I added a new LFS-Authenticate header to the API spec in #599. This should make the client forward compatible with NTLM and other potential authentication methods. We're purposely not using WWW-Authenticate for browser security reasons. With that, the flow should look like this:

# with no lfs.{endpoint}.access value
1: C  --> S   GET ...
2: C <--  S   401 Unauthorized
              LFS-Authenticate: NTLM
3: C  --> S   GET ...
              Authorization: NTLM <base64-encoded type-1-message>
4: C <--  S   401 Unauthorized
              WWW-Authenticate: NTLM <base64-encoded type-2-message>
5: C  --> S   GET ...
              Authorization: NTLM <base64-encoded type-3-message>
6: C <--  S   200 Ok

# with lfs.{endpoint}.access == "ntlm"
1: C  --> S   GET ...
              Authorization: NTLM <base64-encoded type-1-message>
2: C <--  S   401 Unauthorized
              WWW-Authenticate: NTLM <base64-encoded type-2-message>
3: C  --> S   GET ...
              Authorization: NTLM <base64-encoded type-3-message>
4: C <--  S   200 Ok

If the go package can work with LFS-Authenticate, I think that'd be preferable. But it's not worth forking it or adding some config value that only we'd ever use.

This was referenced Sep 1, 2015
@WillHipschman

Copy link
Copy Markdown
Author

I've updated the proposal to include the lfs.{endpoint}.access scheme and included info on storing usernames.

Why can't we use Www-Authenticate? It's specific to the NTLM protocol, so I really don't think we should change it.

@technoweenie

Copy link
Copy Markdown
Contributor

Why can't we use Www-Authenticate?

Browser security stuff. We don't want LFS API urls triggering login popups in browsers.

@WillHipschman WillHipschman mentioned this pull request Oct 6, 2015
@technoweenie

Copy link
Copy Markdown
Contributor

Closing this since we merged #714 🤘

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