tauri-apps / tauri

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

[bug] Adding the "webview" attribute to capabilities does not give plugin permissions on additional webviews #10317

Open sebhernandezr opened 1 month ago

sebhernandezr commented 1 month ago

Describe the bug

Opening a new issue because the last one was closed -> https://github.com/tauri-apps/tauri/issues/10298

I want to invoke a command inside an additional webview with the initialization_script but I get a permissions error.

This is how my code looks like:

let mut webview_builder = WebviewBuilder::new(label, WebviewUrl::External(url))
  .initialization_script(
    r#"
      window.__TAURI_INTERNALS__.invoke("plugin:security|my_plugin", { foo });
    "#,
  );
window.add_child(
  webview_builder,
  PhysicalPosition::new(x, y),
  PhysicalSize::new(X, y),
)

My webview labels are created dynamically and they are always different. The flow is like this: an user clicks on a link in my app, that opens a new webview, and the label is an ID related to that link.

I have tried 3 things on my capabilities file based on @amrbashir suggestions:

None of them worked.

Reproduction

No response

Expected behavior

No response

Full tauri info output

[✔] Environment
    - OS: Mac OS 14.3.1 X64
    ✔ Xcode Command Line Tools: installed
    ✔ rustc: 1.79.0 (129f3b996 2024-06-10)
    ✔ cargo: 1.79.0 (ffa9cf99a 2024-06-03)
    ✔ rustup: 1.27.1 (54dd3d00f 2024-04-24)
    ✔ Rust toolchain: stable-aarch64-apple-darwin (default)
    - node: 20.13.1
    - pnpm: 9.1.2
    - npm: 10.5.2

[-] Packages
    - tauri [RUST]: 2.0.0-beta.23
    - tauri-build [RUST]: 2.0.0-beta.18
    - wry [RUST]: 0.41.0
    - tao [RUST]: 0.28.1
    - tauri-cli [RUST]: 1.5.14
    - @tauri-apps/api : not installed!
    - @tauri-apps/cli [NPM]: 2.0.0-beta.20

[-] App
    - build-type: bundle
    - CSP: unset
    - frontendDist: ../../dist/apps/exam-web
    - devUrl: http://localhost:3000/
    - framework: React
    - bundler: Vite

Stack trace

No response

Additional context

No response

sebhernandezr commented 1 month ago

@amrbashir Any ideas?