update tauri

pull/355/head
Lucas Nogueira 2 years ago
parent b529c9406f
commit 64cb3c7490
No known key found for this signature in database
GPG Key ID: 7C32FCA95C8C95D7

17
Cargo.lock generated

@ -4960,14 +4960,13 @@ dependencies = [
[[package]] [[package]]
name = "tauri" name = "tauri"
version = "2.0.0-alpha.8" version = "2.0.0-alpha.8"
source = "git+https://github.com/tauri-apps/tauri?branch=refactor/cleanup#234edbaf29172c2a461e22a82996da65ebacfcf0" source = "git+https://github.com/tauri-apps/tauri?branch=refactor/cleanup#2bbd957a3b1b1072487f5890071317593481f118"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"bytes 1.4.0", "bytes 1.4.0",
"cocoa", "cocoa",
"dirs-next", "dirs-next",
"embed_plist", "embed_plist",
"encoding_rs",
"futures-util", "futures-util",
"glib", "glib",
"glob", "glob",
@ -5011,11 +5010,10 @@ dependencies = [
[[package]] [[package]]
name = "tauri-build" name = "tauri-build"
version = "2.0.0-alpha.4" version = "2.0.0-alpha.4"
source = "git+https://github.com/tauri-apps/tauri?branch=refactor/cleanup#234edbaf29172c2a461e22a82996da65ebacfcf0" source = "git+https://github.com/tauri-apps/tauri?branch=refactor/cleanup#2bbd957a3b1b1072487f5890071317593481f118"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"cargo_toml", "cargo_toml",
"filetime",
"heck 0.4.1", "heck 0.4.1",
"json-patch", "json-patch",
"quote", "quote",
@ -5032,7 +5030,7 @@ dependencies = [
[[package]] [[package]]
name = "tauri-codegen" name = "tauri-codegen"
version = "2.0.0-alpha.4" version = "2.0.0-alpha.4"
source = "git+https://github.com/tauri-apps/tauri?branch=refactor/cleanup#234edbaf29172c2a461e22a82996da65ebacfcf0" source = "git+https://github.com/tauri-apps/tauri?branch=refactor/cleanup#2bbd957a3b1b1072487f5890071317593481f118"
dependencies = [ dependencies = [
"base64 0.21.0", "base64 0.21.0",
"brotli", "brotli",
@ -5057,7 +5055,7 @@ dependencies = [
[[package]] [[package]]
name = "tauri-macros" name = "tauri-macros"
version = "2.0.0-alpha.4" version = "2.0.0-alpha.4"
source = "git+https://github.com/tauri-apps/tauri?branch=refactor/cleanup#234edbaf29172c2a461e22a82996da65ebacfcf0" source = "git+https://github.com/tauri-apps/tauri?branch=refactor/cleanup#2bbd957a3b1b1072487f5890071317593481f118"
dependencies = [ dependencies = [
"heck 0.4.1", "heck 0.4.1",
"proc-macro2", "proc-macro2",
@ -5451,7 +5449,7 @@ dependencies = [
[[package]] [[package]]
name = "tauri-runtime" name = "tauri-runtime"
version = "0.13.0-alpha.4" version = "0.13.0-alpha.4"
source = "git+https://github.com/tauri-apps/tauri?branch=refactor/cleanup#234edbaf29172c2a461e22a82996da65ebacfcf0" source = "git+https://github.com/tauri-apps/tauri?branch=refactor/cleanup#2bbd957a3b1b1072487f5890071317593481f118"
dependencies = [ dependencies = [
"gtk", "gtk",
"http", "http",
@ -5465,14 +5463,13 @@ dependencies = [
"thiserror", "thiserror",
"url", "url",
"uuid", "uuid",
"webview2-com",
"windows 0.44.0", "windows 0.44.0",
] ]
[[package]] [[package]]
name = "tauri-runtime-wry" name = "tauri-runtime-wry"
version = "0.13.0-alpha.4" version = "0.13.0-alpha.4"
source = "git+https://github.com/tauri-apps/tauri?branch=refactor/cleanup#234edbaf29172c2a461e22a82996da65ebacfcf0" source = "git+https://github.com/tauri-apps/tauri?branch=refactor/cleanup#2bbd957a3b1b1072487f5890071317593481f118"
dependencies = [ dependencies = [
"cocoa", "cocoa",
"gtk", "gtk",
@ -5492,7 +5489,7 @@ dependencies = [
[[package]] [[package]]
name = "tauri-utils" name = "tauri-utils"
version = "2.0.0-alpha.4" version = "2.0.0-alpha.4"
source = "git+https://github.com/tauri-apps/tauri?branch=refactor/cleanup#234edbaf29172c2a461e22a82996da65ebacfcf0" source = "git+https://github.com/tauri-apps/tauri?branch=refactor/cleanup#2bbd957a3b1b1072487f5890071317593481f118"
dependencies = [ dependencies = [
"aes-gcm 0.10.1", "aes-gcm 0.10.1",
"brotli", "brotli",

@ -120,15 +120,6 @@
"pubkey": "dW50cnVzdGVkIGNvbW1lbnQ6IG1pbmlzaWduIHB1YmxpYyBrZXk6IDE5QzMxNjYwNTM5OEUwNTgKUldSWTRKaFRZQmJER1h4d1ZMYVA3dnluSjdpN2RmMldJR09hUFFlZDY0SlFqckkvRUJhZDJVZXAK" "pubkey": "dW50cnVzdGVkIGNvbW1lbnQ6IG1pbmlzaWduIHB1YmxpYyBrZXk6IDE5QzMxNjYwNTM5OEUwNTgKUldSWTRKaFRZQmJER1h4d1ZMYVA3dnluSjdpN2RmMldJR09hUFFlZDY0SlFqckkvRUJhZDJVZXAK"
} }
}, },
"allowlist": {
"protocol": {
"asset": true,
"assetScope": {
"allow": ["$APPDATA/db/**", "$RESOURCE/**"],
"deny": ["$APPDATA/db/*.stronghold"]
}
}
},
"windows": [], "windows": [],
"security": { "security": {
"csp": { "csp": {
@ -137,7 +128,14 @@
"img-src": "'self' asset: https://asset.localhost blob: data:", "img-src": "'self' asset: https://asset.localhost blob: data:",
"style-src": "'unsafe-inline' 'self' https://fonts.googleapis.com" "style-src": "'unsafe-inline' 'self' https://fonts.googleapis.com"
}, },
"freezePrototype": true "freezePrototype": true,
"assetProtocol": {
"enable": true,
"scope": {
"allow": ["$APPDATA/db/**", "$RESOURCE/**"],
"deny": ["$APPDATA/db/*.stronghold"]
}
}
}, },
"systemTray": { "systemTray": {
"iconPath": "icons/tray_icon_with_transparency.png", "iconPath": "icons/tray_icon_with_transparency.png",

@ -1,7 +1,57 @@
use std::path::PathBuf;
use serde::Deserialize; use serde::Deserialize;
use tauri::utils::config::FsAllowlistScope;
#[derive(Debug, Deserialize)] #[derive(Debug, Deserialize)]
pub struct Config { pub struct Config {
pub scope: FsAllowlistScope, pub scope: FsScope,
}
/// Protocol scope definition.
/// It is a list of glob patterns that restrict the API access from the webview.
///
/// Each pattern can start with a variable that resolves to a system base directory.
/// The variables are: `$AUDIO`, `$CACHE`, `$CONFIG`, `$DATA`, `$LOCALDATA`, `$DESKTOP`,
/// `$DOCUMENT`, `$DOWNLOAD`, `$EXE`, `$FONT`, `$HOME`, `$PICTURE`, `$PUBLIC`, `$RUNTIME`,
/// `$TEMPLATE`, `$VIDEO`, `$RESOURCE`, `$APP`, `$LOG`, `$TEMP`, `$APPCONFIG`, `$APPDATA`,
/// `$APPLOCALDATA`, `$APPCACHE`, `$APPLOG`.
#[derive(Debug, PartialEq, Eq, Clone, Deserialize)]
#[serde(untagged)]
pub enum FsScope {
/// A list of paths that are allowed by this scope.
AllowedPaths(Vec<PathBuf>),
/// A complete scope configuration.
Scope {
/// A list of paths that are allowed by this scope.
#[serde(default)]
allow: Vec<PathBuf>,
/// A list of paths that are not allowed by this scope.
/// This gets precedence over the [`Self::Scope::allow`] list.
#[serde(default)]
deny: Vec<PathBuf>,
},
}
impl Default for FsScope {
fn default() -> Self {
Self::AllowedPaths(Vec::new())
}
}
impl FsScope {
/// The list of allowed paths.
pub fn allowed_paths(&self) -> &Vec<PathBuf> {
match self {
Self::AllowedPaths(p) => p,
Self::Scope { allow, .. } => allow,
}
}
/// The list of forbidden paths.
pub fn forbidden_paths(&self) -> Option<&Vec<PathBuf>> {
match self {
Self::AllowedPaths(_) => None,
Self::Scope { deny, .. } => Some(deny),
}
}
} }

@ -2,9 +2,9 @@
// SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: Apache-2.0
// SPDX-License-Identifier: MIT // SPDX-License-Identifier: MIT
use config::FsScope;
use tauri::{ use tauri::{
plugin::{Builder as PluginBuilder, TauriPlugin}, plugin::{Builder as PluginBuilder, TauriPlugin},
utils::config::FsAllowlistScope,
Manager, Runtime, Manager, Runtime,
}; };
@ -50,7 +50,7 @@ pub fn init<R: Runtime>() -> TauriPlugin<R, Option<Config>> {
commands::metadata commands::metadata
]) ])
.setup(|app: &tauri::AppHandle<R>, api| { .setup(|app: &tauri::AppHandle<R>, api| {
let default_scope = FsAllowlistScope::default(); let default_scope = FsScope::default();
app.manage(Scope::new( app.manage(Scope::new(
app, app,
api.config() api.config()

@ -9,8 +9,8 @@ use std::{
sync::{Arc, Mutex}, sync::{Arc, Mutex},
}; };
use crate::config::FsScope;
pub use glob::Pattern; pub use glob::Pattern;
use tauri::utils::config::FsAllowlistScope;
use uuid::Uuid; use uuid::Uuid;
use crate::{Manager, Runtime}; use crate::{Manager, Runtime};
@ -83,7 +83,7 @@ impl Scope {
/// Creates a new scope from a `FsAllowlistScope` configuration. /// Creates a new scope from a `FsAllowlistScope` configuration.
pub(crate) fn new<R: Runtime, M: Manager<R>>( pub(crate) fn new<R: Runtime, M: Manager<R>>(
manager: &M, manager: &M,
scope: &FsAllowlistScope, scope: &FsScope,
) -> crate::Result<Self> { ) -> crate::Result<Self> {
let mut allowed_patterns = HashSet::new(); let mut allowed_patterns = HashSet::new();
for path in scope.allowed_paths() { for path in scope.allowed_paths() {

Loading…
Cancel
Save