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: adminforth/documentation/docs/tutorial/03-Customization/12-security.md
+69-1Lines changed: 69 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -140,4 +140,72 @@ server {
140
140
proxy_set_headerX-Forwarded-For$remote_addr;
141
141
}
142
142
}
143
-
```
143
+
```
144
+
145
+
146
+
147
+
### Backend-only fields
148
+
149
+
Some fields should never be accessed on frontend. For example, `hashed_password` field which is always created using CLI initial app, should never be passed to frontend due to security reasons.
150
+
If any user of system can read `hashed_password` of another user, it can lead to account compromise.
151
+
152
+
To eliminate it we have 2 options:
153
+
154
+
1) Do not list `password_hash` in the `columns` array of the resource. If AdminForth knows nothing about field
155
+
it will never pass this field to frontend!
156
+
2) Define `password_hash` in columns way but set `backendOnly`.
157
+
158
+
The second option is more explicit and should be preferred. This option is used by default in CLI-bootstrapped projects:
159
+
160
+
```ts
161
+
{
162
+
name: 'password_hash',
163
+
type: AdminForthDataTypes.STRING,
164
+
showIn: { all: false },
165
+
backendOnly: true, // will never go to frontend
166
+
}
167
+
```
168
+
169
+
#### Dynamically hide fields depending on user ACL / role
170
+
171
+
You can use `column.showIn` to show or hide column for user depending on his role.
172
+
173
+
However even if `showIn` value (or value returned by showIn function) is `false`, record value will still go to frontend and will be
174
+
visible in the Network tab, so advanced user can still access field value. We did it in this way to provide AdminForth developers with ability to quickly use any record field in custom components.
175
+
176
+
However if you need securely hide only certain fields depending on role, you should use `column.backendOnly` and pass function there.
0 commit comments