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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[feat] Web Request Callbacks and Filtering #4899

Open
ColonelThirtyTwo opened this issue Aug 9, 2022 · 9 comments
Open

[feat] Web Request Callbacks and Filtering #4899

ColonelThirtyTwo opened this issue Aug 9, 2022 · 9 comments

Comments

@ColonelThirtyTwo
Copy link

Describe the problem

Tauri should expose a way to register a Rust callback to intercept and modify requests that the application in the web view makes, as part of navigation, resource loading, or via JavaScript API calls. Election has an API to do this here: https://www.electronjs.org/docs/latest/api/web-request

Applications can use this functionality to modify requests for their needs (adding and removing headers for example) as well as preventing access to sites outside the scope of the application, for security.

Describe the solution you'd like

Electron has an API for this already that can serve as a base. Ideally, we can register two callbacks - one called with the request before it is sent and one called with the response after it is received. The callbacks should be passed the complete info about the request and response, and should be able to mutate or reject them.

Alternatives considered

Delegate requests to the core application via either IPC calls or custom protocols. This requires that the inner page be written to use them though, which is not possible for third party sites, and does not address the use case of security hardening.

Additional context

No response

@ColonelThirtyTwo ColonelThirtyTwo changed the title [feat] Web Request and Filtering [feat] Web Request Callbacks and Filtering Aug 9, 2022
@liesauer

This comment was marked as spam.

@liesauer
Copy link
Contributor

liesauer commented Sep 8, 2022

i am developing a hybrid framework app that allows user installs or uninstalls a in-app "app" which is a regular web app with limited hybrid call accessability. the startup app, i call it "hybrid core", is a web desktop(just likes the windows explorer) which has full control of every "app" including but not limited to: "Networking Accessability", "FileSystem Accessability", "Native API Accessability". therefore, "hybrid core" need to intercept every single request including normal webview http/https/ws request, tauri custom protocol request, tauri ipc message request, etc. to make it works.

@liesauer
Copy link
Contributor

liesauer commented Sep 8, 2022

i can intercept custom protocol request and ipc message now, but no normal http request.
for example:

<img src="http://example.com/abc.png" />

@liesauer
Copy link
Contributor

liesauer commented Sep 8, 2022

i developed a similar ios app for internal use(successfully upload to app store) in 2018. i want to refactor it that supports cross-platform with tauri recently.

@yuezk
Copy link
Contributor

yuezk commented Dec 22, 2022

I'm waiting for this, too. Do we have any plans for this? Thanks.

@FabianLars
Copy link
Member

request filtering is planned, yes. At least a somewhat simple approach/implementation.

modifying requests however is a tricky subject. It would be only possible on Windows. (In theory also on Linux but i do not consider this: #4912 (comment) a viable solution for tauri tbh)

@kotx
Copy link

kotx commented Feb 10, 2023

Should this be an issue in the WRY repo? Shouldn't be Tauri-specific, I think.

@chvanam
Copy link

chvanam commented Apr 6, 2023

Is there an update on this issue ? I agree that a "before/after http event" event with access to the request/response available would be a great addition and catch up to electron !

@github-project-automation github-project-automation bot moved this to 📬Proposal in Roadmap Sep 26, 2023
@findre
Copy link

findre commented Jan 12, 2024

I want get webview's cookie data, i need this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: 📬Proposal
Development

No branches or pull requests

7 participants