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: content/v4/writing-apps.md
+23-7Lines changed: 23 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -432,8 +432,6 @@ source = "spinredis.wasm"
432
432
433
433
Few of us write applications without relying on libraries. Traditionally, those libraries have had to come from the language ecosystem - e.g. `npm` for JavaScript, `pip` for Python, etc. - and you can still work this way in Spin. However, the WebAssembly Component Model means that you can also depend on other WebAssembly components. The process of combining your application component with the Wasm components it depends on is called _composition_, and Spin supports this natively.
434
434
435
-
> Spin's composition is limited to "plug" style scenarios where each of your component's imports is satisfied independently, and where the dependency component does not need to be further composed with any other components. The analogy is plugging each of your imports into a socket provided by a dependency. If you need to construct a more complex composition, you must use a dedicated tool such as [`wac`](https://github.com/bytecodealliance/wac) as part of your build. See the [Component Model book](https://component-model.bytecodealliance.org/creating-and-consuming/composing.html) for details and examples.
436
-
437
435
To use composition through Spin, your component must import a [WIT (Wasm Interface Type) interface](https://component-model.bytecodealliance.org/design/wit.html), and the dependency must export the same WIT interface. The details of working with WIT interfaces is language-specific, and is beyond the scope of the Spin documentation. You can learn more from the [language guides in the Component Model book](https://component-model.bytecodealliance.org/language-support.html). This section focuses on describing the dependency composition support in Spin.
438
436
439
437
### Declaring Component Dependencies
@@ -516,9 +514,11 @@ and Spin will map all of your `security:http` imports to the matching exports fr
516
514
517
515
### Dependency Permissions
518
516
519
-
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.
517
+
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. If a dependency tries to access such a capability, it will fail with an error.
518
+
519
+
#### Granting specific capabilities
520
520
521
-
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:
521
+
To grant a dependency a subset of the parent's capabilities, list them on the dependency:
522
522
523
523
```toml
524
524
[component.my-app.dependencies]
@@ -537,16 +537,32 @@ The permission names are the same as the corresponding permission names in the m
537
537
|`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). |
538
538
|`variables`| The dependency can read all Spin configuration variables listed in the component manifest. The dependency may use the [variables API](./variables.md). |
539
539
540
-
The dependency does not receive any permissions other than those you list.
540
+
`inherit_configuration` applies uniformly to every dependency source — registry packages, local paths, HTTP URLs, and in-app component references. For example, the same permission form works for a local dependency:
If you want to grant the dependency the same permissions as the main component, set `inherit_configuration` to `true`:
549
+
To grant the dependency the same permissions as the main component, set `inherit_configuration` to `true`:
543
550
544
551
```toml
545
552
[component.my-app.dependencies]
546
553
"highly:trusted/dependency" = { version = "1.0.0", inherit_configuration = true }
547
554
```
548
555
549
-
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:
556
+
To make the isolation explicit (for example, in a manifest where other dependencies do inherit), set `inherit_configuration` to `false`. This is identical to omitting the field:
557
+
558
+
```toml
559
+
[component.my-app.dependencies]
560
+
"untrusted:dependency" = { version = "1.0.0", inherit_configuration = false }
561
+
```
562
+
563
+
#### Granting all dependencies full permissions
564
+
565
+
If you want to grant _all_ dependencies of a component the same permissions as the parent component, you can set `dependencies_inherit_configuration = true` at the component level:
0 commit comments