Forum Stats

  • 3,872,608 Users
  • 2,266,458 Discussions
  • 7,911,263 Comments

Discussions

newbie question

lake
lake Member Posts: 1,156 Bronze Badge
edited May 4, 2015 6:54PM in Node.js

unfortunately as soon as I was able to connect to the database, I dearly want to know how to not have

hard coded userid, passwords, or sid's in files.

Is there an easy want to pass through these items?

and is there a way to ask for these items?

(I hope server side javascript has parameters!)

Christopher Jones-Oracleshadowknight

Comments

  • lake
    lake Member Posts: 1,156 Bronze Badge
    edited Apr 28, 2015 3:46PM

    yeah!  I figured it out all by myself! example:

    call this function as below. Node puts node as argv 0, the name of the program as argv 1 and

    then the parameters given.

    node myfunction.js user password sid

    -----------------------------

    var oracledb = require('oracledb');

    oracledb.getConnection(

      {

        user          : process.argv[2],

        password      : process.argv[3],

        connectString : process.argv[4]

      },

      function(err, connection)

      {

        if (err) {

          console.error(err.message);

          return;

        }

        connection.execute(

          "SELECT department_id, department_name "

        + "FROM tmpdepartments "

        + "WHERE department_id = :did",

          [180],

          function(err, result)

          {

            if (err) {

              console.error(err.message);

              return;

            }

            console.log(result.rows);

            console.log(result.metaData);

          });

      });

    Christopher Jones-Oracleshadowknight
  • Christopher Jones-Oracle
    Christopher Jones-Oracle Member Posts: 1,656 Employee
    edited May 4, 2015 6:54PM

    Your solution is still vulnerable to people running 'ps' and seeing your password.

    You could try using https://www.npmjs.com/package/prompt