Skip to content

Conversation

@jeffhostetler
Copy link

Fix NTLM support in gvfs-helper.

NTLM is handled magically by libcurl when we CURLAUTH_ANY is enabled AND
we passed empty username/password. This lets it negotiate with the server and
choose the best authentication scheme.

Signed-off-by: Jeff Hostetler jeffhost@microsoft.com

Signed-off-by: Jeff Hostetler <jeffhost@microsoft.com>
gvfs-helper.c Outdated
* (because the cache-server doesn't support it).
*/
curl_easy_setopt(slot->curl, CURLOPT_HTTPAUTH, CURLAUTH_ANY);
curl_easy_setopt(slot->curl, CURLOPT_USERPWD, ":");

Choose a reason for hiding this comment

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

We'll want to verify that this doesn't make the cache server OR cloud situation break. I wonder if there is anything we can do to tell if we are against the on-prem server or not.

An installer is sent to the customer, which should help.

Copy link
Author

Choose a reason for hiding this comment

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

Yeah, however, the cache server never sends back 401s,
only a generic 400 Bad Request (with a human-readable
"creds required" message in the html body (sigh)). So the
cache server will never trigger the 401 logic inside libcurl.
So I think this change is net-neutral WRT the cache servers.

But now that you say that, I am tempted to move the cache
server case into its own branch (and kill the TODO comment).

A larger take-away here is that cache servers (that require
auth) won't work with origin servers that use NTLM.

I'll fix this up and submit another version shortly.

gvfs-helper.c Outdated
*
* TODO Think about if we really need to handle this case.
* TODO Guard with "if (params->sever_type == __MAIN)"
* Set an empty u/p to get CURL to automatically negotiate
Copy link
Member

Choose a reason for hiding this comment

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

Source context (because GitHub doesn't let you comment on lines outside the default context): this change is in the else part of the if (creds && creds->username) control flow statement.

What happens if creds->username is NULL and creds->password != NULL?
We'll fall into this CURLAUTH_ANY flow.. what if users have manually specified a PAT as the password without a username? I.e., ":password123"

Copy link
Author

Choose a reason for hiding this comment

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

Good question. I was modeling this on how they set this up in [1].
But, you're right, PATs work with an empty username [2].

I should update this to allow either to be set and route us into
Basic auth. (The assumption is that if GCM chooses NTLM,
it'll send back empty strings for both. (I also wonder how all
of this works with Kerberos/GSSNegotiate, but that's for another
day.))

[1] https://github.com/microsoft/git/blob/vfs-2.26.1/http.c#L485

[2] https://docs.microsoft.com/en-us/azure/devops/organizations/accounts/use-personal-access-tokens-to-authenticate?view=azure-devops&tabs=preview-page

Signed-off-by: Jeff Hostetler <jeffhost@microsoft.com>
@jeffhostetler
Copy link
Author

Version 2 moves most of the server-specific code into helper functions and
tries to explain everything that I could think of. Actual code path should be
pretty identical (effectively).

@jeffhostetler
Copy link
Author

I'm tempted to leave this as 2 commits. 1 to show the actual functional fix to make NTLM work. And the second to better explain why. But I'm open to suggestion.

Copy link

@derrickstolee derrickstolee left a comment

Choose a reason for hiding this comment

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

Customer reports this does solve their issue. Thanks!

@derrickstolee derrickstolee merged commit 5f1edfa into microsoft:vfs-2.26.2 May 1, 2020
@jeffhostetler
Copy link
Author

Great! Thanks!

@jeffhostetler jeffhostetler deleted the gvfs-helper-ntlm branch May 1, 2020 17:29
dscho pushed a commit that referenced this pull request May 20, 2020
Fix NTLM support in gvfs-helper.

NTLM is handled magically by libcurl when we CURLAUTH_ANY is enabled AND
we passed empty username/password. This lets it negotiate with the server and
choose the best authentication scheme.
dscho pushed a commit that referenced this pull request May 20, 2020
Fix NTLM support in gvfs-helper.

NTLM is handled magically by libcurl when we CURLAUTH_ANY is enabled AND
we passed empty username/password. This lets it negotiate with the server and
choose the best authentication scheme.
derrickstolee added a commit that referenced this pull request Jun 1, 2020
Fix NTLM support in gvfs-helper.

NTLM is handled magically by libcurl when we CURLAUTH_ANY is enabled AND
we passed empty username/password. This lets it negotiate with the server and
choose the best authentication scheme.
derrickstolee added a commit that referenced this pull request Jul 20, 2020
Fix NTLM support in gvfs-helper.

NTLM is handled magically by libcurl when we CURLAUTH_ANY is enabled AND
we passed empty username/password. This lets it negotiate with the server and
choose the best authentication scheme.
derrickstolee added a commit that referenced this pull request Jul 27, 2020
Fix NTLM support in gvfs-helper.

NTLM is handled magically by libcurl when we CURLAUTH_ANY is enabled AND
we passed empty username/password. This lets it negotiate with the server and
choose the best authentication scheme.
derrickstolee added a commit that referenced this pull request Jul 28, 2020
Fix NTLM support in gvfs-helper.

NTLM is handled magically by libcurl when we CURLAUTH_ANY is enabled AND
we passed empty username/password. This lets it negotiate with the server and
choose the best authentication scheme.
derrickstolee added a commit that referenced this pull request Oct 6, 2020
Fix NTLM support in gvfs-helper.

NTLM is handled magically by libcurl when we CURLAUTH_ANY is enabled AND
we passed empty username/password. This lets it negotiate with the server and
choose the best authentication scheme.
derrickstolee added a commit that referenced this pull request Oct 6, 2020
Fix NTLM support in gvfs-helper.

NTLM is handled magically by libcurl when we CURLAUTH_ANY is enabled AND
we passed empty username/password. This lets it negotiate with the server and
choose the best authentication scheme.
dscho pushed a commit that referenced this pull request Oct 6, 2020
Fix NTLM support in gvfs-helper.

NTLM is handled magically by libcurl when we CURLAUTH_ANY is enabled AND
we passed empty username/password. This lets it negotiate with the server and
choose the best authentication scheme.
derrickstolee added a commit that referenced this pull request Oct 9, 2020
Fix NTLM support in gvfs-helper.

NTLM is handled magically by libcurl when we CURLAUTH_ANY is enabled AND
we passed empty username/password. This lets it negotiate with the server and
choose the best authentication scheme.
derrickstolee added a commit that referenced this pull request Oct 9, 2020
Fix NTLM support in gvfs-helper.

NTLM is handled magically by libcurl when we CURLAUTH_ANY is enabled AND
we passed empty username/password. This lets it negotiate with the server and
choose the best authentication scheme.
derrickstolee added a commit that referenced this pull request Oct 16, 2020
Fix NTLM support in gvfs-helper.

NTLM is handled magically by libcurl when we CURLAUTH_ANY is enabled AND
we passed empty username/password. This lets it negotiate with the server and
choose the best authentication scheme.
derrickstolee added a commit that referenced this pull request Oct 19, 2020
Fix NTLM support in gvfs-helper.

NTLM is handled magically by libcurl when we CURLAUTH_ANY is enabled AND
we passed empty username/password. This lets it negotiate with the server and
choose the best authentication scheme.
mjcheetham pushed a commit that referenced this pull request Dec 15, 2020
Fix NTLM support in gvfs-helper.

NTLM is handled magically by libcurl when we CURLAUTH_ANY is enabled AND
we passed empty username/password. This lets it negotiate with the server and
choose the best authentication scheme.
mjcheetham pushed a commit that referenced this pull request Dec 15, 2020
Fix NTLM support in gvfs-helper.

NTLM is handled magically by libcurl when we CURLAUTH_ANY is enabled AND
we passed empty username/password. This lets it negotiate with the server and
choose the best authentication scheme.
dscho pushed a commit that referenced this pull request Dec 18, 2020
Fix NTLM support in gvfs-helper.

NTLM is handled magically by libcurl when we CURLAUTH_ANY is enabled AND
we passed empty username/password. This lets it negotiate with the server and
choose the best authentication scheme.
dscho pushed a commit that referenced this pull request Dec 24, 2020
Fix NTLM support in gvfs-helper.

NTLM is handled magically by libcurl when we CURLAUTH_ANY is enabled AND
we passed empty username/password. This lets it negotiate with the server and
choose the best authentication scheme.
dscho pushed a commit that referenced this pull request Dec 28, 2020
Fix NTLM support in gvfs-helper.

NTLM is handled magically by libcurl when we CURLAUTH_ANY is enabled AND
we passed empty username/password. This lets it negotiate with the server and
choose the best authentication scheme.
dscho pushed a commit that referenced this pull request Mar 4, 2021
Fix NTLM support in gvfs-helper.

NTLM is handled magically by libcurl when we CURLAUTH_ANY is enabled AND
we passed empty username/password. This lets it negotiate with the server and
choose the best authentication scheme.
dscho pushed a commit that referenced this pull request Mar 4, 2021
Fix NTLM support in gvfs-helper.

NTLM is handled magically by libcurl when we CURLAUTH_ANY is enabled AND
we passed empty username/password. This lets it negotiate with the server and
choose the best authentication scheme.
dscho pushed a commit that referenced this pull request Mar 4, 2021
Fix NTLM support in gvfs-helper.

NTLM is handled magically by libcurl when we CURLAUTH_ANY is enabled AND
we passed empty username/password. This lets it negotiate with the server and
choose the best authentication scheme.
dscho pushed a commit that referenced this pull request Mar 5, 2021
Fix NTLM support in gvfs-helper.

NTLM is handled magically by libcurl when we CURLAUTH_ANY is enabled AND
we passed empty username/password. This lets it negotiate with the server and
choose the best authentication scheme.
dscho pushed a commit that referenced this pull request Mar 8, 2021
Fix NTLM support in gvfs-helper.

NTLM is handled magically by libcurl when we CURLAUTH_ANY is enabled AND
we passed empty username/password. This lets it negotiate with the server and
choose the best authentication scheme.
jeffhostetler pushed a commit that referenced this pull request Mar 15, 2021
Fix NTLM support in gvfs-helper.

NTLM is handled magically by libcurl when we CURLAUTH_ANY is enabled AND
we passed empty username/password. This lets it negotiate with the server and
choose the best authentication scheme.
jeffhostetler pushed a commit that referenced this pull request Mar 16, 2021
Fix NTLM support in gvfs-helper.

NTLM is handled magically by libcurl when we CURLAUTH_ANY is enabled AND
we passed empty username/password. This lets it negotiate with the server and
choose the best authentication scheme.
derrickstolee added a commit that referenced this pull request May 17, 2021
Fix NTLM support in gvfs-helper.

NTLM is handled magically by libcurl when we CURLAUTH_ANY is enabled AND
we passed empty username/password. This lets it negotiate with the server and
choose the best authentication scheme.
derrickstolee added a commit that referenced this pull request May 17, 2021
Fix NTLM support in gvfs-helper.

NTLM is handled magically by libcurl when we CURLAUTH_ANY is enabled AND
we passed empty username/password. This lets it negotiate with the server and
choose the best authentication scheme.
derrickstolee added a commit that referenced this pull request May 17, 2021
Fix NTLM support in gvfs-helper.

NTLM is handled magically by libcurl when we CURLAUTH_ANY is enabled AND
we passed empty username/password. This lets it negotiate with the server and
choose the best authentication scheme.
dscho pushed a commit that referenced this pull request May 21, 2021
Fix NTLM support in gvfs-helper.

NTLM is handled magically by libcurl when we CURLAUTH_ANY is enabled AND
we passed empty username/password. This lets it negotiate with the server and
choose the best authentication scheme.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants