Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

[bug] HTTP scope can't allow all URIs #3507

Closed
elvinaspredkelis opened this issue Feb 18, 2022 · 6 comments
Closed

[bug] HTTP scope can't allow all URIs #3507

elvinaspredkelis opened this issue Feb 18, 2022 · 6 comments

Comments

@elvinaspredkelis
Copy link
Contributor

Describe the bug

Hello 馃憢

It is seemingly impossible allow all URIs to pass through the Tauri's HTTP API.

I do understand this is a security measure, however, some apps rely on allowing all URIs. E.g. developer tooling. Or, the URIs are validated somewhere else, like a backend server.

Reproduction

  1. Add required attributes to the allowlist in tauri.conf.json:
"http": {
        "all": true,
        "request": true,
        "scope": ["https://*", "http://*"]
      }
  1. Try to perform any HTTP request via the Tauri API
  2. Should get this error url not allowed on the configured scope

Expected behavior

It would be expected that such scopes would allow all URIs to pass through the scope validation:

  • http://*
  • https://*
  • Or perhaps work like shell scopes and allow either true or ^https?:// RegEx.

Platform and versions

Operating System - Mac OS, version 12.0.1 X64

Node.js environment
  Node.js - 16.6.2
  @tauri-apps/cli - 1.0.0-rc.4
  @tauri-apps/api - 1.0.0-rc.1

Global packages
  npm - 8.3.0
  pnpm - Not installed
  yarn - 1.22.11

Rust environment
  rustup - 1.24.3
  rustc - 1.58.1
  cargo - 1.58.0
  toolchain - stable-x86_64-apple-darwin 

App directory structure
/dist
/node_modules
/public
/src-tauri
/.git
/.vscode
/src

App
  tauri - 1.0.0-rc.2
  tauri-build - 1.0.0-rc.1
  tao - 0.6.2
  wry - 0.13.1
  build-type - bundle
  CSP - default-src 'self'
  distDir - ../dist
  devPath - http://localhost:8080/
  framework - Vue.js

Stack trace

No response

Additional context

No response

@qu1ck
Copy link

qu1ck commented Feb 27, 2022

Is this actually fixed? Do I have to wait for a release?

I updated my cargo.toml to have

[build-dependencies]
tauri-build = { git = "https://github.com/tauri-apps/tauri.git", features = [] }

[dependencies]
serde_json = "1.0"
serde = { version = "1.0", features = ["derive"] }
tauri = { git = "https://github.com/tauri-apps/tauri.git", features = ["http-all"] }

then did cargo update, cargo clean. On next build my app shows this in the log

   Compiling tauri-utils v1.0.0-rc.2 (https://github.com/tauri-apps/tauri.git#2d8dd495)
   Compiling tauri-build v1.0.0-rc.3 (https://github.com/tauri-apps/tauri.git#2d8dd495)
   Compiling tauri-codegen v1.0.0-rc.2 (https://github.com/tauri-apps/tauri.git#2d8dd495)
   Compiling tauri-macros v1.0.0-rc.2 (https://github.com/tauri-apps/tauri.git#2d8dd495)
   Compiling tauri-runtime v0.3.2 (https://github.com/tauri-apps/tauri.git#2d8dd495)
   Compiling tauri-runtime-wry v0.3.2 (https://github.com/tauri-apps/tauri.git#2d8dd495)

So it seems to pick up the latest from git.

I have this in my app.js:

const http = require('@tauri-apps/api/http')

window.onload = (event) => {
    http.fetch("https://some_valid_url").then(console.log);
}

and this in tauri.conf.json:

    "allowlist": {

      "http": {
        "all": true,
        "request": true,
        "scope": ["https://*"]
      }
    },

And I still get url not allowed on the configured scope in the console instead of a response.

What am I missing?

@lucasfernog
Copy link
Member

What's the URL you used to test it?

@qu1ck
Copy link

qu1ck commented Feb 27, 2022

https://www.google.com/search/howsearchworks/ for example

@lucasfernog
Copy link
Member

Since it's a glob pattern, you'd need to allow https://** in that case.

@qu1ck
Copy link

qu1ck commented Feb 27, 2022

Ah, I was confused by the example, thanks for fixing it. It works!

@cangSDARM
Copy link

never mind. I use rc3, it seems that this feat is only available in rc5

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants