Module to be used to read in hashed passwords generate by passhash. This can be used as a replacement for htpasswd for web apps or easy authentication for standalone apps.
Module to be used to read in hashed passwords generated by passhash. This can be used as a replacement for htpasswd for web apps or easy authentication for standalone apps.
npm install passhash-auth
var passhashauth = require'passhash-auth'
The file should contain lines using the default output format of
passhash. For reference:
Checks if a given
user_name is valid. Returns a boolean.
Checks if the given
password are valid. Returns a boolean.
For this example we will assume the user name and password were obtained from a secure source such as a SSL socket. Due to the
checkHashMatch function returning a boolean, you can have it execute anything you want depending on the return value. For our example it will print to stdout either
var passhashauth = require'passhash-auth';passhashauthloadAuthFile__dirname + '/test_auth';var user1 = 'test'pass1 = 'correctPassword'if passhashauthcheckHashMatchuser1 pass1console.log'match';elseconsole.log'nonmatch';