Doubts of ACL with Node.js!

Asked

Viewed 212 times

1

People I am trying to apply Authorization (ACL) using the plugin npm "node_acl" in a Node.js application with express, I am trying to implement as explained in the documentation.. however I am having difficulties to apply this in practice.. I have the following code in a projectController.js file

import express from 'express';
import authMiddleware from '../middlewares/auth';
import mongoose from '../../database';

const router = express.Router();

let acl = require('acl');
acl = new acl(new acl.mongodbBackend(mongoose.connection.db, 'acl_'));

acl.allow("admin", "/projects", "*");

router.use(authMiddleware);
router.use(acl.middleware());

router.get('/', (req, res) => {
  res.send({ 
    ok: true, 
    user: req.userId
  })
});

export default (app) => app.use('/projects', router);

I was wrong about something?

Thank you!

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.