【发布时间】:2018-06-22 02:09:13
【问题描述】:
我即将为我的学生打开一个 Meteor 网络应用程序,我显然需要将用户集合中的数据保密(每个学生都应该有权访问她自己的“结果”)。但是“管理员”角色需要拥有更多访问权限。这是发布信息(/server/main.js):
Meteor.publish('userData', function() {
if (Roles.userIsInRole(this.userId, ['admin'])) {
return Meteor.users.find({}, {fields: {
_id: 1,
createdAt: 1,
username: 1,
emails: 1,
profile: 1,
lastAccess: 1,
roles: 1
}}
)};
if (this.userId) {
return Meteor.users.find({_id: this.userId}, {fields: {
results: 1
}
});
} else {
this.ready();
}
});
我的问题是:这种发布设置对于恶意用户是否足够安全?
【问题讨论】:
-
您可以将
type密钥保存在users集合中,并在调用方法时检查服务器端的访问/权限。在客户端,任何人都可以操作数据,但是当您从服务器端发送数据时,您可以执行必要的检查。