我最近在我的 Artifactory 实例上激活了安全性,这导致了几个问题。一个仍然存在,看起来有点奇怪:
Maven 使用 HTTP HEAD 来检查是否部署了新的 SNAPSHOT。但是,启用安全性后,第一次调用是在没有身份验证标头的情况下完成的,从而导致来自 Artifactory 的 401 响应。
然后,Maven 应该使用身份验证标头执行相同的调用。maven-metadata.xml文件就是这种情况。
但是对于.pom 和 .jar 文件,请求不会被重新尝试,如下面的日志所示:
20150303104244|3|REQUEST|xxx.xxx.xxx.xxx|non_authenticated_user|GET|/libs-snapshot-local/mycompany/common/common-config/1.0.4-SNAPSHOT/maven-metadata.xml|HTTP/1.1|401|0
20150303104244|12|REQUEST|xxx.xxx.xxx.xxx|user|GET|/libs-snapshot-local/mycompany/common/common-config/1.0.4-SNAPSHOT/maven-metadata.xml|HTTP/1.1|200|322
20150303104244|40|REQUEST|xxx.xxx.xxx.xxx|user|GET|/libs-snapshot-local/mycompany/common/common-config/1.0.4-SNAPSHOT/maven-metadata.xml.sha1|HTTP/1.1|200|40
20150303104244|4|REQUEST|xxx.xxx.xxx.xxx|user|GET|/libs-snapshot-local/mycompany/common/common-config/1.0.4-SNAPSHOT/maven-metadata.xml.md5|HTTP/1.1|200|32
20150303104245|2|REQUEST|xxx.xxx.xxx.xxx|non_authenticated_user|HEAD|/libs-snapshot-local/mycompany/myproject/myproject-interface/2.0.0-SNAPSHOT/myproject-interface-2.0.0-SNAPSHOT.jar|HTTP/1.1|401|0
20150303104245|2|REQUEST|xxx.xxx.xxx.xxx|non_authenticated_user|HEAD|/libs-snapshot-local/mycompany/myproject/myproject-interface/2.0.0-SNAPSHOT/myproject-interface-2.0.0-SNAPSHOT.jar|HTTP/1.1|401|0
如前所述,使用用户凭据重新尝试下载 maven-metadata.xml 文件,但myproject-interface-2.0.0-SNAPSHOT.jar没有。
我试图为该服务器启用抢先身份验证,但我找不到 Maven 行为的任何变化:
<server>
<id>snapshot</id>
<username>user</username>
<password>xxx</password>
<configuration>
<httpConfiguration>
<all>
<usePreemptive>true</usePreemptive>
<params>
<property>
<name>http.authentication.preemptive</name>
<value>%b,true</value>
</property>
</params>
</all>
</httpConfiguration>
</configuration>
</server>
这仅涉及现有 SNAPSHOT 的更新,因为下载新工件是使用包含身份验证标头的 HTTP GET 完成的(至少重试)。这仍然会阻止正确使用 SNAPSHOT 工件。
我正在使用 Maven 3.2.1 和 Artifactory 3.4.2。