【问题标题】:Hide HTTP password when downloading maven artifacts下载 Maven 工件时隐藏 HTTP 密码
【发布时间】:2012-12-22 04:11:29
【问题描述】:

我们有一个受密码保护的 Maven 存储库。下载时控制台显示http密码:

下载:https://arved:passw0rd@maven.arved.at/content/groups/arved/org/apache/xbean/xbean-naming/3.7/xbean-naming-3.7.jar

是否有可能以某种方式隐藏密码?

【问题讨论】:

  • 以前从未见过。您使用的是哪个版本的 Maven 以及哪个 Maven 存储库管理软件?
  • 你的http密码是怎么配置的?

标签: maven buildr


【解决方案1】:

您的存储库配置(URL)可能是错误的,请查看此页面: http://maven.apache.org/guides/mini/guide-encryption.html(加密可选)

您只需将密码输入到 $HOME/.m2/settings.xml

<settings>
...
  <servers>
...
    <server>
      <id>arved-repository</id>
      <username>arved</username>
      <password>passw0rd</password>
    </server>
...
  </servers>
...
</settings>

并使用之前定义的 server.id 在 pom.xml 中配置存储库:

<project>
...
  <repositories>
    <repository>
      <id>arved-repository</id>
      <name>Arved Repository</name>
      <url>https://maven.arved.at/content/groups/arved</url>
    </repository>
...
</project>

【讨论】:

    【解决方案2】:

    一种方法是猴子补丁 URI::HTTP。以下代码可以改进,但显示了总体思路。

    # Patch HTTP.to_s so it does not reveal passwords
    module URI
      class HTTP
        def to_s
          url = ''
          if @scheme
            url << @scheme
            url << ':'
          end
          if @host
            url << '//'
          end
          if self.userinfo
            url << @user
            if @password
              url << ':***'
            end
            url << '@'
          end
          if @host
            url << @host
          end
          if @port
            url << ':'
            url << @port.to_s
          end
          url << path_query
          if @fragment
            url << '#'
            url << @fragment
          end
          url
        end
      end
    end
    

    【讨论】:

      猜你喜欢
      • 2011-09-28
      • 1970-01-01
      • 2021-05-20
      • 2019-07-30
      • 1970-01-01
      • 2022-01-13
      • 2013-12-20
      • 2014-08-10
      • 2016-01-24
      相关资源
      最近更新 更多