Extension pairing / code exchange for browser-watcher origins

Open
#638 0 comments 1 reaction 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
45/100
Issue type
Feature
Clarity
Mostly clear
Activity status
Active
Tech stack
python, rust

Research direction

The issue describes a pairing flow for browser extensions. Start by reading the existing CORS handling in aw-server-rust and the api_key fairing in aw-server/src/endpoints/apikey.rs. Also examine the Python server's aw_server/server.py for the same wildcard. Understand the aw-watcher-web extension's communication endpoints. Implementing this requires coordinated changes across repos, so first get familiar with the authentication flow and the existing code structure.

Written by the indexing model from the issue text.

Description

Follow-up to #637, which narrows the blanket moz-extension://.* CORS trust to the three endpoints aw-watcher-web needs. That closes the read/exfiltration half of the problem with no client change, but the underlying design issue remains: any installed Firefox extension can still write into its own bucket, because extension origins are random per install and cannot be allowlisted up front.

Background and the negative result that makes this necessary are in #637 — briefly: deleting the wildcard does not work, because host permissions do not exempt a Firefox background script from CORS (verified in Firefox 152; the server's ACAO header is the sole gate). So consent has to be captured at runtime instead.

Proposed design

  1. Extension POSTs its origin to /api/0/pair/request (reachable under the wildcard).
  2. Server mints a short code and surfaces a pending-pairing prompt in aw-webui (same-origin, trusted) and/or the tray.
  3. User approves. Server persists {origin, token}.
  4. Extension polls /api/0/pair/status, receives the token, and sends Authorization: Bearer <token> from then on. The server reflects ACAO for that origin only once paired, and enforces the token.

Reuses the existing api_key fairing (aw-server/src/endpoints/apikey.rs, #585) rather than adding a second auth path. Ship behind [auth] require_extension_pairing, default false for one release with a loud warning, then flip.

Needs matching aw-watcher-web work, so it is a coordinated change across repos rather than a server-only fix.

Also outstanding

  • aw-server (Python) has the same wildcard (aw_server/server.py, cors_origins.append("moz-extension://*")) and needs the endpoint scoping from #637, and later the pairing flow.

Credit

Original report by pal0x, privately to @ErikBjare, disclosed publicly with @ErikBjare's approval.

Related: #585 (api_key support), #588 / #636 (api_key bypasses), ActivityWatch/activitywatch#1199 (authentication generally).

Dominant language
Rust
Stars
322
Forks
105
Avg merge
3d 10h
Merged PRs (30d)
22

Getting set up

This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from ActivityWatch/aw-server-rust

All issues in ActivityWatch/aw-server-rust

Similar issues

More Rust issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.