AMP-SCZ / dpdash

Deep phenotyping dashboard
Other
2 stars 1 forks source link

Change DPdash password #38

Open tashrifbillah opened 3 years ago

tashrifbillah commented 3 years ago

https://github.com/AMP-SCZ/dpdash/blob/37f824e18cfd9ae279d8e09828fcd5d0cbbaf37c/singularity/setup.sh#L11-L13

tashrifbillah commented 2 years ago

Define the hash and verifyHash functions directly in node interpreter:

Singularity> pwd
/sw/apps/dpdash/

Singularity> node
Welcome to Node.js v16.4.0.
Type ".help" for more information.
> const { randomBytes, pbkdf2Sync } = require('crypto')
undefined
> const hash = (text) => {
  const salt = randomBytes(16).toString('hex');
  const hash = pbkdf2Sync(text, salt, 2048, 32, 'sha512').toString('hex');
  return [salt, hash].join('$');
}

const verifyHash = (text, original) => {
  const originalHash = original.split('$')[1];
  const salt = original.split('$')[0];
  const hash = pbkdf2Sync(text, salt, 2048, 32, 'sha512').toString('hex');
  return hash === originalHash;
}
undefined
> hash('dpdash')
'54c544608bba7b3520b7639d693952a1$873e1b573b413c858bdeb462d2d813d21b937cd3be2a80a315a40a6b53b80dd6'

In the last line, generate hash for your arbitrary password and update the corresponding collection in dpdmongo.users.