Skip to content

Commit e430b86

Browse files
Merge pull request #200 from itowlson/deps-selective-permission-inheritance
Dependencies: selective permission inheritance
2 parents 34e4ddc + 5d5d34c commit e430b86

1 file changed

Lines changed: 31 additions & 5 deletions

File tree

content/v4/writing-apps.md

Lines changed: 31 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -516,16 +516,42 @@ and Spin will map all of your `security:http` imports to the matching exports fr
516516

517517
By default, dependencies do not have access to Spin resources that require permission to be given in the manifest - network hosts, key-value stores, SQLite databases, variables, etc.
518518

519-
If a component has a dependency which requires resource access, you can grant it by setting the `dependencies_inherit_configuration` flag in the Spin component manifest:
519+
If a component has a dependency which requires resource access, you can grant it by setting the `inherit_configuration` flag on that dependency in the Spin component manifest, listing the capabilities you want to allow to the dependency:
520520

521521
```toml
522-
[component.my-app]
523-
dependencies_inherit_configuration = true
522+
[component.my-app.dependencies]
523+
"my:dependency" = { version = "1.0.0", inherit_configuration = ["allowed_outbound_hosts", "key_value_stores"] }
524+
```
525+
526+
The permission names are the same as the corresponding permission names in the manifest:
527+
528+
| Name | Description |
529+
|------|-------------|
530+
| `ai_models` | The dependency can use all LLMs listed in the component manifest. The dependency may use the [Serverless AI API](./serverless-ai-api-guide.md). |
531+
| `allowed_outbound_hosts` | The dependency can make network requests to all hosts listed in the component manifest. The dependency may use the (outbound) sockets, [HTTP](./http-outbound.md), [MQTT](./mqtt-outbound.md), [MySQL](./rdbms-storage.md), [PostgreSQL](./rdbms-storage.md), and [Redis](./redis-outbound.md) APIs. |
532+
| `environment` | The dependency can read all environment variables listed in the component manifest. |
533+
| `files` | The dependency can read all files listed in the component manifest. |
534+
| `key_value_stores` | The dependency can access all key-value stores listed in the component manifest. The dependency may use the [key-value API](./kv-store-api-guide.md). |
535+
| `sqlite_databases` | The dependency can access all SQLite databases listed in the component manifest. The dependency may use the [SQLite API](./sqlite-api-guide.md). |
536+
| `variables` | The dependency can read all Spin configuration variables listed in the component manifest. The dependency may use the [variables API](./variables.md). |
537+
538+
The dependency does not receive any permissions other than those you list.
539+
540+
If you want to grant the dependency the same permissions as the main component, set `inherit_configuration` to `true`:
541+
542+
```toml
543+
[component.my-app.dependencies]
544+
"highly:trusted/dependency" = { version = "1.0.0", inherit_configuration = true }
524545
```
525546

526-
This grants _all_ dependencies access to _all_ resources listed in the Spin component manifest. You should therefore set this only if you trust _all_ dependencies.
547+
If you want to grant _all_ dependencies the same permissions as the parent component, you can set `dependencies_inherit_configuration = true` at the component level:
527548

528-
> Spin does not currently support inheritance on a dependency-by-dependency or feature-by-feature basis.
549+
```toml
550+
[component.my-app]
551+
dependencies_inherit_configuration = true
552+
[component.my-app.dependencies]
553+
"my:dependency" = "1.0.0" # has all capabilities of the main component
554+
```
529555

530556
## Next Steps
531557

0 commit comments

Comments
 (0)