Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Repository.ListRemoteReferences needs CustomHeaders setting option #2136

Open
rmadani opened this issue Dec 26, 2024 · 3 comments
Open

Repository.ListRemoteReferences needs CustomHeaders setting option #2136

rmadani opened this issue Dec 26, 2024 · 3 comments

Comments

@rmadani
Copy link

rmadani commented Dec 26, 2024

Similar to FetchOptions used for PullOptions, CloneOptions or PushOptions, Repository.ListRemoteReferences needs to somehow expose a CustomHeaders option. Without it, a request to an on-premise Azure DevOps Server (in my case version 2020), throws the following exception using a Personal Access Token for authentication.

Unhandled exception: too many redirects or authentication replays | LibGit2Sharp.LibGit2SharpException | too many redirects or authentication replays

CustomHeaders are needed to enforce Basic Authorization.

Thank you.

@rmadani rmadani changed the title Repository.ListRemoteReferences needs CustomHeader setting optipn Repository.ListRemoteReferences needs CustomHeaders setting option Dec 26, 2024
@ethomson
Copy link
Member

ethomson commented Dec 27, 2024

You're welcome to use custom headers to pass information to the server, but I don't think that I understand. Because you don't need to use custom headers for authentication. You're welcome to use a personal access token using basic authentication. Just set it in the username and password information.

You can treat them as if they were a username/password combination. This is what I do, and this is how we intended you to use personal access tokens when we added them to Azure DevOps.

@rmadani
Copy link
Author

rmadani commented Dec 27, 2024 via email

@ethomson
Copy link
Member

Thanks... I wonder if the problem here is that you're using an on-premises Azure DevOps Server instance, which supports both NTLM and Basic authentication. Our authentication stack prefers NTLM but if you're using a PAT, you can't use NTLM.

This is a bit of an odd case. If you (meaning, the Azure DevOps Server) specify that you allow both NTLM and Basic, then there's no mechanism to say which mechanism maps to which set of credentials. 🥴

Probably we need to be able to provide users the ability to specify not just the credentials but also the mechanisms that the credentials are supported for. That would let you pass UsernamePasswordCredentials but also indicate that they're for Basic authentication. This is a bit of a shitty leaky abstraction, but probably the sensible thing to do. Or we could drop NTLM support and just always use HTTP Basic, which might also be the sensible thing to do, if Microsoft is pushing even on-prem users to create PATs. I'll investigate.

We should also allow the CustomHeaders option to work here, but that's a tactical fix and I'm more interested in what the right long-term plan looks like.

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

No branches or pull requests

2 participants