How to set encrypted password to credentials to pu

2019-05-04 19:33发布

问题:

I'm trying to access a Nexus OSS repository with unencrypted password in global.sbt like this, my global.sbt is:

 credentials += Credentials("Sonatype Nexus", "repo.example.com", "username", "unencrypted_password")

I'd like to thinking about setting encrypted password.

回答1:

You can create a file called .credentials, under ~/.ivy2/.credentials. That's a fairly standard location, but obviously you can place your file anywhere on disk.

The file looks like this:

realm = Sonatype Nexus Repository Manager
host = oss.sonatype.org
user = publishing@yourco.com
password = $encrypted

To encrypt the password, you can use a known AES cypher, which means you can basically do something like this:

val credential: DirectCredentials = Credentials(Path.userHome / ".ivy2" / ".credentials")
val decrypted = credential.copy(passwd = decryptAes(credential.passwd))

Now what you need is a shared cypher company wide or similar, as well as a method to decrypt AES, and for that look here.



标签: scala sbt nexus