Skip to content

Commit c500faf

Browse files
authored
Improve security section (parse-community#823)
* refactored security section * Fixed absolute URLs
1 parent f46829a commit c500faf

File tree

1 file changed

+20
-14
lines changed

1 file changed

+20
-14
lines changed

_includes/cloudcode/cloud-code.md

+20-14
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,7 @@ Parse.Cloud.define('adminFunctionTwo', request => {
249249

250250
```
251251

252-
### Some considerations to be aware of
252+
### Considerations
253253
- The validation function will run prior to your Cloud Code Functions. You can use async and promises here, but try to keep the validation as simple and fast as possible so your cloud requests resolve quickly.
254254
- As previously mentioned, cloud validator objects will not validate if a masterKey is provided, unless `validateMasterKey:true` is set. However, if you set your validator to a function, the function will **always** run.
255255

@@ -672,9 +672,6 @@ Parse.Cloud.afterFind(Parse.User, async (request) => {
672672
})
673673
```
674674
675-
### Some considerations to be aware of
676-
- If you use the `masterKey` to fetch a pointer in an `afterFind` trigger, it will be sent in full to the client. Prior to returning to the client, be sure to check that the returned objects and pointers do not contain information that the client should not be able to access
677-
678675
# Session Triggers
679676
680677
## beforeLogin
@@ -692,8 +689,7 @@ Parse.Cloud.beforeLogin(async request => {
692689
});
693690
```
694691
695-
### Some considerations to be aware of
696-
692+
### Considerations
697693
- It waits for any promises to resolve
698694
- The user is not available on the request object - the user has not yet been provided a session until after beforeLogin is successfully completed
699695
- Like `afterSave` on `Parse.User`, it will not save mutations to the user unless explicitly saved
@@ -721,7 +717,7 @@ Parse.Cloud.afterLogout(async request => {
721717
});
722718
```
723719
724-
### Some considerations to be aware of
720+
### Considerations
725721
- Like with `afterDelete` triggers, the `_Session` object that is contained in the request has already been deleted.
726722
727723
#### The trigger will run...
@@ -830,7 +826,7 @@ Parse.Cloud.afterLiveQueryEvent('MyObject', async (request) => {
830826
});
831827
```
832828
833-
### Some considerations to be aware of
829+
### Considerations
834830
- Live Query events won't trigger until the `afterLiveQueryEvent` trigger has completed. Make sure any functions inside the trigger are efficient and restrictive to prevent bottlenecks.
835831
836832
## onLiveQueryEvent
@@ -871,13 +867,23 @@ To learn more, read the [Parse LiveQuery Protocol Specification](https://github.
871867
872868
"connect" differs from "ws_connect", the former means that the client completed the connect procedure as defined by Parse Live Query protocol, where "ws_connect" just means that a new websocket was created.
873869
874-
# Using the Master Key in cloud code
875-
Set `useMasterKey:true` in the requests that require master key.
870+
# Security
871+
## Master Key
872+
To override object and class access permissions, you can set `useMasterKey: true` if the request accepts the master key option.
873+
874+
### Examples
875+
876+
```javascript
877+
query.find({ useMasterKey: true });
878+
```
876879
877-
## Examples:
880+
```javascript
881+
object.save(null, { useMasterKey: true });
882+
```
878883
879884
```javascript
880-
query.find({useMasterKey:true});
881-
object.save(null,{useMasterKey:true});
882-
Parse.Object.saveAll(objects,{useMasterKey:true});
885+
Parse.Object.saveAll(objects, { useMasterKey: true });
883886
```
887+
888+
### Considerations
889+
- If you set `masterKey: true` when fetching objects with a query or relation in [Cloud Functions]({{ site.baseUrl }}/cloudcode/guide/#cloud-functions) or [Find Triggers]({{ site.baseUrl }}/cloudcode/guide/#find-triggers), the complete object will be returned. You may want to remove object properties that the client should not be able to access before sending it to the client.

0 commit comments

Comments
 (0)