访问需要基本身份验证的 Artifactory/Maven 存储库
我有一个 Artifactory 存储库,它支持基本身份验证。 我如何配置settings.xml以允许访问?
<mirrors>
<mirror>
<id>artifactory</id>
<mirrorOf>*</mirrorOf>
<url>https://myserver.example.com/artifactory/repo</url>
<name>Artifactory</name>
</mirror>
</mirrors>
<servers>
<!--
This server configuration gives your personal username/password for
artifactory. Note that the server id must match that given in the
mirrors section.
-->
<server>
<id>Artifactory</id>
<username>someArtifactoryUser</username>
<password>someArtifactoryPassword</password>
</server>
因此,服务器标签是人工用户的用户凭据,但我还需要提供另一个用户/密码来通过基本身份验证。 我会把它放在哪里?
I have an Artifactory repo that sits behind basic authentication. How would I configure the settings.xml to allow access?
<mirrors>
<mirror>
<id>artifactory</id>
<mirrorOf>*</mirrorOf>
<url>https://myserver.example.com/artifactory/repo</url>
<name>Artifactory</name>
</mirror>
</mirrors>
<servers>
<!--
This server configuration gives your personal username/password for
artifactory. Note that the server id must match that given in the
mirrors section.
-->
<server>
<id>Artifactory</id>
<username>someArtifactoryUser</username>
<password>someArtifactoryPassword</password>
</server>
So server tag is the user credentials for the artifactory user, but I also need to provide another user/password to get through the basic-auth. Where would I put that?!?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
用户名和密码将按照您的情况输入到服务器设置中。 我认为你的问题是你已经通过服务器的名称(Artifactory)而不是它的id(artifactory)指定了服务器。
我建议您将服务器设置放在用户设置中,而不是全局设置中。 您还可以在 Maven 2.1.0+ 中对密码进行加密,请参阅迷你指南< /a> 了解详细信息。
更新:您使用的是哪个版本的 Artifactory? 有 讨论和相应的问题基本-验证失败。 这显然已在 2.0.7 和 2.1.0 中得到修复。
从讨论来看,似乎 解决方法是通过命令行传递属性,例如
更新:要让您的 Maven 安装通过防火墙进行连接,您需要配置代理settings.xml 部分,请参阅此问题了解一些这样做的指示。
Update2:您可以在服务器设置中设置其他属性,请参阅此博客 了解一些背景信息。 我还没有机会对此进行测试,但是来自博客和相关http wagon javadoc,看来您可以在服务器设置上设置authenticationInfo,如下所示:
The username and password go in the server settings as you have them. I think your problem is that you've specified the server by its name (Artifactory), rather than its id (artifactory).
I'd recommend you put the server settings in your user settings rather than the global settings. You can also encrypt the password in Maven 2.1.0+, see the mini guide for details.
Update: What version of Artifactory are you using? There is a discussion and corresponding issue that basic-auth fails. This has apparently been fixed in 2.0.7 and 2.1.0.
From the discussion, it seems that a workaround is to pass the properties via the command line, e.g.
Update: To let your Maven installation connect through a firewall, you'll need to configure the proxy section of the settings.xml, see this question for some pointers on doing that.
Update2: There are additional properties you can set in the server settings, see this blog for some background. I've not had an opportunity to test this, but from the blog and related http wagon javadoc, it appears you can set authenticationInfo on the server settings, something like this:
解决明文密码问题的提示:
Tip to solve the problem with the clear text password:
我能够使用以下配置来启用 HTTP 基本身份验证 - 通过编写 必要的 HTTP 标头 手动。 在我的情况下,我用它来访问 Go 服务器 上的构建工件作为穷人的暂存库。
I was able to use the following configuration to enable HTTP basic authentication - by writing the necessary HTTP headers manually. In my situation I used it to access the build artifacts on my Go server as a poor man's staging repository.
大多数情况下,发生这种情况是由于以下原因:
用户名
或用于访问 Artifactory 的API Key
您可以查看 Maven 在哪些目录中查找内容...使用 -e -X 选项运行将显示这些有时
,Settings.xml 文件可能会放置在不同的目录中,因此当您本地构建时,maven 无法在 ~/.m2 或 ~/.m2/conf 目录中找到它。 例如,如果项目使用 buildkite,它可能位于 buildkite 在构建过程中可以访问的目录内。 在这种情况下,只需将相同的 Settings.xml 文件复制到 ~/.m2 中即可。
要查找 artifactory,请使用您的电子邮件/密码登录网址,然后转到个人资料并找到用户名和 API 密钥,如图所示。
然后检查 Settings.xml 中的存储库是否正确
Most of the time this happens due to following reasons
Username
or theAPI Key
to access the ArtifactoryYou can see what Maven looks for in what directories... Running with -e -X options will show these details
Sometimes the Settings.xml file may be placed inside a different directory, so when you build locally, maven cannot find it inside ~/.m2 or ~/.m2/conf directories. For e.g if the project uses buildkite, it may be inside a directory that buildkite can access during the build process. In that case, just copy the same Settings.xml file into ~/.m2.
To find the aritifactory, logon to the url using your email/password and go to profile and locate the username and the API Key like in the pic.
Then check the repository is correct in Settings.xml