libgit2 / libgit2/libgit2sharp
Credentials being cached between requests to separate remotes with the same URL
まだ誰も着手していません。
- 主要言語
- C#
- スター
- 3.5k
- フォーク
- 925
- PR マージ指標
- 30日以内にマージされた PR はありません
説明
The current implementation of ManagedHttpSmartSubtransportStream uses a static CredentialCache. The credentials in this cache are only differentiated by URL and authentication scheme, if you have two separate repositories configured with the same URL, it's possible to authenticate to a repository without providing valid credentials.
Reproduction steps
using System;
using System.Net;
using LibGit2Sharp;
namespace Example
{
class Program
{
static void Main(string[] args)
{
var uri = "<repository URL>";
var repo1 = Repository.Clone(uri, "directory1", new CloneOptions
{
BranchName = "main",
CredentialsProvider = CredentialsHandlerThatReturnsValidCredentials
}); // This will succeed
var repo2 = Repository.Clone(uri, "directory2", new CloneOptions
{
BranchName = "main",
CredentialsProvider = CredentialHandlerThatReturnsInvalidCredentials
}); // Invalid credential provider is never called, cached credentials from the first request are used
}
public static Credentials CredentialsHandlerThatReturnsValidCredentials(string url, string usernameFromUrl,
SupportedCredentialTypes types)
{
return new UsernamePasswordCredentials
{
Username = "<valid username>",
Password = "<valid password>"
};
}
public static Credentials CredentialHandlerThatReturnsInvalidCredentials(string url, string usernameFromUrl,
SupportedCredentialTypes types)
{
return new UsernamePasswordCredentials
{
Username = "invalid username",
Password = "invalid password"
};
}
}
}
Expected behavior
Second clone should not authenticate, invalid credentials supplied.
Actual behavior
Authenticates with repository successfully, as there has already been a successful authentication to that repository URL.
Version of LibGit2Sharp (release number or SHA1)
0.27.0-preview-0102
Operating system(s) tested; .NET runtime tested
macOS, .NET 5
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
LibGit2Sharp/Core/ManagedHttpSmartSubtransport.cs から始め、特に ManagedHttpSmartSubtransportStream が使用する static CredentialCache を確認します。同じ URL と別々の credential provider を使って 2 つの clone を再現し、2 番目の provider が呼び出されること、および無効な認証情報では認証に成功しないことを確認します。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- csharp, git
- 領域
- authentication, security
- issue の種類
- バグ
- 難易度
- 3/5
- 見積もり時間
- 1〜2日
- 活発さ
- 停滞
- 明瞭さ
- 明確に書かれている
- 初心者へのやさしさ
- 50/100