<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>3.14 身份验证 on 编程那些事儿</title><link>https://before80.github.io/prgms/tools/uv/concepts/authentication/</link><description>Recent content in 3.14 身份验证 on 编程那些事儿</description><generator>Hugo</generator><language>zh-cn</language><lastBuildDate>Fri, 25 Sep 2026 21:01:20 +0800</lastBuildDate><atom:link href="https://before80.github.io/prgms/tools/uv/concepts/authentication/index.xml" rel="self" type="application/rss+xml"/><item><title>3.14.1 `uv auth` CLI</title><link>https://before80.github.io/prgms/tools/uv/concepts/authentication/3.14.1-cli/</link><pubDate>Fri, 25 Sep 2026 19:02:24 +0800</pubDate><guid>https://before80.github.io/prgms/tools/uv/concepts/authentication/3.14.1-cli/</guid><description>&lt;blockquote&gt;
&lt;p&gt;原文链接: &lt;a href="https://docs.astral.sh/uv/concepts/authentication/cli/"&gt;https://docs.astral.sh/uv/concepts/authentication/cli/&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;
&lt;h1 id="3141-uv-auth-cli"&gt;3.14.1 &lt;code&gt;uv auth&lt;/code&gt; CLI&lt;/h1&gt;
&lt;p&gt;uv 提供了用于存储和获取各服务凭据的高层接口。&lt;/p&gt;
&lt;h2 id="登录服务"&gt;登录服务&lt;/h2&gt;
&lt;p&gt;要为某个服务添加凭据，请使用 &lt;code&gt;uv auth login&lt;/code&gt; 命令：&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;div style="color:#b0c4de;background-color:#282c34;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;
&lt;table style="border-spacing:0;padding:0;margin:0;border:0;"&gt;&lt;tr&gt;&lt;td style="vertical-align:top;padding:0;margin:0;border:0;"&gt;
&lt;pre tabindex="0" style="color:#b0c4de;background-color:#282c34;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code&gt;&lt;span style="white-space:pre;-webkit-user-select:none;user-select:none;margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#58626f"&gt;1
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;
&lt;td style="vertical-align:top;padding:0;margin:0;border:0;;width:100%"&gt;
&lt;pre tabindex="0" style="color:#b0c4de;background-color:#282c34;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-console" data-lang="console"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#a6e22e"&gt;$&lt;/span&gt; uv auth login example.com
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;/div&gt;&lt;p&gt;它会提示输入凭据。&lt;/p&gt;
&lt;p&gt;凭据也可以通过 &lt;code&gt;--username&lt;/code&gt; 和 &lt;code&gt;--password&lt;/code&gt; 选项提供；对于使用 &lt;code&gt;__token__&lt;/code&gt; 或任意用户名的服务，可以使用 &lt;code&gt;--token&lt;/code&gt; 选项。&lt;/p&gt;</description></item><item><title>3.14.2 HTTP 身份验证</title><link>https://before80.github.io/prgms/tools/uv/concepts/authentication/3.14.2-http/</link><pubDate>Fri, 25 Sep 2026 19:02:24 +0800</pubDate><guid>https://before80.github.io/prgms/tools/uv/concepts/authentication/3.14.2-http/</guid><description>&lt;blockquote&gt;
&lt;p&gt;原文链接: &lt;a href="https://docs.astral.sh/uv/concepts/authentication/http/"&gt;https://docs.astral.sh/uv/concepts/authentication/http/&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;
&lt;h1 id="3142-http-身份验证"&gt;3.14.2 HTTP 身份验证&lt;/h1&gt;
&lt;p&gt;查询包仓库时，uv 支持通过 HTTP 提供凭据。&lt;/p&gt;
&lt;p&gt;身份验证可以来自以下来源，按优先级排序：&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;URL，例如 &lt;code&gt;https://&amp;lt;user&amp;gt;:&amp;lt;password&amp;gt;@&amp;lt;hostname&amp;gt;/...&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="#netrc-files"&gt;netrc&lt;/a&gt; 配置文件&lt;/li&gt;
&lt;li&gt;uv 凭据存储&lt;/li&gt;
&lt;li&gt;&lt;a href="#keyring-providers"&gt;keyring 提供程序&lt;/a&gt;（默认关闭）&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;身份验证可以用于以下场景中指定的主机：&lt;/p&gt;</description></item><item><title>3.14.3 Git 身份验证</title><link>https://before80.github.io/prgms/tools/uv/concepts/authentication/3.14.3-git/</link><pubDate>Fri, 25 Sep 2026 19:02:24 +0800</pubDate><guid>https://before80.github.io/prgms/tools/uv/concepts/authentication/3.14.3-git/</guid><description>&lt;blockquote&gt;
&lt;p&gt;原文链接: &lt;a href="https://docs.astral.sh/uv/concepts/authentication/git/"&gt;https://docs.astral.sh/uv/concepts/authentication/git/&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;
&lt;h1 id="3143-git-身份验证"&gt;3.14.3 Git 身份验证&lt;/h1&gt;
&lt;p&gt;uv 允许通过 SSH 或 HTTP 身份验证从私有 Git 仓库安装包。&lt;/p&gt;
&lt;h2 id="ssh-身份验证"&gt;SSH 身份验证&lt;/h2&gt;
&lt;p&gt;要使用 SSH 密钥进行身份验证，请使用 &lt;code&gt;ssh://&lt;/code&gt; 协议：&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;git+ssh://git@&amp;lt;hostname&amp;gt;/...&lt;/code&gt;（例如 &lt;code&gt;git+ssh://git@github.com/astral-sh/uv&lt;/code&gt;）&lt;/li&gt;
&lt;li&gt;&lt;code&gt;git+ssh://git@&amp;lt;host&amp;gt;/...&lt;/code&gt;（例如 &lt;code&gt;git+ssh://git@github.com-key-2/astral-sh/uv&lt;/code&gt;）&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;SSH 身份验证要求使用用户名 &lt;code&gt;git&lt;/code&gt;。&lt;/p&gt;</description></item><item><title>3.14.4 TLS 证书</title><link>https://before80.github.io/prgms/tools/uv/concepts/authentication/3.14.4-certificates/</link><pubDate>Fri, 25 Sep 2026 19:02:24 +0800</pubDate><guid>https://before80.github.io/prgms/tools/uv/concepts/authentication/3.14.4-certificates/</guid><description>&lt;blockquote&gt;
&lt;p&gt;原文链接: &lt;a href="https://docs.astral.sh/uv/concepts/authentication/certificates/"&gt;https://docs.astral.sh/uv/concepts/authentication/certificates/&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;
&lt;h1 id="3144-tls-证书"&gt;3.14.4 TLS 证书&lt;/h1&gt;
&lt;p&gt;uv 使用 TLS 与包索引和其他 HTTPS 服务器安全通信。TLS 证书用于验证这些服务器的身份，确保连接不会被拦截。&lt;/p&gt;
&lt;h2 id="tls-后端"&gt;TLS 后端&lt;/h2&gt;
&lt;p&gt;uv 使用 &lt;a href="https://github.com/rustls/rustls"&gt;&lt;code&gt;rustls&lt;/code&gt;&lt;/a&gt;（用 Rust 编写的内存安全 TLS 实现），并以 &lt;a href="https://github.com/aws/aws-lc-rs"&gt;&lt;code&gt;aws-lc-rs&lt;/code&gt;&lt;/a&gt; 作为加密提供程序。&lt;/p&gt;</description></item><item><title>3.14.5 第三方服务</title><link>https://before80.github.io/prgms/tools/uv/concepts/authentication/3.14.5-third-party/</link><pubDate>Fri, 25 Sep 2026 19:02:24 +0800</pubDate><guid>https://before80.github.io/prgms/tools/uv/concepts/authentication/3.14.5-third-party/</guid><description>&lt;blockquote&gt;
&lt;p&gt;原文链接: &lt;a href="https://docs.astral.sh/uv/concepts/authentication/third-party/"&gt;https://docs.astral.sh/uv/concepts/authentication/third-party/&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;
&lt;h1 id="3145-第三方服务"&gt;3.14.5 第三方服务&lt;/h1&gt;
&lt;h2 id="使用替代包索引进行身份验证"&gt;使用替代包索引进行身份验证&lt;/h2&gt;
&lt;p&gt;关于使用流行的替代 Python 包索引进行身份验证，请参阅专门的指南：&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="../../guides/2.7-integration/2.7.10-azure/"&gt;Azure Artifacts&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="../../guides/2.7-integration/2.7.11-google/"&gt;Google Artifact Registry&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="../../guides/2.7-integration/2.7.12-aws/"&gt;AWS CodeArtifact&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="../../guides/2.7-integration/2.7.13-jfrog/"&gt;JFrog Artifactory&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id="hugging-face-支持"&gt;Hugging Face 支持&lt;/h2&gt;
&lt;p&gt;uv 支持对 Hugging Face Hub 的自动身份验证。具体来说，如果设置了 &lt;code&gt;HF_TOKEN&lt;/code&gt; 环境变量，uv 会把它传播到对 &lt;code&gt;huggingface.co&lt;/code&gt; 的请求中。&lt;/p&gt;</description></item></channel></rss>