简体   繁体   English

Artifactory 的 Maven Auth 错误

[英]Maven Auth error with Artifactory

I'm trying to install artifactory in my local computer to manage all my project jars.我正在尝试在我的本地计算机上安装 artifactory 来管理我所有的项目 jars。 I've set up artifactory so it has two users: admin and user, without allowing anonymous login.我已经设置了 artifactory,所以它有两个用户:admin 和 user,不允许匿名登录。 Here's my settings.xml:这是我的 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}" is the passord obtained from encrypting (mvn -ep) the encrypted password from artifactory. “{encrypted-pssw}”是通过加密(mvn -ep)来自artifactory的加密密码获得的密码。 When I try to install ("mvn clean install") or deploy ("mvn deploy") every project it gives me this error:当我尝试安装(“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]

I've tryied the rsa authentication too without any success我也尝试过 rsa 身份验证但没有成功

EDIT: more informations:编辑:更多信息:

If I try to login with the broswer in the repository it asks for username and password, if I put them (using the encrypted password from artifactory) it allowes me to view the repository.如果我尝试使用存储库中的浏览器登录,它会要求输入用户名和密码,如果我将它们(使用来自 artifactory 的加密密码),它允许我查看存储库。

If I use as the url: http://user:passw@localhost:8081 it works and maven can login, but I need to do a lot of dirty work copying my password all over the projects if I use this workaround (note: the password used in the url is the one I get from the encrypted-password field in Artifactory, not the double-encrypted one I get from the maven command)如果我用作 url: http://user:passw@localhost:8081它可以工作并且 maven 可以登录,但是如果我使用这个解决方法,我需要做很多脏活来在整个项目中复制我的密码(注意: url 中使用的密码是我从 Artifactory 的加密密码字段中获得的密码,而不是我从 maven 命令中获得的双重加密密码)

This can be due to the following reasons:这可能是由于以下原因:

  1. Can you check if this user has deploy permission on the remote repositories that are being aggregated under the "remote-repos" virtual repository?您能否检查此用户是否对聚合在“remote-repos”虚拟存储库下的远程存储库具有部署权限? If not you should grant the user deploy permissions to the remote repositories that are needed for the builds resolution.如果不是,您应该授予用户对构建解析所需的远程存储库的部署权限。 If you are not sure you can try using an admin user and see if it worked.如果您不确定可以尝试使用管理员用户并查看它是否有效。

  2. Check if in your Artifactory UI --> Admin --> Security configuration --> "Hide existence of unauthorised resources" is this checkbox checked?检查您的 Artifactory UI --> 管理 --> 安全配置 --> “隐藏未经授权的资源的存在”是否选中了此复选框? If so you will need to define "preemptive authentication" on maven (should be defined in your settings.xml file. See in google on how to add it.如果是这样,您将需要在 Maven 上定义“抢占式身份验证”(应在您的 settings.xml 文件中定义。有关如何添加它的信息,请参阅谷歌。

  3. Last thing that comes to my mind, can you double check that the encrypted password was written correctly in the settings.xml file?我想到的最后一件事是,您能否仔细检查一下在 settings.xml 文件中是否正确写入了加密密码?

Hope this will assist you with finding the root cause of the issue and resolve it.希望这将帮助您找到问题的根本原因并解决它。

Please remove all mirrors in your file.请删除文件中的所有镜像。

 <?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>

You should also check which settings.xml.您还应该检查哪些 settings.xml。 According to the maven website:根据 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

I was trying to modify the first settings.xml file with no luck, adding my credentials to the second one worked.我试图在没有运气的情况下修改第一个 settings.xml 文件,将我的凭据添加到第二个文件中。 If you run your maven command with the -e flag it will also tell you the settings file that it is trying to use如果您使用-e标志运行 Maven 命令,它还会告诉您它尝试使用的设置文件

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM