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

refactor(ipc): use http::Request on with_ipc_handler #1183

Merged
merged 8 commits into from
Mar 6, 2024

Conversation

lucasfernog
Copy link
Member

This pull request changes the ipc_handler closure to get a new IpcRequest type instead of only receive the message string.
On macOS, iOS and Windows, we can read the request URL which enhances the security checks to verify the request source (currently only the url() function can be used, which does not work on contexts where an iframe is used).

For custom protocols, I believe the Origin header can be used instead of this.

@lucasfernog lucasfernog requested a review from a team as a code owner March 5, 2024 19:53
.cargo/config.toml Outdated Show resolved Hide resolved
src/lib.rs Outdated
@@ -1025,6 +1025,26 @@ impl<'a> WebViewBuilder<'a> {
}
}

/// Request from a IPC message. See [`WebViewBuilder::with_ipc_handler`] for more information.
pub struct IpcRequest {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

instead of a new type, can't we just pass the url as a second argument with Option<String>?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe we should use http::Request instead? we might add new parameters to this closure in the future (like a closure to provide a response to the webview) and it's more type safe to have a dedicated type for multiple parameters

src/webkitgtk/mod.rs Outdated Show resolved Hide resolved
src/android/binding.rs Outdated Show resolved Hide resolved
@lucasfernog lucasfernog changed the title refactor(ipc): introduce IpcRequest type to get source URL on supported platforms refactor(ipc): use http::Request on with_ipc_handler Mar 6, 2024
amrbashir
amrbashir previously approved these changes Mar 6, 2024
@lucasfernog
Copy link
Member Author

@amrbashir sorry had to push a docs update :D

@lucasfernog lucasfernog merged commit b8fea39 into dev Mar 6, 2024
12 checks passed
@lucasfernog lucasfernog deleted the refactor/ipc-origin branch March 6, 2024 13:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants