d3fc6f2bfada18e6ae7887b79ed1e4c650ca37e1
2
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
1747559d02 |
plugin pages: name the scheme in a browser's policy, and the service's 'self' (#4198)
In `magpie web`, iOS Safari (18.7) loaded none of a plugin page's scripts: pagePolicy named the page's folder as a scheme-less host-source (host/_magpie/plugin/<tok>/), a sandboxed frame's origin is opaque, and that WebKit took the missing scheme from it, so the bridge never said hello and the page was broken at 10s (orinsid; YangHonghang on v0.1.2681, young02036 on Discord). - pagePolicy: a browser's policy now names the folder under both https:// and http:// (ownSources). Behind nginx or Cloudflare TLS ends before magpie and nothing magpie trusts says which scheme the page came over, so X-Forwarded-Proto is not read; both name the same host, port and folder, and an https page can't load http:// files anyway. The desktop window keeps its own transport alone (wails://, http:// on Windows, #2501). - The second layer (YangHonghang): a page's local service sends its own policy, `connect-src 'self'`, and what it sends runs under magpie's `sandbox allow-scripts`. In WebKit, 'self' there didn't match the service page's own fetch of api/x. servePageService now names the service's root (/_magpie/plugin/<tok>/_magpie/service/) under both schemes after each 'self' in a CSP header the service sends, plus ws:// and wss:// in connect-src and default-src (serviceSelf). 'self' stays, so nothing allowed before is taken away. A <meta> policy isn't rewritten; the plugin docs (en, zh, ja) say to write whole sources. Run at f0a723d4c's tree (rebased on |
||
|
|
75245b73c1 |
gui: a plugin's page in the desktop window names wails:// in its policy, so its bridge loads (#2501)
XYenon (#2501): on macOS the Plugins page stops answering after 10s. A plugin page is served in a frame with sandbox="allow-scripts", and its CSP named its own folder as a scheme-less source (localhost/p/<tok>/). Under wails://, WebKit doesn't match a scheme-less host source, so the page's bridge.js was refused and the page never said it was ready. ownWindow now records the scheme of the native handler's base URL (wails on macOS and Linux, http on Windows, as Wails v3 beta.24's assetserver_<os>.go sets them) in the request's context, and pagePolicy writes that scheme in front of the page's own source. Web requests have no scheme in the context, so the browser GUI keeps its relative source and still works over HTTP, HTTPS and reverse proxies. The patch and its test are the reporter's. The test now uses Wails' real hosts (wails://localhost, or http://wails.localhost on Windows), not a made-up one. What was run: - A WKWebView harness (Swift, a WKURLSchemeHandler for wails://) loading a page in a sandbox="allow-scripts" frame with the old and new CSP: with localhost/p/T/ the handler is never asked for bridge.js; with wails://localhost/p/T/ it is. At top level, with no frame, both load. - TestPluginPageWindowPolicy fails on the old pagePolicy (bridge.js refused for the desktop case) and passes now. - gofmt -l clean; go vet -tags nogui on darwin, linux and windows ok. - Full suite, set -o pipefail; go test -p 4 -timeout 45m ./... at this pair rebased on |