Skip to content

Commit 80a7c51

Browse files
authored
Add docs for secure input (#463)
Just some quick docs for the secure input.
1 parent caebb48 commit 80a7c51

File tree

6 files changed

+80
-1
lines changed

6 files changed

+80
-1
lines changed

.github/workflows/pr_toolkit.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ jobs:
1010
runs-on: ubuntu-20.04
1111
steps:
1212
- name: clone pull-request-toolkit-action
13-
uses: actions/checkout@v2
13+
uses: actions/checkout@v3
1414
with:
1515
repository: apify/pull-request-toolkit-action
1616
path: ./.github/actions/pull-request-toolkit-action

content/docs/actors.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ A single isolated actor consists of source code and various settings. You can th
3232
* [Continuous integration]({{@link actors/development/continuous_integration.md}})
3333
* [Environment variables]({{@link actors/development/environment_variables.md}})
3434
* [Input schema]({{@link actors/development/input_schema.md}})
35+
* [Secret input]({{@link actors/development/secret_input.md}})
3536
* [Source code]({{@link actors/development/source_code.md}})
3637
* [State persistence]({{@link actors/development/state_persistence.md}})
3738
* [Testing and maintenance]({{@link actors/development/testing_and_maintenance.md}})
30.2 KB
Loading
Binary file not shown.

content/docs/actors/development/input_schema.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,7 @@ Properties:
166166
| `enum` | [String] | Required if <br/>`editor` <br/>is `select` | Using this field, you can limit values <br/>to the given array of strings. <br/>Input will be displayed as select box. |
167167
| `enumTitles` | [String] | No | Titles for the `enum` keys described. |
168168
| `nullable` | Boolean | No | Specifies whether `null` <br/>is an allowed value. |
169+
| `isSecret` | Boolean | No | Specifies whether the input field<br />will be stored encrypted.<br />Only available <br />with `textfield` and `textarea` editors. |
169170

170171
> When using escape characters `\` for the regular expression in the `pattern` field, be sure to escape them to avoid invalid JSON issues. For example, the regular expression `https:\/\/(www\.)?apify\.com\/.+` would become `https:\\/\\/(www\\.)?apify\\.com\\/.+`.
171172
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
---
2+
title: Secret input
3+
description: Learn about making some actor input fields secret and encrypted. Ideal for passing passwords, API tokens or login cookies to actors.
4+
paths:
5+
# NOTE: IF ADDING A NEW PATH, LEAVE THE OLD ONES FOR REDIRECTS
6+
- actors/development/secret-input
7+
---
8+
9+
# [](#secret-input)Secret input
10+
11+
The secret input feature allows you to mark some actor input fields as secret, causing them to be encrypted when saving an input for an actor. The input can then be decrypted only inside the actor.
12+
13+
## Setting an input field as secret
14+
15+
To make an input field secret, just add a `"isSecret": true` setting to the input field in the actor's [input schema]({{@link actors/development/input_schema.md}}), like this:
16+
17+
<!-- eslint-skip -->
18+
```json
19+
{
20+
// ...
21+
"properties": {
22+
// ...
23+
"password": {
24+
"title": "Password",
25+
"type": "string",
26+
"description": "A secret, encrypted input field",
27+
"editor": "textfield",
28+
"isSecret": true
29+
},
30+
// ...
31+
},
32+
// ...
33+
}
34+
```
35+
36+
The editor for this input field will then turn into a secret input, and when you edit the field value, it will be stored encrypted.
37+
<img src="{{@asset actors/development/images/secret-input-editor.webp}}" alt="Secret input editor" style="width: 100%; max-width: 822px;"/>
38+
39+
This is only available for `string` inputs, and the editor type is limited to `textfield` or `textarea`.
40+
41+
## Reading secret input fields
42+
43+
When you read the actor input through `Actor.getInput()`, the encrypted fields are automatically decrypted, without any additional code needed (starting with the [`apify` package](https://www.npmjs.com/package/apify) version 3.1.0).
44+
45+
<!-- eslint-skip -->
46+
```js
47+
> await Actor.getInput();
48+
{
49+
username: 'username',
50+
password: 'password'
51+
}
52+
```
53+
54+
If you read the `INPUT` key from the actor run's default key-value store directly, you will still get the original, encrypted input value.
55+
56+
<!-- eslint-skip -->
57+
```js
58+
> await Actor.getValue('INPUT');
59+
{
60+
username: 'username',
61+
password: 'ENCRYPTED_VALUE:Hw/uqRMRNHmxXYYDJCyaQX6xcwUnVYQnH4fWIlKZL2Vhtq1rZmtoGXQSnhIXmF58+DjKlMZpTlK2zN3YUXk1ylzU6LfXyysOG/PISAfwm27FUgy3IfdgMyQggQ4MydLzdlzefX0mPRyixBviRcFhRTC+K7nK9lkATt3wJpj91YAZm104ZYkcd5KmsU2JX39vxN0A0lX53NjIenzs3wYPaPYLdjKIe+nqG9fHlL7kALyi7Htpy91ZgnQJ1s9saJRkKfWXvmLYIo5db69zU9dGCeJzUc0ca154O+KYYP7QTebJxqZNQsC8EH6sVMQU3W0qYKjuN8fUm1fRzyw/kKFacQ==:VfQd2ZbUt3S0RZ2ciywEWYVBbTTZOTiy'
62+
}
63+
```
64+
65+
## Encryption mechanism
66+
67+
The encryption mechanism used for encrypting the secret input fields is the same dual encryption as in [PGP](https://en.wikipedia.org/wiki/Pretty_Good_Privacy#/media/File:PGP_diagram.svg).
68+
69+
The secret input field is encrypted using a random key, using the `aes-256-gcm` cipher, and then the key is encrypted using a 2048-bit RSA key.
70+
The RSA key is unique for every user and actor combination, so no actor can decrypt input meant for other actor run of the same user, and no user can decrypt input of actor runs of a different user, but same actor.
71+
72+
The decryption keys are passed to the actor runs as environment variables, so the input decryption happens only inside of the actor run.
73+
74+
## Example actor
75+
76+
If you want to test the secret input live, check out the [Example Secret Input](https://console.apify.com/actors/O3S2UlSKzkcnFHRRA) actor in Apify Console.
77+
If you want to dig in deeper, you can check out its [source code](https://github.com/apify/actor-example-secret-input) on GitHub.

0 commit comments

Comments
 (0)