tauri-apps / tauri

Build smaller, faster, and more secure desktop applications with a web frontend.
https://tauri.app
Apache License 2.0
79.58k stars 2.36k forks source link

[feat] how to allow all commands in the ACL #9227

Open liesauer opened 3 months ago

liesauer commented 3 months ago

Describe the problem

i already have a invoke_filter that use to judge which commands can be executed(before ACL came out). it does the exactly the same thing as ACL does. so i just want to pass everything in ACL side.

image

Describe the solution you'd like

if have a way to pass all commands or all commands of a plugin, it would be better, we don't need to modify the capabilities file again and again when adding a new command.

  "permissions": [
    "*",
    "all:all",
    "my-plugin:all"
  ]

Alternatives considered

No response

Additional context

No response

liesauer commented 3 months ago

btw, it looks like the ACL does not support custom plugin yet.

  "permissions": [
    "my-plugin:hello"
  ]
Permission my-plugin:hello not found, expected one of app:default ...
tillmann-crabnebula commented 3 months ago

if have a way to pass all commands or all commands of a plugin

You can add all of these to the default permission of the plugin and add the default permission to your capability. You only need to modify the plugins default permission in the plugin if you added a command and never touch the capabilities again.

btw, it looks like the ACL does not support custom plugin yet.

It supports all Tauri plugins out of the box and we have adapted most of our plugins in the plugin workspace, so feel free to check it out for reference (v2 branch).

Out of curiosity: Is your invoke filter using a similar concept as the isolation pattern or did you come up with another method?

liesauer commented 3 months ago

ummm, i get it now, plugin permissions missing, i was expecting changing v1 to v2 and everything should works. :grin:

liesauer commented 3 months ago

invoke filter is not similar as isolation pattern, because of the iframe limitation, i am not using it and decided to make a little patch to intercept every commands on on_message method.

when users run a "app" at first time, it will pop up a permission request dialog, if user allow, related commands get passed. similar concept as app permission likes modern operating system does. it more likes runtime version of ALC.

tillmann-crabnebula commented 3 months ago

Interesting concept. We have a similar runtime scope handling with the dialog+fs plugin combination, allowing users to make slected paths to be accessible for the fs plugin. Some plugins allow dynamic scope changes from rust at runtime using a "global" scope.

I think offering a generic way to prompt users at runtime for permission/scope changes/requests is something we should look into and make it part of the core functionality or a dedicated plugin after the 2.0 release.

Would you mind sharing relevant code or are you interested in supporting contributions to a plugin or Tauri itself to make your approach part of Tauri?

i was expecting changing v1 to v2 and everything should works. 😁

😁 would be nice right? Sometime we have to break things though and this a reason why we are doing a major version bump.

Did you try the migration tool or documentation from https://beta.tauri.app/guides/upgrade-migrate/from-tauri-1/?