You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: _includes/parse-server/class-level-permissions.md
+186-1
Original file line number
Diff line number
Diff line change
@@ -2,7 +2,61 @@
2
2
3
3
Class level permissions are a security feature from that allows one to restrict access on a broader way than the [ACL based permissions]({{ site.baseUrl }}/rest/guide/#security).
4
4
5
-
## `requiresAuthentication`
5
+
## CRUD operations
6
+
7
+
You can set permissions per operation per class.
8
+
9
+
Operations:
10
+
11
+
-`get`
12
+
-`find`
13
+
-`count`
14
+
-`create`
15
+
-`update`
16
+
-`delete`
17
+
-`addField`
18
+
19
+
20
+
Allowed entities are:
21
+
22
+
-`*` (Public)
23
+
-`[objectId]` (User)
24
+
-`role:[role_name]` (Role)
25
+
-`requiredAuthentication` (Authenticated Users)
26
+
-`pointerFields`
27
+
28
+
And any combinations of the above.
29
+
30
+
The syntax is:
31
+
32
+
```js
33
+
// PUT http://localhost:1337/schemas/:className
34
+
// Set the X-Parse-Application-Id and X-Parse-Master-Key header
35
+
// body:
36
+
{
37
+
classLevelPermissions:
38
+
{
39
+
"get": {
40
+
"*":true, // means Public access
41
+
"s0meUs3r1d":true, // key must be an id of `_User`
42
+
"role:admin":true, // key must be `role:${role_name}`
43
+
"requiresAuthentication":true, // any authenticated users
44
+
"pointerFields": ["onwer", "followers"] // field names in this class referring to _User(s)
45
+
}
46
+
...
47
+
}
48
+
}
49
+
```
50
+
51
+
### `*` - Public access
52
+
53
+
Allows anyone despite authentication status to execute operation.
54
+
55
+
### Users, Roles
56
+
57
+
This works exactly as ACL's
58
+
59
+
### `requiresAuthentication`
6
60
7
61
If you want to restrict access to a full class to only authenticated users, you can use the `requiresAuthentication` class level permission. For example, you want to allow your **authenticated users** to `find` and `get` objects from your application and your admin users to have all privileges, you would set the CLP:
8
62
@@ -29,3 +83,134 @@ If you want to restrict access to a full class to only authenticated users, you
29
83
```
30
84
31
85
Note that this is in no way securing your content. If you allow anyone to log in to your server, any client will be able to query this object.
86
+
87
+
### `pointerFields`
88
+
89
+
This lets you dynamically enforce permissions based on particular object's fields value.
90
+
Must be an array of field names already existing in this class. Supports only fields of types: `Pointer<_User>` or `Array` (containing Pointers to `_User`s). When evaluating the permission Parse Server will also assume user pointers stored in these fields and allow such users an operation. You can think of it as a virtual ACL or a dynamic role defined per-object in its own field.
-`create` operation can't be allowed by pointer, because there is literally no object to check it's field before it is created);
216
+
-`addField` by pointer will only work when you update an object with a new field, but it is advised to control addField permission using other means instead (e.g. restrict to a role or particular admin user by id).
0 commit comments