【发布时间】:2016-02-01 10:38:57
【问题描述】:
我在从我的 Artifactory 服务器下载“受保护的”工件时遇到了巨大的困难。谁能确认下面的(maven)settings.xml 摘录足以导致 GET 请求抢先携带身份验证信息?
Maven 3.3.9。 Artifactory 4.4.2.
<servers>
<server>
<id>myServerId</id>
<username>myUserId</username>
<password>myPlainTextPassword</password>
<configuration>
<httpConfiguration>
<all>
<params>
<property>
<name>http.authentication.preemptive</name>
<value>%b,true</value>
</property>
</params>
</all>
</httpConfiguration>
</configuration>
</server>
</servers>
谢谢,
罗宾
Maven 输出:
C:\>mvn -U clean package
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building fc 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
Downloading: http://repo.myserver.co.uk/artifactory/libs-release/com/group/artifact/126/artifact-126.pom
Downloading: http://www.license4j.com/maven/com/group/artifact/126/artifact-126.pom
Downloading: http://repo.myserver.co.uk/artifactory/private-local/com/group/artifact/126/artifact-126.pom
Downloading: https://repo.maven.apache.org/maven2/com/group/artifact/126/artifact-126.pom
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 3.906 s
[INFO] Finished at: 2016-01-31T19:41:52+02:00
[INFO] Final Memory: 8M/245M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal on project fc: Could not resolve dependencies for project uk.co.myserver:fc:jar:1.0-SNAPSHOT: Failed to collect dependencies at com.group:artifact:jar:126: Failed to read artifact descriptor for com.group:artifact:jar:126: Could not transfer artifact com.group:artifact:pom:126 from/to releases (http://repo.myserver.co.uk/artifactory/libs-release): Access denied to: http://repo.myserver.co.uk/artifactory/libs-release/com/group/artifact/126/artifact-126.pom , ReasonPhrase:Forbidden. -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/DependencyResolutionException
神器访问日志:
2016-02-01 11:14:33,562 [DENIED DOWNLOAD] libs-release:com/group/artifact/126/artifact-126.pom for anonymous/193.66.174.253.
2016-02-01 11:14:33,564 [DENIED DOWNLOAD] private-release-local:com/group/artifact/126/artifact-126.pom for anonymous/193.66.174.253.
2016-02-01 11:14:34,436 [ACCEPTED DELETE] libs-release:com/group/artifact/126/artifact-126.pom for anonymous/193.66.174.253.
2016-02-01 11:14:35,010 [DENIED DOWNLOAD] private-local:com/group/artifact/126/artifact-126.pom for anonymous/193.66.174.253.
2016-02-01 11:14:35,011 [DENIED DOWNLOAD] private-release-local:com/group/artifact/126/artifact-126.pom for anonymous/193.66.174.253.
2016-02-01 11:14:35,012 [ACCEPTED DELETE] private-local:com/group/artifact/126/artifact-126.pom for anonymous/193.66.174.253.
以下所有内容都存在于 pom.xml 和 settings.xml 中,并且由于它们都引用相同的 Artifactory 服务器,它们共享相同的用户名/密码/http.authentication.preemptive 参数:
<id>releases</id>
<id>snapshots</id>
<id>private-local</id>
<id>plugin-releases</id>
<id>plugin-snapshots</id>
<id>deploy-releases</id>
<id>deploy-snapshots</id>
settings.xml 中只有以下内容没有提及,因为访问应该是匿名的,并且它是其他人服务器上的单独存储库实例:
<id>license4j-runtime-library</id>
这是请求日志的相应输出:
20160202060102|58|REQUEST|193.66.174.253|admin|GET|/ui/systemlogs/logData|HTTP/1.1|200|0
20160202060102|1099|REQUEST|199.19.249.196|anonymous|GET|/libs-release/com/group/artifact/126/artifact-126.pom|HTTP/1.1|401|0
20160202060102|706|REQUEST|199.91.135.165|anonymous|GET|/libs-release/com/group/artifact/126/artifact-126.pom|HTTP/1.1|401|0
20160202060102|5|REQUEST|193.66.174.253|anonymous|GET|/libs-release/com/group/artifact/126/artifact-126.pom|HTTP/1.1|401|0
20160202060103|3|REQUEST|199.19.249.196|anonymous|GET|/private-local/com/group/artifact/126/artifact-126.pom|HTTP/1.1|401|0
20160202060103|3|REQUEST|193.66.174.253|anonymous|GET|/private-local/com/group/artifact/126/artifact-126.pom|HTTP/1.1|401|0
20160202060113|60|REQUEST|193.66.174.253|admin|GET|/ui/systemlogs/logData|HTTP/1.1|200|0
请注意,有两个对本地私有的请求,这两个请求都以“匿名”的形式出现。通过抢先式身份验证,我原以为所有这些都是“myUserId”。
【问题讨论】:
-
提供日志输出。
-
正在研究如何附加日志摘录....
-
确保服务器
<id/>与<repositories/>、<pluginRepositories/>和<distributionManagement/>中用于两个存储库的服务器匹配。否则,您在上面指定的凭据将不会被使用。如果您的settings.xml中有<mirrors/>部分,则需要确保其中的<id/>也匹配,以及其中定义为配置文件的任何<repositories/>和<pluginRepositories/>。 -
以下所有内容在 pom.xml 和 settings.xml 中完全相同,并且由于它们都引用相同的 Artifactory 服务器,它们共享相同的用户名/密码/http.authentication.preemptive 参数:
releases snapshots private-local plugin-releases plugin-snapshots deploy-releases deploy-snapshots settings.xml 中只有以下内容未提及,因为访问应该是匿名的,并且它是其他人服务器上的单独存储库实例:license4j-runtime-library -
作为参考,我的 mvn 命令是从 AUTHENTICATED http 代理后面执行的。
标签: maven-3 artifactory