1.0.1 • Published 10 years ago

baucis-security-plugin v1.0.1

Weekly downloads
3
License
MIT
Repository
github
Last release
10 years ago

Baucis Security Plugin

This plugin adds a security middleware to baucis.

Installation

npm install baucis-security-plugin

Usage

All you need to do is to overhand a function that allows this plugin to decide if the current instance is allowed to be accessed. You can do this, for example with the mongoose-user-resolver-plugin. This plugin adds a method getUserId to mongoose models. By comparing the current user and the owner of the instance (getUserId) this function realizes a general access rule.

var security = require('baucis-security-plugin');
security(function (instance, ctx) {
    return instance.getUserId()
        .then(function (userId) {
            if (userId.toString() !== ctx.req.session.passport.user) {
                return Q(false);
            } else {
                return Q(true);
            }
        });
});

This means that a user can not modify entries that belong to a different user.

Code-Quality

Current Jenkins report for this project:

  • BuildStatus
  • Test
  • LastBuild
  • CodeCoverageInJenkins
1.0.1

10 years ago

1.0.0

10 years ago