2

I'm writing a script to configure .npmrc file with JFrog Artifactory credentials. Artifactory/NPM requires the configured password to be base64 encoded, i.e. (with the password "test"):

//mycompany.jfrog.io/mycompany/api/npm/npm-repo/:_password=dGVzdAo=

However, a base64 encoded string does not match what Artifactory provides for the password in the Set Me Up dialog. In fact, base64 decoding the string that Artifactory provides in this dialog yields a different string that is not the account's password. How is the password string provided by Artifactory generated?

Mark Thë Brouch
  • 179
  • 3
  • 12

3 Answers3

4

You can use the Artifactory npm auth REST API to retrieve the setting for the .npmrc.
For example:

$ curl -uadmin:<CREDENTIAL> http://<ARTIFACTORY_SERVER_DOMAIN>:8081/artifactory/api/npm/auth

Will return the following response

_auth = YWRtaW46e0RFU2VkZX1uOFRaaXh1Y0t3bHN4c2RCTVIwNjF3PT0=
email = myemail@email.com
always-auth = true

For more info see the npm repositories documentation.

Dror Bereznitsky
  • 20,048
  • 3
  • 48
  • 57
2

You can try using the encrypted password generated by Artifactory, or your API key for authentication purposes, as mentioned here

Suryansh
  • 193
  • 2
  • 12
  • How can I programmatically encrypt the password generated by Artifactory? In my script I ask the user for their JFrog password and it should encrypt that and store it in the .npmrc file. – Mark Thë Brouch Jun 13 '18 at 16:13
0

I have been looking for a way to base64 encode in Windows.

PowerShell script:

$Text = ‘Password’
$Bytes = [System.Text.Encoding]::Unicode.GetBytes($Text)
$EncodedText =[Convert]::ToBase64String($Bytes)
echo $EncodedText

This will return the following response:

UABhAHMAcwB3AG8AcgBkAA==

ddkserv
  • 96
  • 3