Skip to content

Commit 13d319d

Browse files
feat: Tauri v2 beta permissions config (#9)
* configure tauri permissions * update to latest beta * disable android/ios build script --------- Co-authored-by: fabianlars <[email protected]>
1 parent 498b557 commit 13d319d

File tree

6 files changed

+377
-4
lines changed

6 files changed

+377
-4
lines changed

Cargo.toml

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,20 @@ version = "0.0.0-alpha.0"
44
authors = ["FabianLars <[email protected]>"]
55
description = "A Tauri plugin for spawning a localhost server. Needed for some oauth flows (Login with X)."
66
edition = "2021"
7-
rust-version = "1.64"
7+
rust-version = "1.70"
88
license = "MIT OR Apache-2.0"
9-
include = ["src/**", "Cargo.toml", "LICENSE_*"]
9+
exclude = [".github/", "examples/", "renovate.json", ".gitignore"]
1010
readme = "README.md"
1111
repository = "https://github.com/FabianLars/tauri-plugin-oauth"
12+
links = "tauri-plugin-oauth"
1213

1314
[dependencies]
15+
tauri = { version = "2.0.0-beta.12" }
1416
httparse = "1"
1517
log = "0.4"
1618
serde = "1"
17-
tauri = "2.0.0-alpha.16"
18-
url = "2"
19+
url = "2"
20+
thiserror = "1.0"
21+
22+
[build-dependencies]
23+
tauri-plugin = { version = "2.0.0-beta.10", features = ["build"] }

build.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
const COMMANDS: &[&str] = &["start", "cancel"];
2+
3+
fn main() {
4+
tauri_plugin::Builder::new(COMMANDS)
5+
//.android_path("android")
6+
//.ios_path("ios")
7+
.build();
8+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# Automatically generated - DO NOT EDIT!
2+
3+
"$schema" = "../../schemas/schema.json"
4+
5+
[[permission]]
6+
identifier = "allow-cancel"
7+
description = "Enables the cancel command without any pre-configured scope."
8+
commands.allow = ["cancel"]
9+
10+
[[permission]]
11+
identifier = "deny-cancel"
12+
description = "Denies the cancel command without any pre-configured scope."
13+
commands.deny = ["cancel"]
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# Automatically generated - DO NOT EDIT!
2+
3+
"$schema" = "../../schemas/schema.json"
4+
5+
[[permission]]
6+
identifier = "allow-start"
7+
description = "Enables the start command without any pre-configured scope."
8+
commands.allow = ["start"]
9+
10+
[[permission]]
11+
identifier = "deny-start"
12+
description = "Denies the start command without any pre-configured scope."
13+
commands.deny = ["start"]
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
| Permission | Description |
2+
|------|-----|
3+
|`allow-cancel`|Enables the cancel command without any pre-configured scope.|
4+
|`deny-cancel`|Denies the cancel command without any pre-configured scope.|
5+
|`allow-start`|Enables the start command without any pre-configured scope.|
6+
|`deny-start`|Denies the start command without any pre-configured scope.|

permissions/schemas/schema.json

Lines changed: 328 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,328 @@
1+
{
2+
"$schema": "http://json-schema.org/draft-07/schema#",
3+
"title": "PermissionFile",
4+
"description": "Permission file that can define a default permission, a set of permissions or a list of inlined permissions.",
5+
"type": "object",
6+
"properties": {
7+
"default": {
8+
"description": "The default permission set for the plugin",
9+
"anyOf": [
10+
{
11+
"$ref": "#/definitions/DefaultPermission"
12+
},
13+
{
14+
"type": "null"
15+
}
16+
]
17+
},
18+
"set": {
19+
"description": "A list of permissions sets defined",
20+
"type": "array",
21+
"items": {
22+
"$ref": "#/definitions/PermissionSet"
23+
}
24+
},
25+
"permission": {
26+
"description": "A list of inlined permissions",
27+
"default": [],
28+
"type": "array",
29+
"items": {
30+
"$ref": "#/definitions/Permission"
31+
}
32+
}
33+
},
34+
"definitions": {
35+
"DefaultPermission": {
36+
"description": "The default permission set of the plugin.\n\nWorks similarly to a permission with the \"default\" identifier.",
37+
"type": "object",
38+
"required": [
39+
"permissions"
40+
],
41+
"properties": {
42+
"version": {
43+
"description": "The version of the permission.",
44+
"type": [
45+
"integer",
46+
"null"
47+
],
48+
"format": "uint64",
49+
"minimum": 1.0
50+
},
51+
"description": {
52+
"description": "Human-readable description of what the permission does.",
53+
"type": [
54+
"string",
55+
"null"
56+
]
57+
},
58+
"permissions": {
59+
"description": "All permissions this set contains.",
60+
"type": "array",
61+
"items": {
62+
"type": "string"
63+
}
64+
}
65+
}
66+
},
67+
"PermissionSet": {
68+
"description": "A set of direct permissions grouped together under a new name.",
69+
"type": "object",
70+
"required": [
71+
"description",
72+
"identifier",
73+
"permissions"
74+
],
75+
"properties": {
76+
"identifier": {
77+
"description": "A unique identifier for the permission.",
78+
"type": "string"
79+
},
80+
"description": {
81+
"description": "Human-readable description of what the permission does.",
82+
"type": "string"
83+
},
84+
"permissions": {
85+
"description": "All permissions this set contains.",
86+
"type": "array",
87+
"items": {
88+
"$ref": "#/definitions/PermissionKind"
89+
}
90+
}
91+
}
92+
},
93+
"Permission": {
94+
"description": "Descriptions of explicit privileges of commands.\n\nIt can enable commands to be accessible in the frontend of the application.\n\nIf the scope is defined it can be used to fine grain control the access of individual or multiple commands.",
95+
"type": "object",
96+
"required": [
97+
"identifier"
98+
],
99+
"properties": {
100+
"version": {
101+
"description": "The version of the permission.",
102+
"type": [
103+
"integer",
104+
"null"
105+
],
106+
"format": "uint64",
107+
"minimum": 1.0
108+
},
109+
"identifier": {
110+
"description": "A unique identifier for the permission.",
111+
"type": "string"
112+
},
113+
"description": {
114+
"description": "Human-readable description of what the permission does.",
115+
"type": [
116+
"string",
117+
"null"
118+
]
119+
},
120+
"commands": {
121+
"description": "Allowed or denied commands when using this permission.",
122+
"default": {
123+
"allow": [],
124+
"deny": []
125+
},
126+
"allOf": [
127+
{
128+
"$ref": "#/definitions/Commands"
129+
}
130+
]
131+
},
132+
"scope": {
133+
"description": "Allowed or denied scoped when using this permission.",
134+
"allOf": [
135+
{
136+
"$ref": "#/definitions/Scopes"
137+
}
138+
]
139+
},
140+
"platforms": {
141+
"description": "Target platforms this permission applies. By default all platforms are affected by this permission.",
142+
"type": [
143+
"array",
144+
"null"
145+
],
146+
"items": {
147+
"$ref": "#/definitions/Target"
148+
}
149+
}
150+
}
151+
},
152+
"Commands": {
153+
"description": "Allowed and denied commands inside a permission.\n\nIf two commands clash inside of `allow` and `deny`, it should be denied by default.",
154+
"type": "object",
155+
"properties": {
156+
"allow": {
157+
"description": "Allowed command.",
158+
"default": [],
159+
"type": "array",
160+
"items": {
161+
"type": "string"
162+
}
163+
},
164+
"deny": {
165+
"description": "Denied command, which takes priority.",
166+
"default": [],
167+
"type": "array",
168+
"items": {
169+
"type": "string"
170+
}
171+
}
172+
}
173+
},
174+
"Scopes": {
175+
"description": "A restriction of the command/endpoint functionality.\n\nIt can be of any serde serializable type and is used for allowing or preventing certain actions inside a Tauri command.\n\nThe scope is passed to the command and handled/enforced by the command itself.",
176+
"type": "object",
177+
"properties": {
178+
"allow": {
179+
"description": "Data that defines what is allowed by the scope.",
180+
"type": [
181+
"array",
182+
"null"
183+
],
184+
"items": {
185+
"$ref": "#/definitions/Value"
186+
}
187+
},
188+
"deny": {
189+
"description": "Data that defines what is denied by the scope.",
190+
"type": [
191+
"array",
192+
"null"
193+
],
194+
"items": {
195+
"$ref": "#/definitions/Value"
196+
}
197+
}
198+
}
199+
},
200+
"Value": {
201+
"description": "All supported ACL values.",
202+
"anyOf": [
203+
{
204+
"description": "Represents a null JSON value.",
205+
"type": "null"
206+
},
207+
{
208+
"description": "Represents a [`bool`].",
209+
"type": "boolean"
210+
},
211+
{
212+
"description": "Represents a valid ACL [`Number`].",
213+
"allOf": [
214+
{
215+
"$ref": "#/definitions/Number"
216+
}
217+
]
218+
},
219+
{
220+
"description": "Represents a [`String`].",
221+
"type": "string"
222+
},
223+
{
224+
"description": "Represents a list of other [`Value`]s.",
225+
"type": "array",
226+
"items": {
227+
"$ref": "#/definitions/Value"
228+
}
229+
},
230+
{
231+
"description": "Represents a map of [`String`] keys to [`Value`]s.",
232+
"type": "object",
233+
"additionalProperties": {
234+
"$ref": "#/definitions/Value"
235+
}
236+
}
237+
]
238+
},
239+
"Number": {
240+
"description": "A valid ACL number.",
241+
"anyOf": [
242+
{
243+
"description": "Represents an [`i64`].",
244+
"type": "integer",
245+
"format": "int64"
246+
},
247+
{
248+
"description": "Represents a [`f64`].",
249+
"type": "number",
250+
"format": "double"
251+
}
252+
]
253+
},
254+
"Target": {
255+
"description": "Platform target.",
256+
"oneOf": [
257+
{
258+
"description": "MacOS.",
259+
"type": "string",
260+
"enum": [
261+
"macOS"
262+
]
263+
},
264+
{
265+
"description": "Windows.",
266+
"type": "string",
267+
"enum": [
268+
"windows"
269+
]
270+
},
271+
{
272+
"description": "Linux.",
273+
"type": "string",
274+
"enum": [
275+
"linux"
276+
]
277+
},
278+
{
279+
"description": "Android.",
280+
"type": "string",
281+
"enum": [
282+
"android"
283+
]
284+
},
285+
{
286+
"description": "iOS.",
287+
"type": "string",
288+
"enum": [
289+
"iOS"
290+
]
291+
}
292+
]
293+
},
294+
"PermissionKind": {
295+
"type": "string",
296+
"oneOf": [
297+
{
298+
"description": "allow-cancel -> Enables the cancel command without any pre-configured scope.",
299+
"type": "string",
300+
"enum": [
301+
"allow-cancel"
302+
]
303+
},
304+
{
305+
"description": "deny-cancel -> Denies the cancel command without any pre-configured scope.",
306+
"type": "string",
307+
"enum": [
308+
"deny-cancel"
309+
]
310+
},
311+
{
312+
"description": "allow-start -> Enables the start command without any pre-configured scope.",
313+
"type": "string",
314+
"enum": [
315+
"allow-start"
316+
]
317+
},
318+
{
319+
"description": "deny-start -> Denies the start command without any pre-configured scope.",
320+
"type": "string",
321+
"enum": [
322+
"deny-start"
323+
]
324+
}
325+
]
326+
}
327+
}
328+
}

0 commit comments

Comments
 (0)