Skip to content

Role-based security, authorization, and filtering utilities for thinky and RethinkDB

License

Notifications You must be signed in to change notification settings

shastajs/palisade

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

27 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Role-based security, authorization, and filtering utilities for Thinky/RethinkDB

Install

One command and you're ready to secure your data:

npm install palisade --save

Now, check out the documentation to get started!

Example

The documentation has more detailed examples, but here's a quick peek:

ES6

// your thinky connection instance
import db from 'connections/thinky'
import palisade, { screenDeep } from 'palisade'

const User = db.createModel('User', {
  id: String,
  name: String,
  birthday: Date,
  times: {
    created: Date
  }
})

// Anyone can list and read users and their public fields (id and name)
// Users can update themselves, but only their own birthday
// Admins can create, update, replace, or delete any user
palisade(User, {
  document: {
    read: ['public'],
    create: ['admin'],
    update: ['admin', 'self'],
    replace: ['admin'],
    delete: ['admin']
  },
  read: {
    id: ['public'],
    name: ['public'],
    birthday: ['admin', 'self'],
    times: {
      created: ['admin']
    }
  },
  write: {
    id: ['admin'],
    name: ['admin'],
    birthday: ['admin', 'self'],
    times: {
      created: ['admin']
    }
  }
})

ES5

// your thinky connection instance
var db = require('connections/thinky');
var palisade = require('palisade');
var screenDeep = palisade.screenDeep;

var User = db.createModel('User', {
  id: String,
  name: String,
  birthday: Date,
  times: {
    created: Date
  }
});

// Anyone can list and read users and their public fields (id and name)
// Users can update themselves, but only their own birthday
// Admins can create, update, replace, or delete any user
palisade(User, {
  document: {
    read: ['public'],
    create: ['admin'],
    update: ['admin', 'self'],
    replace: ['admin'],
    delete: ['admin']
  },
  read: {
    id: ['public'],
    name: ['public'],
    birthday: ['admin', 'self'],
    times: {
      created: ['admin']
    }
  },
  write: {
    id: ['admin'],
    name: ['admin'],
    birthday: ['admin', 'self'],
    times: {
      created: ['admin']
    }
  }
});

About

Role-based security, authorization, and filtering utilities for thinky and RethinkDB

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published