Skip to content

fix: scope request auth to the original host and tighten file/browser-server handling - #19

Open
usamaiqb wants to merge 6 commits into
novincode:mainfrom
usamaiqb:fix/request-scoping-and-open-handling
Open

usamaiqb wants to merge 6 commits into
novincode:mainfrom
usamaiqb:fix/request-scoping-and-open-handling

Conversation

@usamaiqb

Copy link
Copy Markdown
Contributor

Summary

Small, independent fixes across core and desktop. One commit per change.

Core

  • Send cookies and saved credentials only to the same host the download was added for. After a cross-host redirect, or for HLS playlists and segments on another host, requests go without them. New request_scope module with tests.
  • Run HLS output filenames through sanitize_filename, like regular downloads.

Desktop

  • open_file: replace cmd /C start with the open crate, which uses the OS default handler (ShellExecuteW on Windows). open moves 5.3.3 → 5.4.4; it was already a dependency of tauri-plugin-shell.
  • /api/downloads: return a DownloadSummary with only the fields the extension uses, instead of the full Download.
  • Browser server: return 403 for requests whose Origin is not an extension scheme, or whose Host is not localhost, 127.0.0.1 or [::1]. Requests without an Origin are still allowed.

Notes

  • A cross-host redirect that depends on the original site's cookies will now go without them. Same-host redirects and http → https upgrades are unaffected.

Testing

  • cargo test -p dlman-core and -p dlman-desktop pass, except media::dash::tests::test_parse_simple_mpd, which already fails on main.

… belong to

Browser cookies and saved site credentials are captured for the URL the
user added. Requests that end up on a different host (after a redirect,
or a variant playlist / segment served from elsewhere) now go out
without them, matching how reqwest already treats redirect hops.

Adds `request_scope` with the shared host check and unit tests.
Stream (HLS) output names can come from the caller, the page title or
the URL path. Run them through `sanitize_filename` like regular
downloads so they get the same cleanup.
`open_file` shelled out to `cmd /C start` on Windows. Use the `open`
crate instead (ShellExecuteW on Windows, `open` on macOS, xdg-open on
Linux), so all three platforms go through the same code path.
`/api/downloads` serialised the internal `Download` model directly.
Return a `DownloadSummary` with just the fields the extension uses
instead, so the API shape no longer changes whenever `Download` gains a
field. Includes a test for the projection.
The local browser-integration server exists for the DLMan extension.
Serve requests whose `Origin` is a browser-extension scheme
(chrome-extension, moz-extension, safari-web-extension) and answer
anything else with 403. Requests without an `Origin` header are still
accepted, since Chrome can omit it for extension fetches.
The server binds 127.0.0.1 and the extension calls it as
`localhost:<port>`. Check the `Host` header against the loopback names
(`localhost`, `127.0.0.1`, `[::1]`, optionally with a port) and answer
anything else with 403. Includes unit tests for the host check.
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.

1 participant