[WIP] Encryption for secure values (#183)

This commit is contained in:
Gregory Schier
2025-04-15 07:18:26 -07:00
committed by GitHub
parent e114a85c39
commit 2e55a1bd6d
208 changed files with 4063 additions and 28698 deletions

View File

@@ -9,18 +9,18 @@ publish = false
futures-util = "0.3.31"
log = "0.4.20"
md5 = "0.7.0"
rustls = { version = "0.23.21", default-features = false, features = ["custom-provider", "ring"] }
rustls-platform-verifier = "0.5.0"
serde = { version = "1.0.217", features = ["derive"] }
rustls = { version = "0.23.25", default-features = false, features = ["custom-provider", "ring"] }
rustls-platform-verifier = "0.5.1"
serde = { workspace = true, features = ["derive"] }
serde_json = { workspace = true }
tauri = { workspace = true }
thiserror = "2.0.11"
tokio = { version = "1.0", default-features = false, features = ["macros", "time", "test-util"] }
tokio-tungstenite = { version = "0.26.1", default-features = false, features = ["rustls-tls-native-roots", "connect"] }
yaak-models = { workspace = true }
tokio = { workspace = true, features = ["macros", "time", "test-util"] }
tokio-tungstenite = { version = "0.26.2", default-features = false, features = ["rustls-tls-native-roots", "connect"] }
yaak-http = { workspace = true }
yaak-models = { workspace = true }
yaak-plugins = { workspace = true }
yaak-templates = { workspace = true }
serde_json = "1.0.132"
[build-dependencies]
tauri-plugin = { workspace = true, features = ["build"] }

View File

@@ -1,13 +0,0 @@
# Automatically generated - DO NOT EDIT!
"$schema" = "../../schemas/schema.json"
[[permission]]
identifier = "allow-cancel"
description = "Enables the cancel command without any pre-configured scope."
commands.allow = ["cancel"]
[[permission]]
identifier = "deny-cancel"
description = "Denies the cancel command without any pre-configured scope."
commands.deny = ["cancel"]

View File

@@ -1,13 +0,0 @@
# Automatically generated - DO NOT EDIT!
"$schema" = "../../schemas/schema.json"
[[permission]]
identifier = "allow-close"
description = "Enables the close command without any pre-configured scope."
commands.allow = ["close"]
[[permission]]
identifier = "deny-close"
description = "Denies the close command without any pre-configured scope."
commands.deny = ["close"]

View File

@@ -1,13 +0,0 @@
# Automatically generated - DO NOT EDIT!
"$schema" = "../../schemas/schema.json"
[[permission]]
identifier = "allow-connect"
description = "Enables the connect command without any pre-configured scope."
commands.allow = ["connect"]
[[permission]]
identifier = "deny-connect"
description = "Denies the connect command without any pre-configured scope."
commands.deny = ["connect"]

View File

@@ -1,13 +0,0 @@
# Automatically generated - DO NOT EDIT!
"$schema" = "../../schemas/schema.json"
[[permission]]
identifier = "allow-delete-connection"
description = "Enables the delete_connection command without any pre-configured scope."
commands.allow = ["delete_connection"]
[[permission]]
identifier = "deny-delete-connection"
description = "Denies the delete_connection command without any pre-configured scope."
commands.deny = ["delete_connection"]

View File

@@ -1,13 +0,0 @@
# Automatically generated - DO NOT EDIT!
"$schema" = "../../schemas/schema.json"
[[permission]]
identifier = "allow-delete-connections"
description = "Enables the delete_connections command without any pre-configured scope."
commands.allow = ["delete_connections"]
[[permission]]
identifier = "deny-delete-connections"
description = "Denies the delete_connections command without any pre-configured scope."
commands.deny = ["delete_connections"]

View File

@@ -1,13 +0,0 @@
# Automatically generated - DO NOT EDIT!
"$schema" = "../../schemas/schema.json"
[[permission]]
identifier = "allow-delete-request"
description = "Enables the delete_request command without any pre-configured scope."
commands.allow = ["delete_request"]
[[permission]]
identifier = "deny-delete-request"
description = "Denies the delete_request command without any pre-configured scope."
commands.deny = ["delete_request"]

View File

@@ -1,13 +0,0 @@
# Automatically generated - DO NOT EDIT!
"$schema" = "../../schemas/schema.json"
[[permission]]
identifier = "allow-duplicate-request"
description = "Enables the duplicate_request command without any pre-configured scope."
commands.allow = ["duplicate_request"]
[[permission]]
identifier = "deny-duplicate-request"
description = "Denies the duplicate_request command without any pre-configured scope."
commands.deny = ["duplicate_request"]

View File

@@ -1,13 +0,0 @@
# Automatically generated - DO NOT EDIT!
"$schema" = "../../schemas/schema.json"
[[permission]]
identifier = "allow-list-connections"
description = "Enables the list_connections command without any pre-configured scope."
commands.allow = ["list_connections"]
[[permission]]
identifier = "deny-list-connections"
description = "Denies the list_connections command without any pre-configured scope."
commands.deny = ["list_connections"]

View File

@@ -1,13 +0,0 @@
# Automatically generated - DO NOT EDIT!
"$schema" = "../../schemas/schema.json"
[[permission]]
identifier = "allow-list-events"
description = "Enables the list_events command without any pre-configured scope."
commands.allow = ["list_events"]
[[permission]]
identifier = "deny-list-events"
description = "Denies the list_events command without any pre-configured scope."
commands.deny = ["list_events"]

View File

@@ -1,13 +0,0 @@
# Automatically generated - DO NOT EDIT!
"$schema" = "../../schemas/schema.json"
[[permission]]
identifier = "allow-list-requests"
description = "Enables the list_requests command without any pre-configured scope."
commands.allow = ["list_requests"]
[[permission]]
identifier = "deny-list-requests"
description = "Denies the list_requests command without any pre-configured scope."
commands.deny = ["list_requests"]

View File

@@ -1,13 +0,0 @@
# Automatically generated - DO NOT EDIT!
"$schema" = "../../schemas/schema.json"
[[permission]]
identifier = "allow-list-websocket-connections"
description = "Enables the list_websocket_connections command without any pre-configured scope."
commands.allow = ["list_websocket_connections"]
[[permission]]
identifier = "deny-list-websocket-connections"
description = "Denies the list_websocket_connections command without any pre-configured scope."
commands.deny = ["list_websocket_connections"]

View File

@@ -1,13 +0,0 @@
# Automatically generated - DO NOT EDIT!
"$schema" = "../../schemas/schema.json"
[[permission]]
identifier = "allow-list-websocket-requests"
description = "Enables the list_websocket_requests command without any pre-configured scope."
commands.allow = ["list_websocket_requests"]
[[permission]]
identifier = "deny-list-websocket-requests"
description = "Denies the list_websocket_requests command without any pre-configured scope."
commands.deny = ["list_websocket_requests"]

View File

@@ -1,13 +0,0 @@
# Automatically generated - DO NOT EDIT!
"$schema" = "../../schemas/schema.json"
[[permission]]
identifier = "allow-send"
description = "Enables the send command without any pre-configured scope."
commands.allow = ["send"]
[[permission]]
identifier = "deny-send"
description = "Denies the send command without any pre-configured scope."
commands.deny = ["send"]

View File

@@ -1,13 +0,0 @@
# Automatically generated - DO NOT EDIT!
"$schema" = "../../schemas/schema.json"
[[permission]]
identifier = "allow-upsert-request"
description = "Enables the upsert_request command without any pre-configured scope."
commands.allow = ["upsert_request"]
[[permission]]
identifier = "deny-upsert-request"
description = "Denies the upsert_request command without any pre-configured scope."
commands.deny = ["upsert_request"]

View File

@@ -1,13 +0,0 @@
# Automatically generated - DO NOT EDIT!
"$schema" = "../../schemas/schema.json"
[[permission]]
identifier = "allow-upsert-websocket-request"
description = "Enables the upsert_websocket_request command without any pre-configured scope."
commands.allow = ["upsert_websocket_request"]
[[permission]]
identifier = "deny-upsert-websocket-request"
description = "Denies the upsert_websocket_request command without any pre-configured scope."
commands.deny = ["upsert_websocket_request"]

View File

@@ -1,415 +0,0 @@
## Default Permission
Default permissions for the plugin
- `allow-close`
- `allow-connect`
- `allow-delete-connection`
- `allow-delete-connections`
- `allow-delete-request`
- `allow-duplicate-request`
- `allow-list-connections`
- `allow-list-events`
- `allow-list-requests`
- `allow-send`
- `allow-upsert-request`
## Permission Table
<table>
<tr>
<th>Identifier</th>
<th>Description</th>
</tr>
<tr>
<td>
`yaak-ws:allow-cancel`
</td>
<td>
Enables the cancel command without any pre-configured scope.
</td>
</tr>
<tr>
<td>
`yaak-ws:deny-cancel`
</td>
<td>
Denies the cancel command without any pre-configured scope.
</td>
</tr>
<tr>
<td>
`yaak-ws:allow-close`
</td>
<td>
Enables the close command without any pre-configured scope.
</td>
</tr>
<tr>
<td>
`yaak-ws:deny-close`
</td>
<td>
Denies the close command without any pre-configured scope.
</td>
</tr>
<tr>
<td>
`yaak-ws:allow-connect`
</td>
<td>
Enables the connect command without any pre-configured scope.
</td>
</tr>
<tr>
<td>
`yaak-ws:deny-connect`
</td>
<td>
Denies the connect command without any pre-configured scope.
</td>
</tr>
<tr>
<td>
`yaak-ws:allow-delete-connection`
</td>
<td>
Enables the delete_connection command without any pre-configured scope.
</td>
</tr>
<tr>
<td>
`yaak-ws:deny-delete-connection`
</td>
<td>
Denies the delete_connection command without any pre-configured scope.
</td>
</tr>
<tr>
<td>
`yaak-ws:allow-delete-connections`
</td>
<td>
Enables the delete_connections command without any pre-configured scope.
</td>
</tr>
<tr>
<td>
`yaak-ws:deny-delete-connections`
</td>
<td>
Denies the delete_connections command without any pre-configured scope.
</td>
</tr>
<tr>
<td>
`yaak-ws:allow-delete-request`
</td>
<td>
Enables the delete_request command without any pre-configured scope.
</td>
</tr>
<tr>
<td>
`yaak-ws:deny-delete-request`
</td>
<td>
Denies the delete_request command without any pre-configured scope.
</td>
</tr>
<tr>
<td>
`yaak-ws:allow-duplicate-request`
</td>
<td>
Enables the duplicate_request command without any pre-configured scope.
</td>
</tr>
<tr>
<td>
`yaak-ws:deny-duplicate-request`
</td>
<td>
Denies the duplicate_request command without any pre-configured scope.
</td>
</tr>
<tr>
<td>
`yaak-ws:allow-list-connections`
</td>
<td>
Enables the list_connections command without any pre-configured scope.
</td>
</tr>
<tr>
<td>
`yaak-ws:deny-list-connections`
</td>
<td>
Denies the list_connections command without any pre-configured scope.
</td>
</tr>
<tr>
<td>
`yaak-ws:allow-list-events`
</td>
<td>
Enables the list_events command without any pre-configured scope.
</td>
</tr>
<tr>
<td>
`yaak-ws:deny-list-events`
</td>
<td>
Denies the list_events command without any pre-configured scope.
</td>
</tr>
<tr>
<td>
`yaak-ws:allow-list-requests`
</td>
<td>
Enables the list_requests command without any pre-configured scope.
</td>
</tr>
<tr>
<td>
`yaak-ws:deny-list-requests`
</td>
<td>
Denies the list_requests command without any pre-configured scope.
</td>
</tr>
<tr>
<td>
`yaak-ws:allow-list-websocket-connections`
</td>
<td>
Enables the list_websocket_connections command without any pre-configured scope.
</td>
</tr>
<tr>
<td>
`yaak-ws:deny-list-websocket-connections`
</td>
<td>
Denies the list_websocket_connections command without any pre-configured scope.
</td>
</tr>
<tr>
<td>
`yaak-ws:allow-list-websocket-requests`
</td>
<td>
Enables the list_websocket_requests command without any pre-configured scope.
</td>
</tr>
<tr>
<td>
`yaak-ws:deny-list-websocket-requests`
</td>
<td>
Denies the list_websocket_requests command without any pre-configured scope.
</td>
</tr>
<tr>
<td>
`yaak-ws:allow-send`
</td>
<td>
Enables the send command without any pre-configured scope.
</td>
</tr>
<tr>
<td>
`yaak-ws:deny-send`
</td>
<td>
Denies the send command without any pre-configured scope.
</td>
</tr>
<tr>
<td>
`yaak-ws:allow-upsert-request`
</td>
<td>
Enables the upsert_request command without any pre-configured scope.
</td>
</tr>
<tr>
<td>
`yaak-ws:deny-upsert-request`
</td>
<td>
Denies the upsert_request command without any pre-configured scope.
</td>
</tr>
<tr>
<td>
`yaak-ws:allow-upsert-websocket-request`
</td>
<td>
Enables the upsert_websocket_request command without any pre-configured scope.
</td>
</tr>
<tr>
<td>
`yaak-ws:deny-upsert-websocket-request`
</td>
<td>
Denies the upsert_websocket_request command without any pre-configured scope.
</td>
</tr>
</table>

View File

@@ -1,455 +0,0 @@
{
"$schema": "http://json-schema.org/draft-07/schema#",
"title": "PermissionFile",
"description": "Permission file that can define a default permission, a set of permissions or a list of inlined permissions.",
"type": "object",
"properties": {
"default": {
"description": "The default permission set for the plugin",
"anyOf": [
{
"$ref": "#/definitions/DefaultPermission"
},
{
"type": "null"
}
]
},
"set": {
"description": "A list of permissions sets defined",
"type": "array",
"items": {
"$ref": "#/definitions/PermissionSet"
}
},
"permission": {
"description": "A list of inlined permissions",
"default": [],
"type": "array",
"items": {
"$ref": "#/definitions/Permission"
}
}
},
"definitions": {
"DefaultPermission": {
"description": "The default permission set of the plugin.\n\nWorks similarly to a permission with the \"default\" identifier.",
"type": "object",
"required": [
"permissions"
],
"properties": {
"version": {
"description": "The version of the permission.",
"type": [
"integer",
"null"
],
"format": "uint64",
"minimum": 1.0
},
"description": {
"description": "Human-readable description of what the permission does. Tauri convention is to use `<h4>` headings in markdown content for Tauri documentation generation purposes.",
"type": [
"string",
"null"
]
},
"permissions": {
"description": "All permissions this set contains.",
"type": "array",
"items": {
"type": "string"
}
}
}
},
"PermissionSet": {
"description": "A set of direct permissions grouped together under a new name.",
"type": "object",
"required": [
"description",
"identifier",
"permissions"
],
"properties": {
"identifier": {
"description": "A unique identifier for the permission.",
"type": "string"
},
"description": {
"description": "Human-readable description of what the permission does.",
"type": "string"
},
"permissions": {
"description": "All permissions this set contains.",
"type": "array",
"items": {
"$ref": "#/definitions/PermissionKind"
}
}
}
},
"Permission": {
"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.",
"type": "object",
"required": [
"identifier"
],
"properties": {
"version": {
"description": "The version of the permission.",
"type": [
"integer",
"null"
],
"format": "uint64",
"minimum": 1.0
},
"identifier": {
"description": "A unique identifier for the permission.",
"type": "string"
},
"description": {
"description": "Human-readable description of what the permission does. Tauri internal convention is to use `<h4>` headings in markdown content for Tauri documentation generation purposes.",
"type": [
"string",
"null"
]
},
"commands": {
"description": "Allowed or denied commands when using this permission.",
"default": {
"allow": [],
"deny": []
},
"allOf": [
{
"$ref": "#/definitions/Commands"
}
]
},
"scope": {
"description": "Allowed or denied scoped when using this permission.",
"allOf": [
{
"$ref": "#/definitions/Scopes"
}
]
},
"platforms": {
"description": "Target platforms this permission applies. By default all platforms are affected by this permission.",
"type": [
"array",
"null"
],
"items": {
"$ref": "#/definitions/Target"
}
}
}
},
"Commands": {
"description": "Allowed and denied commands inside a permission.\n\nIf two commands clash inside of `allow` and `deny`, it should be denied by default.",
"type": "object",
"properties": {
"allow": {
"description": "Allowed command.",
"default": [],
"type": "array",
"items": {
"type": "string"
}
},
"deny": {
"description": "Denied command, which takes priority.",
"default": [],
"type": "array",
"items": {
"type": "string"
}
}
}
},
"Scopes": {
"description": "An argument for fine grained behavior control of Tauri commands.\n\nIt can be of any serde serializable type and is used to allow or prevent certain actions inside a Tauri command. The configured scope is passed to the command and will be enforced by the command implementation.\n\n## Example\n\n```json { \"allow\": [{ \"path\": \"$HOME/**\" }], \"deny\": [{ \"path\": \"$HOME/secret.txt\" }] } ```",
"type": "object",
"properties": {
"allow": {
"description": "Data that defines what is allowed by the scope.",
"type": [
"array",
"null"
],
"items": {
"$ref": "#/definitions/Value"
}
},
"deny": {
"description": "Data that defines what is denied by the scope. This should be prioritized by validation logic.",
"type": [
"array",
"null"
],
"items": {
"$ref": "#/definitions/Value"
}
}
}
},
"Value": {
"description": "All supported ACL values.",
"anyOf": [
{
"description": "Represents a null JSON value.",
"type": "null"
},
{
"description": "Represents a [`bool`].",
"type": "boolean"
},
{
"description": "Represents a valid ACL [`Number`].",
"allOf": [
{
"$ref": "#/definitions/Number"
}
]
},
{
"description": "Represents a [`String`].",
"type": "string"
},
{
"description": "Represents a list of other [`Value`]s.",
"type": "array",
"items": {
"$ref": "#/definitions/Value"
}
},
{
"description": "Represents a map of [`String`] keys to [`Value`]s.",
"type": "object",
"additionalProperties": {
"$ref": "#/definitions/Value"
}
}
]
},
"Number": {
"description": "A valid ACL number.",
"anyOf": [
{
"description": "Represents an [`i64`].",
"type": "integer",
"format": "int64"
},
{
"description": "Represents a [`f64`].",
"type": "number",
"format": "double"
}
]
},
"Target": {
"description": "Platform target.",
"oneOf": [
{
"description": "MacOS.",
"type": "string",
"enum": [
"macOS"
]
},
{
"description": "Windows.",
"type": "string",
"enum": [
"windows"
]
},
{
"description": "Linux.",
"type": "string",
"enum": [
"linux"
]
},
{
"description": "Android.",
"type": "string",
"enum": [
"android"
]
},
{
"description": "iOS.",
"type": "string",
"enum": [
"iOS"
]
}
]
},
"PermissionKind": {
"type": "string",
"oneOf": [
{
"description": "Enables the cancel command without any pre-configured scope.",
"type": "string",
"const": "allow-cancel"
},
{
"description": "Denies the cancel command without any pre-configured scope.",
"type": "string",
"const": "deny-cancel"
},
{
"description": "Enables the close command without any pre-configured scope.",
"type": "string",
"const": "allow-close"
},
{
"description": "Denies the close command without any pre-configured scope.",
"type": "string",
"const": "deny-close"
},
{
"description": "Enables the connect command without any pre-configured scope.",
"type": "string",
"const": "allow-connect"
},
{
"description": "Denies the connect command without any pre-configured scope.",
"type": "string",
"const": "deny-connect"
},
{
"description": "Enables the delete_connection command without any pre-configured scope.",
"type": "string",
"const": "allow-delete-connection"
},
{
"description": "Denies the delete_connection command without any pre-configured scope.",
"type": "string",
"const": "deny-delete-connection"
},
{
"description": "Enables the delete_connections command without any pre-configured scope.",
"type": "string",
"const": "allow-delete-connections"
},
{
"description": "Denies the delete_connections command without any pre-configured scope.",
"type": "string",
"const": "deny-delete-connections"
},
{
"description": "Enables the delete_request command without any pre-configured scope.",
"type": "string",
"const": "allow-delete-request"
},
{
"description": "Denies the delete_request command without any pre-configured scope.",
"type": "string",
"const": "deny-delete-request"
},
{
"description": "Enables the duplicate_request command without any pre-configured scope.",
"type": "string",
"const": "allow-duplicate-request"
},
{
"description": "Denies the duplicate_request command without any pre-configured scope.",
"type": "string",
"const": "deny-duplicate-request"
},
{
"description": "Enables the list_connections command without any pre-configured scope.",
"type": "string",
"const": "allow-list-connections"
},
{
"description": "Denies the list_connections command without any pre-configured scope.",
"type": "string",
"const": "deny-list-connections"
},
{
"description": "Enables the list_events command without any pre-configured scope.",
"type": "string",
"const": "allow-list-events"
},
{
"description": "Denies the list_events command without any pre-configured scope.",
"type": "string",
"const": "deny-list-events"
},
{
"description": "Enables the list_requests command without any pre-configured scope.",
"type": "string",
"const": "allow-list-requests"
},
{
"description": "Denies the list_requests command without any pre-configured scope.",
"type": "string",
"const": "deny-list-requests"
},
{
"description": "Enables the list_websocket_connections command without any pre-configured scope.",
"type": "string",
"const": "allow-list-websocket-connections"
},
{
"description": "Denies the list_websocket_connections command without any pre-configured scope.",
"type": "string",
"const": "deny-list-websocket-connections"
},
{
"description": "Enables the list_websocket_requests command without any pre-configured scope.",
"type": "string",
"const": "allow-list-websocket-requests"
},
{
"description": "Denies the list_websocket_requests command without any pre-configured scope.",
"type": "string",
"const": "deny-list-websocket-requests"
},
{
"description": "Enables the send command without any pre-configured scope.",
"type": "string",
"const": "allow-send"
},
{
"description": "Denies the send command without any pre-configured scope.",
"type": "string",
"const": "deny-send"
},
{
"description": "Enables the upsert_request command without any pre-configured scope.",
"type": "string",
"const": "allow-upsert-request"
},
{
"description": "Denies the upsert_request command without any pre-configured scope.",
"type": "string",
"const": "deny-upsert-request"
},
{
"description": "Enables the upsert_websocket_request command without any pre-configured scope.",
"type": "string",
"const": "allow-upsert-websocket-request"
},
{
"description": "Denies the upsert_websocket_request command without any pre-configured scope.",
"type": "string",
"const": "deny-upsert-websocket-request"
},
{
"description": "Default permissions for the plugin",
"type": "string",
"const": "default"
}
]
}
}
}

View File

@@ -16,7 +16,7 @@ use yaak_models::models::{
};
use yaak_models::util::UpdateSource;
use yaak_plugins::events::{
CallHttpAuthenticationRequest, HttpHeader, RenderPurpose, WindowContext,
CallHttpAuthenticationRequest, HttpHeader, PluginWindowContext, RenderPurpose,
};
use yaak_plugins::manager::PluginManager;
use yaak_plugins::template_callback::PluginTemplateCallback;
@@ -125,7 +125,7 @@ pub(crate) async fn send<R: Runtime>(
environment.as_ref(),
&PluginTemplateCallback::new(
&app_handle,
&WindowContext::from_window(&window),
&PluginWindowContext::new(&window),
RenderPurpose::Send,
),
)
@@ -200,7 +200,7 @@ pub(crate) async fn connect<R: Runtime>(
environment.as_ref(),
&PluginTemplateCallback::new(
&app_handle,
&WindowContext::from_window(&window),
&PluginWindowContext::new(&window),
RenderPurpose::Send,
),
)

View File

@@ -7,13 +7,13 @@ pub enum Error {
#[error("WebSocket error: {0}")]
WebSocketErr(#[from] tungstenite::Error),
#[error("Model error: {0}")]
#[error(transparent)]
ModelError(#[from] yaak_models::error::Error),
#[error("Plugin error: {0}")]
#[error(transparent)]
PluginError(#[from] yaak_plugins::error::Error),
#[error("Render error: {0}")]
#[error(transparent)]
TemplateError(#[from] yaak_templates::error::Error),
#[error("WebSocket error: {0}")]