【问题标题】:Maven Auth error with ArtifactoryArtifactory的Maven Auth错误
【发布时间】:2017-03-12 19:10:17
【问题描述】:

我正在尝试在我的本地计算机上安装 artifactory 来管理我所有的项目 jar。 我已经设置了工件,所以它有两个用户:管理员和用户,不允许匿名登录。 这是我的 settings.xml:

<?xml version="1.0" encoding="UTF-8"?>
<settings>
<servers>
    <server>
        <id>central</id>
        <username>user</username>
        <password>{encrypted-pssw}</password>
    </server>
    <server>
        <id>snapshot</id>
        <username>user</username>
        <password>{encrypted-pssw}</password>
    </server>
</servers>
<mirrors>
    <mirror>
        <mirrorOf>*</mirrorOf>
        <name>remote-repos</name>
        <url>http://localhost:8081/artifactory/remote-repos</url>
        <id>remote-repos</id>
    </mirror>
</mirrors>
<profiles>
    <profile>
        <id>central</id>
        <repositories>
            <repository>
                <id>artifactory</id>
                <url>http://localhost:8081/artifactory/repo</url>
                <layout>default</layout>
                <name>Artifactory default repo</name>
            </repository>
        </repositories>
    </profile>
</profiles>
<activeProfiles>
    <activeProfile>central</activeProfile>
</activeProfiles>

“{encrypted-pssw}”是通过加密(mvn -ep)从artifactory获得的加密密码获得的密码。 当我尝试安装(“mvn clean install”)或部署(“mvn deploy”)每个项目时,它给了我这个错误:

Could not transfer artifact org.apache.maven.plugins:maven-clean-plugin:pom:2.5 from/to remote-repos (http://localhost:8081/artifactory/remote-repos): Not authorized , ReasonPhrase: Unauthorized. -> [Help 1]

我也尝试过 rsa 身份验证,但没有任何成功

编辑:更多信息:

如果我尝试使用存储库中的浏览器登录,它会询问用户名和密码,如果我输入它们(使用来自 artifactory 的加密密码),它允许我查看存储库。

如果我使用 url:http://user:passw@localhost:8081 它可以工作并且 maven 可以登录,但是如果我使用这种解决方法,我需要做很多脏活来在整个项目中复制我的密码(注意:在url 是我从 Artifactory 中的 encrypted-password 字段中获得的,而不是我从 maven 命令中获得的双重加密的)

【问题讨论】:

  • 下面的问题意味着这个用户是否有权限部署到远程存储库,而不是查看。这是两个不同的权限。你能验证和更新吗?
  • 是的,用户拥有所有权限:如果我使用 ip 方法登录 (user:pssw@ip:port) 它可以部署
  • 在收到'Could not transfer artifact org.apache.maven.plugins:maven-clean-plugin:pom:2.5 from /to remote-repos (localhost:8081/artifactory/remote-repos):未授权,ReasonPhrase:未授权。 -> [Help 1] '错误?
  • artifactory.log 中未显示任何内容,但在 request.log 中显示以下行:“20161101133853|1|REQUEST|127.0.0.1|non_authenticated_user|HEAD|/remote-repos/org/apache /maven/plugins/maven-clean-plugin/2.5/maven-clean-plugin-2.5.pom|HTTP/1.1|401|0"
  • 正如您在 request.log 中看到的,请求到达 Artifactory 时没有用户:'non_authenticated_user'。通常,您会在该行下方看到另一行,maven 正在发送另一个带有凭据的请求。

标签: java maven authentication passwords artifactory


【解决方案1】:

请删除您文件中的所有镜像。

<?xml version="1.0" encoding="UTF-8"?>
<settings>
<servers>
    <server>
        <id>central</id>
        <username>user</username>
        <password>{encrypted-pssw}</password>
    </server>
    <server>
        <id>snapshot</id>
        <username>user</username>
        <password>{encrypted-pssw}</password>
    </server>
</servers>
<profiles>
    <profile>
        <id>central</id>
        <repositories>
            <repository>
                <id>artifactory</id>
                <url>http://localhost:8081/artifactory/repo</url>
                <layout>default</layout>
                <name>Artifactory default repo</name>
            </repository>
        </repositories>
    </profile>
</profiles>
<activeProfiles>
    <activeProfile>central</activeProfile>
</activeProfiles>

【讨论】:

    【解决方案2】:

    您还应该检查哪些 settings.xml。根据maven网站:

    There are two locations where a settings.xml file may live:
    
    The Maven install: ${maven.home}/conf/settings.xml
    A user’s install: ${user.home}/.m2/settings.xml
    

    我试图修改第一个 settings.xml 文件,但没有成功,将我的凭据添加到第二个有效。如果您使用 -e 标志运行 maven 命令,它还会告诉您它正在尝试使用的设置文件

    【讨论】:

      【解决方案3】:

      这可能是由于以下原因:

      1. 您能否检查此用户是否具有对“remote-repos”虚拟存储库下聚合的远程存储库的部署权限?如果不是,您应该授予用户对构建解析所需的远程存储库的部署权限。如果您不确定可以尝试使用管理员用户并查看它是否有效。

      2. 检查您的 Artifactory UI --> 管理 --> 安全配置 --> “隐藏未授权资源的存在”是否选中了此复选框?如果是这样,您将需要在 maven 上定义“抢先式身份验证”(应在您的 settings.xml 文件中定义。有关如何添加它,请参阅 google。

      3. 我想到的最后一件事是,您能否仔细检查一下 settings.xml 文件中的加密密码是否正确写入?

      希望这将帮助您找到问题的根本原因并解决它。

      【讨论】:

        猜你喜欢
        • 2012-04-25
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2012-12-21
        • 1970-01-01
        • 2014-05-30
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多