简体   繁体   English

如何在 Sequelize / Node.js 中设置沙箱帐户?

[英]How to set up a sandbox account in Sequelize / Node.js?

I am trying to set up a sandbox user in Sequelize (that can read from the database, but cannot write / edit it).我正在尝试在 Sequelize 中设置一个沙箱用户(可以从数据库中读取,但不能写入/编辑它)。 I already have my user model and relations in place.我已经有了我的用户模型和关系。 I can easily add a role enum to the user model to specify one or more "sandbox" accounts.我可以轻松地向用户模型添加角色枚举以指定一个或多个“沙箱”帐户。

However, how should I go about setting those permission?但是,我应该如何设置这些权限? Do I have to check every single database post / delete / update route against user permissions or can I use a middleware somehow?我是否必须根据用户权限检查每个数据库发布/删除/更新路由,还是可以以某种方式使用中间件?

You may need to create a table to store user wise, access on different database and different permissions (read/write etc).您可能需要创建一个表来存储用户,访问不同的数据库和不同的权限(读/写等)。

Create a middleware which authorizes user and this middleware is responsible to authorize user to do action, based on that perform further actions创建一个授权用户的中间件,该中间件负责授权用户执行操作,基于该执行进一步的操作

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM