Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

cradle_security

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cradle_security

Add users, roles and authorization creation commands to Cradle module

  • 0.2.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

Cradle Security

This module is a simple extension of the Cradle module for CouchDB database.

Install

To install this module use npm as usual:

$ npm install cradle_security

or

$ npm install cradle_security --save-dev

if you want to run tests.

Usage

CouchDB setup

// load module
var couchDB = require('cradle_security')({
    debug: true,                // set true to see all log messages
    adminUsername: "admin",     // set your admin username
    adminPassword: "password"   // set your admin password
});

// setup the database
couchDB.setup({
    host: '127.0.0.1',          // CouchDB host (default localhost only)
    port: 5984,                 // CouchDB port
    cache: true,                // CouchDB cache
    timeout: 5000               // connection timeout
});

// create a new connection
conn = new (couchDB.Connection)({
    auth: {
        username: "admin",      // set your admin username
        password: "password"    // set your admin password
    }
});

Create new database with new user

db.createWithUser(
    "new_user",                 // username
    "new_user_password",        // password
    [ "admins" ],               // array of roles
    function (err, res) {       // callback
        console.log(res);       // it should be { ok: true } if no error occurred
    }
);

Create new user

db.addUser(
    "new_user",                 // username
    "new_user_password",        // password
    [ "admins" ],               // array of roles
    function (err, res) {       // callback
        console.log(res);       // it should seem
                                // { ok: true, id:
                                // 'org.couchdb.user:new_user',
                                // rev: '1-83d5aba64688501431753b7cc13d7578' }
                                // if no error occurred
    }
);

Delete user

db.delUser(
    "new_user",                 // username
    function (err, res) {       // callback
    console.log(res);           // it should seem
                                // { ok: true, id:
                                // 'org.couchdb.user:new_user',
                                // rev: '2-645980a99208ef5902cb216e5a49526e' }
                                // if no error occurred
    }
);

Add roles to the database

db.addRoles(
    [ "admins" ],               // array of admin roles
    [ "guests" ],               // array of member roles
    function (err, res) {       // callback
        console.log(res);       // it should be { ok: true } if no error occurred
    }
);

Documentation

To create your own documentation you must install JSDuck and type in your terminal:

$ cd /path-of-package
$ ./gen_doc.sh

See full documentation into doc folder and some examples into test folder within the cradle_security package.

For all CouchDB supported function please refer to cradle documentation.

Keywords

FAQs

Package last updated on 08 Jul 2014

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc