conceptadev / 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.
MIT License
4 stars 1 forks source link

@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