使用 Ivy 和私人公司存储库时,我的凭据应该放在哪里?
我正在使用 Ant + Ivy,我的公司最近为我们自己的私人图书馆设置了 Nexus 服务器。 Ivy 可以通过使用 ibilio 解析器和 m2兼容=true 从 Nexus 服务器获取依赖项,但我必须将我的凭据放入 ivysettings.xml 文件中。
不同的开发人员应该如何存储他们的凭据?
ivysettings.xml 文件是否不应在 vcs 中提交?
我真的不想以纯文本形式存储我的密码。
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
使用具有控制 Nexus 凭据的属性的设置文件:
运行构建时,您可以指定真实的用户名和密码:
更新/增强
将密码作为属性存储在文件系统上需要加密。
Jasypt 有一个可以生成加密字符串的命令行程序:
这可以保存在构建的属性文件中
:以下 ANT 目标将解密任何加密的 ANT 属性:
当然,要实现此目的,需要在构建过程中指定用于加密属性的密码。
这意味着该解决方案仅适用于隐藏静态数据。
Use a settings file with properties controlling the Nexus credentials:
When you run the build you can then specify the true username and password:
Update/Enhancement
Storing passwords as properties on the file system requires encryption.
Jasypt has a command-line program that can generate encrypted strings:
This can be saved in the build's property file:
The following ANT target will decrypt any encrypted ANT properties:
Of course to make this work, the password used for encrypting the properties needs to be specified as part of the build.
This means the solution is only good for hiding data at rest.
出于我的目的,命令行凭据不是一个选项,因为我正在通过 Jenkins 运行,并且它们会清楚地粘贴在构建输出上,因此这是我的解决方案,它通过相当安全的方式实现了平衡。
在您的主目录中创建一个包含敏感信息的属性文件(我们将其称为“maven.repo.properties”)
在构建文件顶部附近,导入属性文件
在 build.xml 下的发布目标中,设置 ivy 设置文件位置(确实会签入代码控件)但嵌入您的凭证属性
像您一样创建 ivysettings.xml之前,但删除用户名和密码属性
然后,您可以利用操作系统的权限来确保maven.repo.properties 文件对除您(或您的自动构建实现)之外的所有人都正确隐藏。
For my purposes the command-line credentials weren't an option because I'm running through Jenkins and they'd be clearly pasted on the build output, so here was my solution which strikes a balance by being reasonably secure.
Create a properties file in your home directory that contains the sensitive information (we'll call it "maven.repo.properties")
Near the top of your build file, import the property file
In your publish target under build.xml, set your ivy settings file location (which does get checked in to code control) but embed your credential properties
Create your ivysettings.xml just as you did before, but strip out the username and passwd attributes
You can then leverage your operating system's permissions to make sure that the maven.repo.properties file is properly hidden from everybody except you (or your automatic build implementation).
Mark O'Connor 的答案中的 ivysettings.xml 示例实际上应该如下所示:
意思是,属性名称不应该被 ${...} 包围(我花了很长时间才发现为什么失败了 - 但现在我知道如何调试 ivy 访问 - 使用 commons-httpclient-3.0,将所有内容设置为详细等)
The ivysettings.xml sample in Mark O'Connor's answer should actually be as follows:
Means, the property names should not be surrounded by ${...} (it took me quite a while to find out why this failed - but now I know how to debug ivy access - use commons-httpclient-3.0, set everything to verbose etc.)
除了 Mark O'Connor 的答案之外,您还可以通过将这些属性放入 antrc 启动文件或进入 环境使用的变量由蚂蚁。请注意,这两个地方都不是很安全。
Additional to Mark O'Connor's answer you can hide the password from your daily work and from the prying eyes of your workmates by putting these properties either into the antrc startup file or into the environment variables used by ant. Please note that they are not very secure in either place.