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: access-policies.md
+60-11Lines changed: 60 additions & 11 deletions
Original file line number
Diff line number
Diff line change
@@ -6,9 +6,13 @@ id: access
6
6
7
7
Access Policies ensure that we provide specific access to resources for users. You may want to open publicly the **read** access for an entity while limiting **creation** to logged in users for example.
8
8
9
-
Acces policies are a way to implement **Authorization** following the RBAC (Role-Based Access Control) method. Indeed it is possible to create different entities (ex: User, Manager...) with different access to resources.
9
+
Access policies are a way to implement **Authorization** following the RBAC (Role-Based Access Control) method. Indeed it is possible to create different entities (ex: User, Manager...) with different access to resources. You also can limit access to a user own's records using [ownership-based access](#ownership-based-access).
10
10
11
-
Policies can be added to [entities](./entities.md) or [endpoints](./endpoints.md).
11
+
Policies can be added to [entities](./entities.md) and [endpoints](./endpoints.md).
12
+
13
+
:::info
14
+
By default, all CRUD rules access are set to **admin** and thus only available for logged-in admins. Custom endpoints are **public** by default.
15
+
:::
12
16
13
17
## Syntax
14
18
@@ -33,8 +37,6 @@ entities:
33
37
34
38
In this case, everyone can see the **Invoice** items, only logged-in **Users** can create new ones. Updating an Invoice is restricted to [Admins](./auth.md#admins) only and no one can delete them (not even Admins).
35
39
36
-
By default, all rules access are set to **admin** and thus only visible by logged-in **Admins**.
| **restricted** | Only logged-in users have access to it. If _allow_ key specifies one or several entities, users logged in as other entities will not have access. Admins always have access to restricted rules | 🔒 |
51
-
| **admin** | Only [admins](./auth.md#admins) have access | 👨🏻💻 |
52
-
| **forbidden** | No one has access, not even admins | 🚫 |
| **restricted** | Only logged-in users have access to it. If _allow_ key specifies one or several entities, users logged in as other entities will not have access. If _condition_ is set to `self`, it limits access to the item owner. Admins always have access to restricted rules | 🔒 |
53
+
| **admin** | Only [admins](./auth.md#admins) have access | 👨🏻💻 |
54
+
| **forbidden** | No one has access, not even admins | 🚫 |
53
55
54
56
### Entity rules
55
57
@@ -63,18 +65,65 @@ Each entity has **5 rules** where one or several access policies can be applied:
63
65
64
66
By default, all rules have the [admin access type](#access-types)
65
67
68
+
## Ownership-based access
69
+
70
+
Above rules are based on predefined roles, but you many want to grant user access only to their own records. For example, a platform like _Craiglist_ allows its users to create and manage classified ads only for them, not letting users edit others' content.
71
+
72
+
In Manifest, this is done simply by adding the `{condition: 'self'}` to a restricted policy:
73
+
74
+
```yaml
75
+
User:
76
+
properties:
77
+
- name
78
+
authenticable: true
79
+
80
+
Project:
81
+
properties:
82
+
- name
83
+
belongsTo:
84
+
- User # Should belong to an authenticable entity.
Copy file name to clipboardExpand all lines: auth.md
+2-4Lines changed: 2 additions & 4 deletions
Original file line number
Diff line number
Diff line change
@@ -47,9 +47,7 @@ entities:
47
47
- name
48
48
```
49
49
50
-
Authenticable entities have 2 extra properties that are used as credentials to log in: `email` and `password`. You do not need to specify them.
51
-
52
-
The passwords are automatically hashed using _bcryt_ with 10 salt rounds.
50
+
Authenticable entities have 2 extra properties that are used as credentials to log in: `email` and `password`. You do not need to specify them.The `email` property expects a unique valid emails and the `password` property is automatically hashed using _bcryt_ with 10 salt rounds.
53
51
54
52
## Actions
55
53
@@ -187,7 +185,7 @@ Logout removes the token from future request headers.
187
185
</TabItem>
188
186
<TabItem value="sdk" label="JS SDK" default>
189
187
```js
190
-
// All future calls will lose the "Authorization" header.
188
+
// Resets the "Authorization" header for all future calls.
Copy file name to clipboardExpand all lines: entities.md
+3-1Lines changed: 3 additions & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -246,6 +246,8 @@ Timestamp field (ISO 8601 Format)
246
246
```
247
247
248
248
#### Email
249
+
You can create one-to-many relationships or many-to-many relationships. Defining relationships in your entities allows you to load relations when you query them and also filter by relations.
250
+
249
251
250
252
```yaml
251
253
- { name: email, type: email }
@@ -341,7 +343,7 @@ The location type consists in a object with `lat` and `lng` coordinates.
341
343
342
344
## Relations
343
345
344
-
You can create **one-to-many** relationships or **many-to-many** relationships.
346
+
You can create **one-to-many** relationships or **many-to-many** relationships. Defining relationships in your entities allows you to [load relations](./crud.md#load-relations) when you query them and also [filter your query by relations](./crud.md#filter-by-relation).
0 commit comments