Commit 2662ed3
authored
feat(input_schema): Enable secret objects (#515)
# Secret object/array inputs
Based on the [issue](apify/apify-core#21369):
> An ideal solution would be if we could encrypt objects
This is proposal to enable `isSecret` boolean property for `object` and
`array` fields in Input Schema.
Currently this is available only for `string` fields with editors either
`textfield` or `textarea`.
## Update based on the outcome of discussion in this PR:
- Enable this also for `array` properties (not just `object`)
- Enable "validation" properties like (`minProperties`, `maxProperties`,
sub-schema in the future,..) even for secured fields
- Encrypt the value to string and update the validation logic of JSON
Schema (Ajv) validator to this form of string (encrypted object/array)
as a value for `object`/`array` fields.
- In the encrypted string capture the hash of the field schema (without
unimportant fields like title, description, etc.) so we know that the
stored encrypted value might no longer match the Actor's input schema.
Approach suggested by @jancurn in the discussion below.
The actual implementation stringify the object value and encrypts the
string to final value in form of:
```
"ENCRYPTED_VALUE:FIELD_SCHEMA_HASH:ENCRYPTED_PASSWORD:ENCRYPTED_VALUE" // for strings
"ENCRYPTED_JSON_VALUE:FIELD_SCHEMA_HASH:ENCRYPTED_PASSWORD:ENCRYPTED_VALUE" // for objects/arrays
```
Where the second group (`FIELD_SCHEMA_HASH`) is optional so all existing
stored encrypted values are still matching and are backwards compatible.
-----
### Original description (❗outdated):
>The `object` fields with `isSecret: true` won't be able to specify some
properties that "normal" `object` fields can do, such as: `default`,
`prefill`, `patternKey`, `patternValue`, `minProperties`,
`maxProperties`.
Editor can be only `json` or `hidden`. This restriction is basically the
same as with the secret `string` property.
>
>In addition to change in the Input Schema's JSON schema it's also
needed to change the encryption/decryption logic.
If input is `string`, there is no change and the encrypted value is
stored in `ENCRYPTED_VALUE:base64:base64` form.
In case of `object` input, we need to keep the type of the encrypted
value to be still `object` because of validation of input in other
stages.
>
>This propose to store encrypted objects as object with structure:
>```
>{
> "secret": "encrypted-stringified-json-of-original-object"
>}
>```
>where the `secret` key, contains same string value as normal encrypted
string property.
>
>When decrypting an encrypted value the logic is exactly the same as
with string. We would check if the object has `secret` field and if the
value is string that match the encrypted string regex.
>
>- API, Console and Javascript SDK uses the `@apify/input_secrets` for
encryption/decryption (it's part of this PR)
>- Python SDK uses `apify._crypto` to decrypt secrets here is draft PR
(I didn't test is yet), just to showcase what change >would be needed
there: apify/apify-sdk-python#482
>- The last required change would be in console to handle secret inputs
via input UI. Also draft, but this is tested and >works well:
apify/apify-core#21454
>
>I didn't find any other place where would this change causing issues.1 parent e46c673 commit 2662ed3
File tree
11 files changed
+637
-84
lines changed- packages
- input_schema
- src
- input_secrets/src
- test
11 files changed
+637
-84
lines changedSome generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
49 | 49 | | |
50 | 50 | | |
51 | 51 | | |
| 52 | + | |
52 | 53 | | |
53 | 54 | | |
54 | 55 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
33 | 33 | | |
34 | 34 | | |
35 | 35 | | |
| 36 | + | |
| 37 | + | |
36 | 38 | | |
37 | 39 | | |
38 | 40 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
152 | 152 | | |
153 | 153 | | |
154 | 154 | | |
| 155 | + | |
155 | 156 | | |
156 | 157 | | |
157 | 158 | | |
| |||
166 | 167 | | |
167 | 168 | | |
168 | 169 | | |
169 | | - | |
| 170 | + | |
| 171 | + | |
170 | 172 | | |
171 | 173 | | |
172 | 174 | | |
173 | 175 | | |
174 | 176 | | |
175 | | - | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
176 | 182 | | |
177 | 183 | | |
178 | 184 | | |
179 | | - | |
180 | | - | |
181 | | - | |
182 | | - | |
183 | | - | |
184 | | - | |
185 | | - | |
186 | | - | |
187 | | - | |
188 | | - | |
189 | | - | |
190 | | - | |
191 | | - | |
192 | | - | |
193 | | - | |
194 | | - | |
195 | | - | |
196 | | - | |
197 | | - | |
198 | | - | |
199 | | - | |
200 | | - | |
201 | | - | |
202 | | - | |
203 | | - | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
204 | 221 | | |
205 | | - | |
206 | | - | |
207 | | - | |
208 | | - | |
| 222 | + | |
209 | 223 | | |
210 | | - | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
211 | 248 | | |
212 | 249 | | |
213 | 250 | | |
214 | 251 | | |
215 | 252 | | |
216 | 253 | | |
217 | 254 | | |
218 | | - | |
| 255 | + | |
219 | 256 | | |
220 | 257 | | |
221 | | - | |
222 | 258 | | |
223 | 259 | | |
224 | 260 | | |
| |||
227 | 263 | | |
228 | 264 | | |
229 | 265 | | |
230 | | - | |
231 | | - | |
232 | | - | |
233 | | - | |
| 266 | + | |
234 | 267 | | |
235 | 268 | | |
236 | 269 | | |
237 | 270 | | |
238 | 271 | | |
239 | 272 | | |
240 | | - | |
| 273 | + | |
241 | 274 | | |
242 | 275 | | |
243 | 276 | | |
244 | 277 | | |
245 | | - | |
246 | | - | |
247 | | - | |
248 | | - | |
249 | | - | |
250 | | - | |
251 | | - | |
252 | | - | |
253 | | - | |
254 | 278 | | |
255 | | - | |
256 | | - | |
| 279 | + | |
257 | 280 | | |
258 | | - | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
259 | 330 | | |
260 | 331 | | |
261 | 332 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
| 6 | + | |
6 | 7 | | |
7 | 8 | | |
8 | 9 | | |
| |||
133 | 134 | | |
134 | 135 | | |
135 | 136 | | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
136 | 158 | | |
137 | 159 | | |
138 | 160 | | |
139 | 161 | | |
140 | 162 | | |
141 | 163 | | |
142 | | - | |
| 164 | + | |
143 | 165 | | |
144 | 166 | | |
145 | 167 | | |
| |||
215 | 237 | | |
216 | 238 | | |
217 | 239 | | |
218 | | - | |
| 240 | + | |
219 | 241 | | |
220 | 242 | | |
221 | 243 | | |
| |||
249 | 271 | | |
250 | 272 | | |
251 | 273 | | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
252 | 284 | | |
253 | 285 | | |
254 | 286 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
0 commit comments