Impossible to push to Azure repository using Person Access Token
Dieses Issue hat noch niemand übernommen.
Bewertung
- Schwierigkeit
- 3/5
- Geschätzter Aufwand
- 1-2 Tage
- Anfängerfreundlichkeit
- 25/100
- Issue-Typ
- Feature
- Klarheit
- Klar beschrieben
- Aktivitätsstatus
- Veraltet
- Tech-Stack
- azure, csharp, git
- Bereich
- authentication, devtools
Rechercherichtung
Beginne damit, PushOptions zu überprüfen und die verfügbaren Konfigurationsoptionen mit FetchOptions zu vergleichen. Lies anschließend Pull Request #2011 und das git-push-Wiki-Beispiel. Die Arbeit ist abgeschlossen, wenn beim Pushen in ein Azure-Repository der PAT als benutzerdefinierter Authorization-Header übergeben werden kann, ohne dass Fehler durch die Wiederholung der Authentifizierung auftreten; füge relevante Tests hinzu oder aktualisiere sie, falls das vorhandene Subsystem solche Tests bereitstellt.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Beschreibung
My problem is described perfectly here, but I don't think the solution is the correct one, since that would use the credentials stored on the computer as far as I'm aware.
When making git requests to an azure repository with a PAT, it is expected to be passed along as a custom header. (see documentation).
This is possible when doing a Clone operation, since CloneOptions contains FetchOptions, which allows us to set custom headers.
So a clone is perfectly possible as follows:
string encodedToken = Convert.ToBase64String(Encoding.UTF8.GetBytes($":{credentials.PersonalAccessToken}"));
var fetchOptions = new FetchOptions
{
CustomHeaders = new[] {
$"Authorization: Basic {encodedToken}"
}
};
var options = new CloneOptions
{
CredentialsProvider = (url, usernameFromUrl, types) =>
new UsernamePasswordCredentials()
{
Username = credentials.UserName,
Password = credentials.PersonalAccessToken
},
FetchOptions = fetchOptions,
BranchName = branchName,
Checkout = true,
OnCheckoutProgress = (path, completedSteps, totalSteps) =>
Logger.LogInformation("Clone progress {completed} / {total}", completedSteps, totalSteps),
RepositoryOperationCompleted = (context) =>
Logger.LogInformation("Clone completed"),
};
Repository.Clone(Remote, WorkingDirectory, options);
However, when trying to push to this same repository, PushOptions does not expose something similar to include the PAT as header, even though it is stored in the internal data structure since https://github.com/libgit2/libgit2sharp/pull/1233 .
Using the provided example from the wiki
I get the following error:
Unhandled exception: too many redirects or authentication replays | LibGit2Sharp.LibGit2SharpException | too many redirects or authentication replays
Which is the exact same error I was getting when trying to clone without the added custom header.
As far as I can see, there is a PR open that would fix this, but it is not yet merged in: https://github.com/libgit2/libgit2sharp/pull/2011
- Vorherrschende Sprache
- C#
- Sterne
- 3.5k
- Forks
- 925
- PR-Merge-Kennzahlen
- Keine gemergten PRs in 30 T.
Beitragsleitfaden
Erste Schritte
- Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
- Forken Sie das Repository und arbeiten Sie in einem Branch.
- Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.
Mehr aus libgit2/libgit2sharp
-
Schwierigkeit 4/5 3-5 Tage Anfängerfreundlichkeit 52/100
libgit2/libgit2sharp#2193 · 2 Kommentare ·
-
Schwierigkeit 4/5 3-5 Tage Anfängerfreundlichkeit 38/100
libgit2/libgit2sharp#2192 · 1 Kommentar ·
-
Website is down Offen
Schwierigkeit 4/5 3-5 Tage Anfängerfreundlichkeit 20/100
libgit2/libgit2sharp#2191 · 2 Reaktionen ·
-
Schwierigkeit 3/5 1-2 Tage Anfängerfreundlichkeit 68/100
libgit2/libgit2sharp#2189 · 1 Reaktion ·
-
Schwierigkeit 3/5 1-2 Tage Anfängerfreundlichkeit 35/100
libgit2/libgit2sharp#2187 · 2 Kommentare ·
Alle Issues in libgit2/libgit2sharp
Ähnliche Issues
-
:watch: Not Triaged dotnet-fsharp/svc
Schwierigkeit 1/5 Unter einer Stunde Anfängerfreundlichkeit 90/100
-
Client customer-reported needs-team-attention question Service Attention WebPubSub
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 76/100
Azure/azure-sdk-for-net#63292 · 3 Kommentare · 1 Reaktion ·
-
Issue-Enhancement Needs-Triage
Schwierigkeit 1/5 Unter einer Stunde Anfängerfreundlichkeit 86/100
PowerShell/PowerShell#28061 · 2 Reaktionen ·
-
dependencies needs-team-triage server-Azure.Mcp
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 72/100
-
aspnet-core/svc aspnetcore-signalr/subsvc doc-enhancement Pri2 SignalR
Schwierigkeit 1/5 Unter einer Stunde Anfängerfreundlichkeit 88/100
dotnet/AspNetCore.Docs#37729 ·