2

I'm connecting to a few APIs and using basic authentication like so:

this.jenkins = jenkinsapi.init('https://USERNAME:[email protected]:8080', {strictSSL: false});

I'm concerned about just having the user's password just sitting there in a variable or plain text. It is inside a 'private' method but if anybody is able to view the source on the server they would be able to view the username and password.

How can I make this more secure while still using http basic auth?

Ramkrishna Sharma
7,0173 gold badges45 silver badges51 bronze badges
asked Apr 26, 2016 at 13:10
1
  • 1
    use configuration file to store username/password, ideally a file that is loaded in the server not in the webapp or on build so even developpers will not know the username/password of production. Commented Apr 26, 2016 at 13:25

1 Answer 1

1

Take a look at Environment Variables. These are available in Node.js.

process.env.ENV_VARIABLE

Where ENV_VARIABLE is something defined in your system running the application. For isntance, in my Node.js application running on Heroku, and hosted publically on Github, I'm using process.env.MONGOLAB_URI instead of the SQL-type string containing the database name, username, and password. I have this automatically configured because of Heroku, but I'm able to also set the variable locally in my OS (Windows in this case) so that the code will run locally, as well.

Also check out this answer about using Environment variables with Jenkins.

answered Apr 26, 2016 at 13:13
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.