我最近在我的Artifactory實例上激活了安全性,這導致了幾個問題。其中一個仍然存在,似乎有點奇怪:從Maven到Artifactory的Authenticated HEAD調用
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不是。
我試圖讓該服務器的preemtive身份驗證,但我找不到在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>
這僅涉及現有快照下載新文物的更新與HTTP GET完成與包含驗證標頭(至少有一個重試)。這仍然會阻止正確使用SNAPSHOT工件。
我正在使用Maven 3.2.1和Artifactory 3.4.2。