Open
Description
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.
Activity
[-]Repository.ListRemoteReferences needs CustomHeader setting optipn[/-][+]Repository.ListRemoteReferences needs CustomHeaders setting option[/+]ethomson commentedon 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 commentedon Dec 27, 2024
ethomson commentedon Dec 30, 2024
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 forBasic
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.rmadani commentedon Jan 9, 2025