解析云中的主密钥是什么? [英] What does the Master Key in Parse Cloud?

查看:89
本文介绍了解析云中的主密钥是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有人可以简要地解释一下解析云代码中的master key是什么吗?

Could somebody explain me in brief that what does the master key within Parse Cloud Code?

最近实现的CC功能(使用主键)是否可以改变其他非Cloud Code功能的行为?

Is it possible that a recently implemented CC function (which uses the master key) can change the behavior of other non Cloud Code functions?

作为一个实例,您拥有一个正常运行的解决方案,该解决方案使当前用户可以将其他PFUser对象添加到关系中,并在需要时将其删除.在此之前,您不需要master key,因为您是用当前用户编写PFUser currentUser的.稍后,在要编写另一个PFUser对象的位置上创建另一种类型的用户关系,现在这一次您需要使用master key,因为如果没有此功能,currentUser将无法编写其他PFUser对象.因此,您将创建一个Cloud Code文件来处理此问题,并赋予实际的currentUser合法性以编写其他用户.现在一切正常,当实际用户想要编写其他用户对象时,我们不会出错.但是发生了什么事.当currentUser试图从他的第一个PFRelation中删除数据时(在新的cc函数之前也可以使用),他得到的错误..user must be authenticated via logIn or signUp与我们第一次尝试写另一个用户之前得到的错误相同.

As an instance, you have a properly working solution which lets to the current user to add other PFUser objects into a relation and delete them if needed. Until this point you don't need the master key because you writing the PFUser currentUser with the current user. Later you create another type of user relation where you want to write another PFUser object, now this time you need to use master key, because without this the currentUser won't be able to write another PFUser objects. Therefore you create a Cloud Code file to handle this issue and give legitimacy to the actual currentUser for writing other users. Now everything is working fine, we don't get an error when the actual user wants to write other user objects. However something happened. When currentUser tries to delete data from his first PFRelation (that was also worked before the new cc function) he gets the same error ..user must be authenticated via logIn or signUp that we got before we first tried to write an other user.

我猜是因为我们使用主密钥,它将覆盖现有/原始的安全选项 我们需要为其他所有功能实现它.我对吗?如果是,我该如何处理?还是可以在main.js cc文件中设置不同的限制,并且每个旧"功能都将以相同的方式以及使用主密钥的新功能以相同的方式工作?

I guess since we using the master key it will override the existing/original security options and we need to implement it for every other function. Am i right? If yes, how should i deal with this? Or is it possible to just set different restrictions inside the main.js cc file, and every "old" function will work in the same way plus the new one which using master key?

我非常感谢您提供有关该主题的任何信息,因为这对我来说是一个巨大的黑洞.

I would really appreciate any information about the topic, because it's a huge black hole for me.

推荐答案

主密钥将覆盖所有安全性,例如ACL或基于类的权限.就像"root"密码一样.

The master key overrides all security, such as ACL or Class-based permissions. It is like the "root" password.

您仅应在需要时调用它,因为使用Parse.Cloud.useMasterKey();启用当前请求后,当前请求的所有方法都将使用主密钥.

You should invoke it only when needed, because all methods for the current request after it is enabled with Parse.Cloud.useMasterKey(); will use the master key.

您可以通过将选项传递给各个query/save/etc方法来有选择地使用它.

You can selectively use it by passing options to the individual query/save/etc methods.

query.find({ useMasterKey: true }).then(function(results) { // ...

object.save(null, { useMasterKey: true }).then( // ...

这篇关于解析云中的主密钥是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆