Skip to content

Commit dc11462

Browse files
ildellaFabianLars
andauthored
more docs for opener URL permissions (#3271)
Co-authored-by: Fabian-Lars <github@fabianlars.de>
1 parent 149b422 commit dc11462

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

src/content/docs/plugin/opener.mdx

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,10 @@ By default all potentially dangerous plugin commands and scopes are blocked and
115115

116116
See the [Capabilities Overview](/security/capabilities/) for more information and the [step by step guide](/learn/security/using-plugin-permissions/) to use plugin permissions.
117117

118+
Below are two example scope configurations. Both `path` and `url` use the [glob pattern syntax](https://docs.rs/glob/latest/glob/struct.Pattern.html) to define allowed file paths and URLs.
119+
120+
First, an example on how to add permissions to specific paths for the `openPath()` function:
121+
118122
```json title="src-tauri/capabilities/default.json" ins={6-15}
119123
{
120124
"$schema": "../gen/schemas/desktop-schema.json",
@@ -127,11 +131,37 @@ See the [Capabilities Overview](/security/capabilities/) for more information an
127131
"allow": [
128132
{
129133
"path": "/path/to/file"
134+
},
135+
{
136+
"path": "$APPDATA/file"
130137
}
131138
]
132139
}
133140
]
134141
}
135142
```
136143

144+
Lastly, an example on how to add permissions for the exact `https://tauri.app` URL and all URLs on a custom protocol (must be known to the OS) for the `openUrl()` function:
145+
146+
```json title="src-tauri/capabilities/default.json" ins={6-15}
147+
{
148+
"$schema": "../gen/schemas/desktop-schema.json",
149+
"identifier": "main-capability",
150+
"description": "Capability for the main window",
151+
"windows": ["main"],
152+
"permissions": [
153+
{
154+
"identifier": "opener:allow-open-url",
155+
"allow": [
156+
{
157+
"url": "https://tauri.app"
158+
},
159+
{
160+
"url": "custom:*"
161+
}
162+
}
163+
]
164+
}
165+
```
166+
137167
<PluginPermissions plugin={frontmatter.plugin} />

0 commit comments

Comments
 (0)