2015-03-03 29 views
2

我最近在我的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。

回答

1

這與Artifactory快照資源庫中「Maven快照版本行爲」選項的用法有關。

如解釋here所示,Maven 3不再支持此選項。

Maven的3只支持獨特的快照

的Maven 3已經降到了 解決和部署非唯一快照的支持。因此,如果您有一個使用非唯一快照的 快照存儲庫,我們建議您將Maven快照策略更改爲「唯一」並從此存儲庫中刪除以前部署的任何快照。由Maven客戶端在部署時生成的唯一 快照名稱不能幫助 確定構建快照的源控件更改,其中構建的快照是 ,與檢出時間源無關。 因此,我們建議工件本身應嵌入 修訂/標記(作爲其名稱的一部分或內部),以便清晰可見的 修訂版跟蹤。 Artifactory允許您使用 修訂版編號標記工件,作爲其構建集成支持的一部分。

切換到唯一解決了這個問題。

0

對於其他人誰的土地在這裏希望在默認情況下啓用搶先認證:

The documentation的主Maven站點此設置是錯誤的。我花了一段時間追蹤它,但最終找到了我在下面轉載的open bug ticket上的答案。這適用於OS X上的Maven 3.1.1。

<servers> 
<server> 
    <id>serverid</id> 
    <username>myuser</username> 
    <password>mypassword</password> 
    <configuration> 
    <wagonProvider>httpclient</wagonProvider> 
    <httpConfiguration> 
    <all> 
    <usePreemptive>true</usePreemptive> 
    </all> 
    </httpConfiguration> 
    </configuration> 
</server> 
</servers> 
相關問題