[英]Accessing an Artifactory/Maven Repo that requires basic-auth
I have an Artifactory repo that sits behind basic authentication. 我有一个Artifactory仓库,它位于基本身份验证之后。 How would I configure the settings.xml to allow access? 如何配置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>
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. 因此,server tag是artifactory用户的用户凭据,但我还需要提供另一个用户/密码来完成basic-auth。 Where would I put that?!? 我会把它放在哪里?!?
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 ( A rtifactory), rather than its id ( a rtifactory). 我觉得你的问题是,你已经被它的名字(A rtifactory)指定的服务器,而不是它的ID( 一 rtifactory)。
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. 您也可以在Maven 2.1.0+中加密密码,有关详细信息,请参阅迷你指南 。
Update: What version of Artifactory are you using? 更新:您使用的是什么版本的Artifactory? There is a discussion and corresponding issue that basic-auth fails. 有一个讨论和相应的问题 ,基本认证失败。 This has apparently been fixed in 2.0.7 and 2.1.0. 这显然已在2.0.7和2.1.0中修复。
From the discussion, it seems that a workaround is to pass the properties via the command line, eg 从讨论开始,似乎解决方法是通过命令行传递属性,例如
-Dhttp.proxyHost=proxy -Dhttp.proxyPort=8080 -Dproxy.username=... -Dhttp.password=...
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. 更新:要让您的Maven安装通过防火墙连接,您需要配置settings.xml的代理部分,请参阅此问题以获取有关此操作的一些指示。
Update2: There are additional properties you can set in the server settings, see this blog for some background. Update2:您可以在服务器设置中设置其他属性,有关背景信息,请参阅此博客 。 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: 我没有机会测试这个,但是从博客和相关的http旅行车javadoc看来,你可以在服务器设置上设置authenticationInfo,如下所示:
<server>
<id>Artifactory</id>
<username>someArtifactoryUser</username>
<password>someArtifactoryPassword</password>
<configuration>
<authenticationInfo>
<userName>auth-user</userName>
<password>auth-pass</password>
</authenticationInfo>
</configuration>
</server>
I was able to use the following configuration to enable HTTP basic authentication - by writing the necessary HTTP headers manually. 我能够使用以下配置来启用HTTP基本身份验证 - 通过手动编写必要的HTTP标头 。 In my situation I used it to access the build artifacts on my Go server as a poor man's staging repository. 在我的情况下,我用它来访问我的Go服务器上的构建工件作为穷人的临时存储库。
<server>
<id>go</id>
<configuration>
<httpHeaders>
<property>
<name>Authorization</name>
<!-- Base64-encoded "guest:guest" -->
<value>Basic Z3Vlc3Q6Z3Vlc3Q=</value>
</property>
</httpHeaders>
</configuration>
</server>
Tip to solve the problem with the clear text password: 提示用明文密码解决问题:
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.