@inspire-platform/sails-hook-permissions

Comprehensive user permissions and entitlements system for sails.js and Waterline. Supports user authentication with passport.js, role-based permissioning, object ownership, and row-level security.

Stats

StarsIssuesVersionUpdatedCreatedSize
@inspire-platform/sails-hook-permissions
422.0.0-15-hf19 months ago5 years agoMinified + gzip package size for @inspire-platform/sails-hook-permissions in KB

Readme

@inspire-platform/sails-hook-permissions

NPM version

Comprehensive sails.js user permissions and entitlements system. Supports user authentication with passport.js, role-based permissioning, object ownership, and row-level security.

Contents

Install

$ npm install @inspire-platform/sails-hook-permissions --save

Quickstart

1. configure sailsrc

{
  "generators": {
    "modules": {
      "permissions-api": "@inspire-platform/sails-hook-permissions/generator"
    }
  }
}

2. run generator

WARNING! The generator is not currently up to date with the 2.x.x releases.

$ sails generate permissions-api

3. Manual configuration

Env vars

variable description default
ADMIN_USERNAME admin username admin
ADMIN_EMAIL admin user email address admin@example.com
ADMIN_PASSWORD admin user password admin1234

config/permissions.js (or config/local.js)

...
permissions: {
  adminUser: {
    username: 'admin',
    email: 'admin@example.com',
    password: 'admin1234'
    // add custom fields here if your model requires them
  }
},
...

config/policies.js

'*': [
  'basicAuth',
  'passport',
  'sessionAuth',
  'ModelPolicy',
  'AuditPolicy',
  'OwnerPolicy',
  'PermissionPolicy',
  'RolePolicy',
  'CriteriaPolicy'
],

AuthController: {
  '*': [ 'passport' ]
}

4. Login

You can now login using the aforementioned default login data or the admin settings you specified using the /auth/local endpoint.

{
    "identifier": "admin@example.com",
    "password": "admin1234"
}

License

MIT

If you find any bugs or have a feature request, please open an issue on github!

The npm package download data comes from npm's download counts api and package details come from npms.io.