Skip to content

Commit

Permalink
remove inlinedpermission struct [skip ci]
Browse files Browse the repository at this point in the history
  • Loading branch information
lucasfernog committed Jan 15, 2024
1 parent 2be4981 commit 609fcfb
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 26 deletions.
18 changes: 7 additions & 11 deletions core/tauri-build/src/acl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,7 @@ use std::collections::HashMap;

use anyhow::{Context, Result};
use serde::Deserialize;
use tauri_utils::acl::{
capability::Capability, plugin::Manifest, InlinedPermission, Permission, PermissionSet,
};
use tauri_utils::acl::{capability::Capability, plugin::Manifest, Permission, PermissionSet};

#[derive(Deserialize)]
#[serde(untagged)]
Expand Down Expand Up @@ -61,21 +59,19 @@ pub(crate) fn get_plugin_manifests() -> Result<HashMap<String, Manifest>> {
for permission_file in permission_files {
if let Some(default) = permission_file.default {
manifest.default_permission.replace(Permission {
inner: InlinedPermission {
identifier: "default".into(),
version: default.version,
description: default.description,
commands: default.commands,
scope: default.scope,
},
identifier: "default".into(),
version: default.version,
description: default.description,
commands: default.commands,
scope: default.scope,
});
}

if let Some(permissions) = permission_file.permission {
manifest.permissions.extend(
permissions
.into_iter()
.map(|p| (p.inner.identifier.clone(), p))
.map(|p| (p.identifier.clone(), p))
.collect::<HashMap<_, _>>(),
);
}
Expand Down
11 changes: 5 additions & 6 deletions core/tauri-codegen/src/context/resolve_acl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,15 +41,14 @@ pub fn resolve(
let permissions = get_permissions(plugin_name, permission_name, &acl)?;

for permission in permissions {
if permission.inner.commands.allow.is_empty() && permission.inner.commands.deny.is_empty()
{
if permission.commands.allow.is_empty() && permission.commands.deny.is_empty() {
// global scope
global_scope.push(permission.inner.scope.clone());
global_scope.push(permission.scope.clone());
} else {
current_scope_id += 1;
command_scopes.insert(current_scope_id, permission.inner.scope.clone());
command_scopes.insert(current_scope_id, permission.scope.clone());

for allowed_command in &permission.inner.commands.allow {
for allowed_command in &permission.commands.allow {
resolve_command(
&mut allowed_commands,
format!("plugin:{plugin_name}|{allowed_command}"),
Expand All @@ -58,7 +57,7 @@ pub fn resolve(
);
}

for denied_command in &permission.inner.commands.deny {
for denied_command in &permission.commands.deny {
resolve_command(
&mut denied_commands,
format!("plugin:{plugin_name}|{denied_command}"),
Expand Down
10 changes: 1 addition & 9 deletions core/tauri-utils/src/acl/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ pub struct Scopes {
///
/// If the scope is defined it can be used to fine grain control the access of individual or multiple commands.
#[derive(Debug, Serialize, Deserialize)]
pub struct InlinedPermission {
pub struct Permission {
/// The version of the permission.
pub version: Option<NonZeroU64>,

Expand All @@ -67,14 +67,6 @@ pub struct InlinedPermission {
pub scope: Scopes,
}

/// A permission.
#[derive(Debug, Serialize, Deserialize)]
pub struct Permission {
/// Permission data.
#[serde(flatten)]
pub inner: InlinedPermission,
}

/// A set of direct permissions grouped together under a new name.
#[derive(Debug, Serialize, Deserialize)]
pub struct PermissionSet {
Expand Down

0 comments on commit 609fcfb

Please sign in to comment.