Node.js implementation of Bcrypt as a micro service.
Clone or download
Latest commit 55b8b2a Jan 8, 2019
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
bin
conf add cli Nov 11, 2015
lib/pipeline
messages
protocol Update auth0-instrumentation to 2.18.0, Add tracing support (#42) Sep 24, 2018
test
.dockerignore
.eslintrc.yml
.gitignore
.npmignore
.travis.yml
Dockerfile
LICENSE
README.md
client-test.js
client.js
index.js
package-lock.json
package.json
pool.js
server.js
tracer.js
worker.js

README.md

Build Status

Bcrypt as a service (node.js)

This module is a client and server.

Server

Installation:

sudo npm i -g auth0/node-baas

Start a baas server on port 9485 and salt with 10 iterations:

baas -p 9485 -s 10

How it works?

The server listen in a TCP port. The protocol buffer is defined in /protocol.

The server start N workers by default N is the number of COREs on the system.

Every request (hash or compare) is assigned to a worker. A worker can handle one operation at the time. If all workers are "busy", the server will reply the request with "SERVER IS BUSY" error to the client. The client automatically retries the request in another connection.

Client

Install:

npm i auth0/node-baas

The client keeps api-level compatibility with node-bcrypt.

var BaasClient = require('baas').Client;

var baas = new BaasClient({
  port: 9485,
  host: 'my-baas-load-balancer'
  pool: {
    maxConnections: 20,
    maxRequestsPerConnection: 10
  }
});

//hash a password
baas.hash('plainTextPassword', function (err, hash) {
  console.log(hash)
});

//compare a password
baas.compare('plainTextPassword', 'bcryptHash', function (err, success) {
  console.log(success)
});

The client also support ssl:

var BaasClient = require('baas').Client;
var baas = new BaasClient({
  port: 9485,
  host: 'my-baas-load-balancer',
  protocol: 'baass'
  pool: {
    maxConnections: 20,
    maxRequestsPerConnection: 10
  }
});

//or
var baas = new BaasClient({
  uri: 'baass://my-baas-load-balancer',
  pool: {
    maxConnections: 20,
    maxRequestsPerConnection: 10
  }
});

To install on ubuntu/debian

sudo apt-key adv --keyserver keyserver.ubuntu.com --recv F63E3D3A
sudo sh -c 'echo deb http://debs.auth0.com/ stable main > /etc/apt/sources.list.d/auth0.list'
sudo aptitude update
sudo aptitude install -y baas

Author

Auth0

License

This project is licensed under the MIT license. See the LICENSE file for more info.