访问需要 basic-auth 的 Artifactory/Maven Repo [英] Accessing an Artifactory/Maven Repo that requires basic-auth

查看:20
本文介绍了访问需要 basic-auth 的 Artifactory/Maven Repo的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个位于基本身份验证后面的 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>

所以服务器标签是 artifactory 用户的用户凭据,但我还需要提供另一个用户/密码来通过基本身份验证.我会把它放在哪里?!?

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

推荐答案

用户名和密码按您的方式进入服务器设置.我认为您的问题是您已按名称 (Artifactory) 指定服务器,而不是其 ID (artifactory).

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:您可以在 server 设置中设置其他属性,请参阅此 博客 了解一些背景.我还没有机会测试这个,但是来自博客和相关的 http wagon javadoc,看来您可以在服务器设置中设置 authenticationInfo,如下所示:

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> 

这篇关于访问需要 basic-auth 的 Artifactory/Maven Repo的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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