访问需要基本身份验证的Artifactory/Maven回购 [英] Accessing an Artifactory/Maven Repo that requires basic-auth

查看:300
本文介绍了访问需要基本身份验证的Artifactory/Maven回购的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个Artifactory仓库,位于基本身份验证的后面.我将如何配置settings.xml以允许访问?

I have an Artifactory repo that sits behind basic authentication. How would I configure the settings.xml to allow access?

<mirrors>
    <mirror>
        <id>artifactory</id>
        <mirrorOf>*</mirrorOf>
        <url>https://myserver.example.com/artifactory/repo</url>
        <name>Artifactory</name>
    </mirror>
</mirrors>
<servers>
    <!--
        This server configuration gives your personal username/password for
        artifactory. Note that the server id must match that given in the
        mirrors section.
    -->
    <server>
        <id>Artifactory</id>
        <username>someArtifactoryUser</username>
        <password>someArtifactoryPassword</password>
    </server>

因此服务器标记是工件用户的用户凭证,但是我还需要提供另一个用户/密码来通过基本身份验证.我该放在哪里?!?

So server tag is the user credentials for the artifactory user, but I also need to provide another user/password to get through the basic-auth. Where would I put that?!?

推荐答案

用户名和密码随您输入在服务器设置中.我认为您的问题是您通过服务器名称( A rtifactory)而不是其ID( a rtifactory)指定了服务器.

The username and password go in the server settings as you have them. I think your problem is that you've specified the server by its name (Artifactory), rather than its id (artifactory).

我建议您将服务器设置放在用户设置中,而不要放在全局设置中.您还可以在Maven 2.1.0+中加密密码,请参见迷你指南了解详情.

I'd recommend you put the server settings in your user settings rather than the global settings. You can also encrypt the password in Maven 2.1.0+, see the mini guide for details.

更新:您正在使用哪个版本的Artifactory?有问题,身份验证失败.显然,该问题已在2.0.7和2.1.0中修复.

Update: What version of Artifactory are you using? There is a discussion and corresponding issue that basic-auth fails. This has apparently been fixed in 2.0.7 and 2.1.0.

从讨论中可以看出,

From the discussion, it seems that a workaround is to pass the properties via the command line, e.g.

-Dhttp.proxyHost=proxy -Dhttp.proxyPort=8080 -Dproxy.username=... -Dhttp.password=... 

更新:要使您的Maven安装通过防火墙连接,您需要配置settings.xml的代理部分,请参阅此

Update: To let your Maven installation connect through a firewall, you'll need to configure the proxy section of the settings.xml, see this question for some pointers on doing that.

Update2:您可以在服务器设置中设置其他属性,请参见此

Update2: There are additional properties you can set in the server settings, see this blog for some background. I've not had an opportunity to test this, but from the blog and related http wagon javadoc, it appears you can set authenticationInfo on the server settings, something like this:

<server>  
  <id>Artifactory</id>
  <username>someArtifactoryUser</username>
  <password>someArtifactoryPassword</password>
  <configuration>  
    <authenticationInfo>
      <userName>auth-user</userName>
      <password>auth-pass</password>
    </authenticationInfo>
  </configuration>  
</server> 

这篇关于访问需要基本身份验证的Artifactory/Maven回购的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆