Skip to content

rcstuber/bookshelf-encrypt-columns

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

This Bookshelf.js plugin enables you to define which model columns are encrypted on save/update. Those columns will also be automatically decrypted when fetched.

Installation

Install the package via npm:

$ npm install --save bookshelf-encrypt-columns

Usage

Require and register the bookshelf-encrypt-columns plugin:

var bookshelf = require('bookshelf')(knex);
var encryptColumns = require('bookshelf-encrypt-columns');

bookshelf.plugin(encryptColumns, {
  cipher: 'a-valid-cipher',
  key: 'your-strong-key'
});

Both cipher and key are required. By default, the plugin will use the aes-256-ctr cipher. For a list of valid ciphers, please see the Node Crypto docs. Be sure to store your key in a secure location and avoid passing it to the plugin directly.

Define which columns are encrypted with the encryptedColumns prototype property:

bookshelf.Model.extend({
  encryptedColumns: ['secret'],
  tableName: 'test'
});

License

MIT

Credits

This plugin was inspired by and borrows heavily from the bookshelf-json-columns plugin.

About

Automagically encrypt/decrypt database columns via Bookshelf.js

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 100.0%