searchcode-server icon indicating copy to clipboard operation
searchcode-server copied to clipboard

Encrypt usernames and passwords

Open boyter opened this issue 8 years ago • 6 comments

Currently for convenience the usernames and passwords of the repositories are stored unencrypted. Need to encrypt them as well, but sadly they need to be reversible.

Should also look into storing a ssh key for this such that we dont need username or password.

boyter avatar Feb 23 '17 21:02 boyter

This answer http://stackoverflow.com/questions/1205135/how-to-encrypt-string-in-java covers things quite well.

You can use Jasypt

With Jasypt, encrypting and checking a password can be as simple as...

StrongTextEncryptor textEncryptor = new StrongTextEncryptor(); textEncryptor.setPassword(myEncryptionPassword); Encryption:

String myEncryptedText = textEncryptor.encrypt(myText); Decryption:

String plainText = textEncryptor.decrypt(myEncryptedText);

boyter avatar Feb 23 '17 21:02 boyter

Be aware, I get around needing passwords by installing the ssh key into the system and setting up ~/.ssh/config file

# Setup SSH keys
mkdir -p ~/.ssh/
cp /setup/RP-readonly_rsa.pem ~/.ssh/RP-readonly_rsa.pem
chmod 600 ~/.ssh/RP-readonly_rsa.pem

# Use a private key ssh key to connect to gerrit
echo "Host gerrit" >> ~/.ssh/config
echo "User RP-readonly" >> ~/.ssh/config
echo "IdentityFile ~/.ssh/RP-readonly_rsa.pem" >> ~/.ssh/config
echo "StrictHostKeyChecking no" >> ~/.ssh/config

hskrtich avatar Feb 24 '17 03:02 hskrtich

That would work too actually... especially since you are calling out to the external git if I am not mistaken.

Something to keep in mind....

boyter avatar Feb 24 '17 07:02 boyter

It works with the internal GIT as well.

hskrtich avatar Feb 24 '17 16:02 hskrtich

Really? Now that is not something I expected!

That is a very cool outcome (all watching please note the coolness). Will have to add that to the documentation that I am working on. Going to leave this open till that is done.

https://github.com/boyter/searchcode-server/issues/50

boyter avatar Feb 26 '17 21:02 boyter

I think this solution should be presented in the FAQ, because with ssh I could not find anything on the website.

bert2002 avatar Oct 31 '19 06:10 bert2002