How to use feathers-permissions - 3 common examples

To help you get started, we’ve selected a few feathers-permissions examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github implustech / famn / app / service / user / hooks / index.ts View on Github external
import * as globalHooks from '../../../hooks'
const hooks = require('feathers-hooks')
const auth = require('feathers-authentication')
const local = require('feathers-authentication-local')
const permissions = require('feathers-permissions')

const adminPermission = permissions.hooks.checkPermissions({
  roles: ['ADMIN'],
  on: 'user',
  field: 'roles'
})

const before = {
  all: [
  ],
  find: [
    adminPermission,
    permissions.hooks.isPermitted(),
    auth.hooks.authenticate('jwt')
  ],
  get: [
    auth.hooks.authenticate('jwt')
  ],
github implustech / famn / app / service / user / hooks / index.ts View on Github external
create: [
    adminPermission,
    permissions.hooks.isPermitted(),
    local.hooks.hashPassword()
  ],
  update: [
    auth.hooks.authenticate('jwt'),
    local.hooks.hashPassword()
  ],
  patch: [
    auth.hooks.authenticate('jwt'),
    local.hooks.hashPassword()
  ],
  remove: [
    adminPermission,
    permissions.hooks.isPermitted(),
    auth.hooks.authenticate('jwt'),
  ]
}

const after = {
  all: [hooks.remove('password')],
  find: [],
  get: [],
  create: [],
  update: [],
  patch: [],
  remove: []
}

export default {
  before,
github foxhound87 / rfx-stack / src / api / services / user / hooks.before.js View on Github external
import { hooks as perms } from 'feathers-permissions';
import { setUUID } from '@/api/hooks/setUUID';

/**
  Hook: before
  Service: user
*/
export default {
  all: [],
  find: [
    auth.authenticate(['jwt', 'local']),
    perms.checkPermissions({ service: 'user' }),
  ],
  get: [
    auth.authenticate(['jwt', 'local']),
    perms.checkPermissions({ service: 'user' }),
  ],
  create: [
    setUUID(),
    local.hashPassword(),
  ],
  update: [
    auth.authenticate(['jwt', 'local']),
    perms.checkPermissions({ service: 'user' }),
  ],
  patch: [
    auth.authenticate(['jwt', 'local']),
    perms.checkPermissions({ service: 'user' }),
  ],
  remove: [
    auth.authenticate(['jwt', 'local']),
    perms.checkPermissions({ service: 'user' }),

feathers-permissions

Simple permissions module for Feathers

MIT
Latest version published 4 years ago

Package Health Score

60 / 100
Full package analysis