Skip to content

Repository.ListRemoteReferences needs CustomHeaders setting option #2136

Open
@rmadani

Description

@rmadani

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

changed the title [-]Repository.ListRemoteReferences needs CustomHeader setting optipn[/-] [+]Repository.ListRemoteReferences needs CustomHeaders setting option[/+] on Dec 26, 2024
ethomson

ethomson commented on Dec 27, 2024

@ethomson
Member

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

rmadani commented on Dec 27, 2024

@rmadani
Author
ethomson

ethomson commented on Dec 30, 2024

@ethomson
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.

rmadani

rmadani commented on Jan 9, 2025

@rmadani
Author
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @ethomson@rmadani

        Issue actions

          Repository.ListRemoteReferences needs CustomHeaders setting option · Issue #2136 · libgit2/libgit2sharp