我已經在網上搜索并沒有找到明確的答案,所以也許這里有人可以幫助我理解。
總結問題
- 事實 1
Git Credential Manager (GCM) 是另一種安全存盤憑據并通過 HTTPS 連接到 GitHub 的方法。使用 GCM,您不必手動創建和存盤 PAT,因為 GCM 代表您管理身份驗證,包括 2FA(雙因素身份驗證)。
- 事實 2
如果您在沒有 GitHub CLI 的情況下進行身份驗證,則必須使用個人訪問令牌進行身份驗證。當 Git 提示您輸入密碼時,請輸入您的個人訪問令牌 (PAT)。Git 的基于密碼的身份驗證已被洗掉,使用 PAT 更加安全。有關詳細資訊,請參閱“創建個人訪問令牌”。每次您使用 Git 向 GitHub 進行身份驗證時,系統都會提示您輸入憑據以向 GitHub 進行身份驗證,除非您將它們快取為憑據幫助程式。
我對上面的粗線非常感興趣:
GCM(核心)如何代表我“管理”身份驗證,而無需我手動創建 PAT?
我試圖使問題簡短而準確,但我將嘗試在這里詳細說明:我嘗試使用 GIT for Windows(最新版本)以及 VS 2022 附帶的 GIT。兩者都是最新的并使用Credential Manager Core的最新版本,這是 GitHub 的新(自 2021 年以來)策略所必需的,不再允許 acc/pw 并且身份驗證現在需要使用 PAT。但是,我想知道 GCM 是如何神奇地作業的,而無需在 GitHub 設定中手動創建 PAT(請參閱鏈接)。從上述文章中,我強烈假設 Windows 憑據管理器擁有某種訪問令牌(甚至可能是 acc/pw ???)。我希望能找到一些澄清。
-is the acc/pw stored or a token in the Windows Credential Manager (formerly aka Vault)? -where is the token coming from, if not manually created by user in GitHub (is there api/webservice from GitHub that is called by the GCM maybe??? if so, why do all those tutorials instruct to add PATs manually??? how would I be able to leverage the same functionality???)
Sidenotes:
All I ever did to authenticate GIT and VS was adding the GitHub account/pw into VS in the account section. After that, I never needed to type in username/pw OR any token at all. Neither for command line (portable) GIT (git-bash) nor for the VS included GIT.
I've checked the Windows Credential Manager passwords, to verify if they are indeed tokens or plain passwords. There's indeed some kind of access token (my pw is not saved there). But that's only half of my question. The more interesting part is actually, where does that token come from and how to get tokens from GitHub without manually creating them?! Moreover, what are the implications of that token (does it expire, when and so on...)
Additional sources, I searched:
Creating a personal access token
Authenticate with GitHub using a token
Support for password authentication was removed. Please use a personal access token instead
Only more mentions of manually created PATs... (exactly the opposite, from what is asked)
Authenticate with GitHub using a token
Support for password authentication was removed. Please use a personal access token instead
How to do git commit using personal access token?
Git 憑證管理器和手動創建的 PAT
將多個 git 個人訪問令牌 (PAT) 與憑據管理器一起使用
非常感謝大家!
uj5u.com熱心網友回復:
GitHub 個人訪問令牌只是 GitHub OAuth 令牌的一個特例。我不記得當前的 GCM Core 實作是如何作業的,因為我認為它與之前的 Core GCM 實作有所不同,但它基本上讓您登錄并執行某種 OAuth 流程來為您的帳戶頒發令牌。無論是實際的 PAT 還是不同型別的 OAuth 令牌都無關緊要,因為它們本質上是相同的。
GCM Core 可以將憑據存盤在多個位置,包括系統憑據存盤(取決于作業系統)。一旦它們被存盤,只要它們有效,Git 就會使用它們。
大多數教程建議自己生成 PAT 的原因是因為 GCM Core 雖然可用于多個平臺,但默認情況下不會在任何地方提供,除非作為 Windows 的 Git 的一部分。事實上,因為它是用 .NET 撰寫的,讓它在 macOS 和 Linux 上運行通常有點麻煩,因此通常使用其他憑證助手來代替。有些人還在 Windows 上使用不同的憑據管理器。大多數撰寫教程的人都希望提出普遍適用的建議,因此建議 PAT 是一種讓人們啟動和運行的簡單易行的方法。
如果您想做類似的事情來發布令牌,GitHub 提供了有關如何使用 OAuth 應用程式執行此操作的檔案。根據用戶授予的權限,這些令牌也可用于訪問 API(如果需要)。
轉載請註明出處,本文鏈接:https://www.uj5u.com/ruanti/449512.html
上一篇:AzureDevOpsYAMLPipelines:添加基于Git標記的條件
下一篇:VisualStudio2022git錯誤無法與{0}埠{1}協商:找不到匹配的主機密鑰型別。他們的提議:ssh-rsa
