Skip to content

Commit 4587702

Browse files
feat(docs): add comprehensive App Secrets documentation to inputs guide (#70)
Co-authored-by: Robin Le Caignec <[email protected]>
1 parent c4708c4 commit 4587702

File tree

1 file changed

+96
-7
lines changed

1 file changed

+96
-7
lines changed

src/guides/build-iapp/inputs.md

Lines changed: 96 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -35,14 +35,15 @@ This guide shows both perspectives for each input type.
3535

3636
## Input types overview
3737

38-
Inside the TEE, your iApp can work with four distinct categories of inputs:
38+
Inside the TEE, your iApp can work with five distinct categories of inputs:
3939

40-
| Input Type | Visibility | Security Level | Purpose | How iApp Accesses It |
41-
| --------------------- | ---------- | -------------- | ------------------------ | ---------------------- |
42-
| **Protected Data** | Public | Encrypted | Data to be processed | Clear files in TEE |
43-
| **Args** | Public | Clear | Configuration parameters | Command line arguments |
44-
| **Input Files** | Public | Clear | Large datasets, models | Clear files in TEE |
45-
| **Requester Secrets** | Private | Encrypted | User's sensitive data | Environment variables |
40+
| Input Type | Visibility | Security Level | Purpose | How iApp Accesses It |
41+
| --------------------- | ---------- | -------------- | -------------------------- | ---------------------- |
42+
| **Protected Data** | Public | Encrypted | Data to be processed | Clear files in TEE |
43+
| **Args** | Public | Clear | Configuration parameters | Command line arguments |
44+
| **Input Files** | Public | Clear | Large datasets, models | Clear files in TEE |
45+
| **Requester Secrets** | Private | Encrypted | User's sensitive data | Environment variables |
46+
| **App Secrets** | Private | Encrypted | Developer's sensitive data | Environment variables |
4647

4748
## 1. Protected Data
4849

@@ -356,6 +357,94 @@ const processProtectedDataResponse =
356357
});
357358
```
358359

360+
## 5. App Secrets
361+
362+
**What they are:** App Secrets are confidential data owned by the iApp developer
363+
that are provisioned during app deployment and made available to your iApp
364+
during execution. They are stored securely in the Secret Management Service
365+
(SMS) and only accessible within the Trusted Execution Environment (TEE).
366+
367+
**When to use:** Use App Secrets for API keys, private keys, tokens, database
368+
credentials, or any sensitive data that belongs to the app developer and needs
369+
to be available to the iApp during execution. Unlike Requester Secrets (which
370+
are provided by users), App Secrets are configured once by the developer and
371+
remain constant across all executions.
372+
373+
::: info
374+
375+
App Secrets are different from Requester Secrets:
376+
377+
- **App Secrets**: Owned by the app developer, configured once during deployment
378+
- **Requester Secrets**: Owned by the user executing the iApp, provided per
379+
execution
380+
381+
:::
382+
383+
### How to Use App Secrets in Your iApp
384+
385+
App Secrets are configured in your `iapp.config.json` during development and
386+
automatically deployed with your iApp. For deployment details, see the
387+
[Build Your iApp guide](/references/iapp-generator/building-your-iexec-app).
388+
389+
#### Configuration in iapp.config.json
390+
391+
Add your App Secret to the project configuration:
392+
393+
```json
394+
{
395+
"defaultChain": "arbitrum",
396+
"projectName": "my-iapp",
397+
"template": "JavaScript",
398+
"appSecret": "{\"API_KEY\":\"sk-1234567890abcdef\",\"DATABASE_URL\":\"postgresql://user:pass@host:5432/db\"}"
399+
}
400+
```
401+
402+
::: warning
403+
404+
- **Size limit**: App secrets are limited to 4096 kB maximum
405+
- **Immutable**: Once set, app secrets cannot be changed without redeploying the
406+
iApp
407+
- **Security**: App secrets are encrypted and only accessible within the TEE
408+
environment
409+
- **Ownership**: App secrets belong to the iApp developer, not the user
410+
executing the iApp
411+
412+
:::
413+
414+
### How to Access App Secrets
415+
416+
App secrets are exposed as environment variables following the `IEXEC_APP_DEVELOPER_SECRET` naming pattern.
417+
418+
::: code-group
419+
420+
```python [Python]
421+
import os
422+
import json
423+
424+
# Get your app secret
425+
app_secret = os.environ.get('IEXEC_APP_DEVELOPER_SECRET')
426+
427+
if app_secret:
428+
# Parse JSON (multiple secrets)
429+
secrets = json.loads(app_secret)
430+
api_key = secrets.get('API_KEY')
431+
database_url = secrets.get('DATABASE_URL')
432+
```
433+
434+
```javascript [JavaScript]
435+
// Get your app secret
436+
const appSecret = process.env.IEXEC_APP_DEVELOPER_SECRET;
437+
438+
if (appSecret) {
439+
// Parse JSON (multiple secrets)
440+
const secrets = JSON.parse(appSecret);
441+
const apiKey = secrets.API_KEY;
442+
const databaseUrl = secrets.DATABASE_URL;
443+
}
444+
```
445+
446+
:::
447+
359448
## Testing Inputs Locally
360449

361450
Use iApp Generator to test different input types:

0 commit comments

Comments
 (0)