Repository navigation
feat: add HTTP Basic Auth for nginx reverse proxies - #171
TimeToBuildBob wants to merge 6 commits into
Conversation
[Medium impact] The PR appears safe to merge; no blocking issue remains. SummaryAdds HTTP Basic Auth options for nginx reverse proxies without replacing the client’s HTTP methods.
No new actionable issues were found. The supplied previous threads are unnumbered, so they have no numbered ledger entries. Tests were inspected, not run during this review. Diagram%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[Load auth settings] --> B{Auth configured?}
B -->|No| F[Start watcher normally]
B -->|Yes| C{Swift strategy or API-key conflict?}
C -->|Yes| D[Exit with an error]
C -->|No| E[Wrap client HTTP calls]
E --> G{Origin and path match?}
G -->|Yes| H[Attach Basic Auth]
G -->|No| I[Leave request unchanged]
Reviews (3) · Last reviewed commit: "fix(auth): scope Basic Auth to the confi..." · Reviewed by Greptile |
Adapt ActivityWatch#127 onto current master without replacing aw-client HTTP methods. Inject auth on the client module's requests calls so 0.5.14 and current master (API-key headers, loopback proxy bypass) both keep their kwargs. Refuse the default macOS swift strategy, which cannot attach credentials, and refuse combining Basic auth with a server API key. Keep secrets out of the first-run config template. Co-Authored-By: Violet Evergarden <2929724643@qq.com> Git-Session-Id: c21445f7-1f56-4701-aecd-76f905f63912
Git-Session-Id: 896b30ad-dd9a-559f-be4d-516e4c4aa070
15e2a6a to
a4caf13
Compare
|
CI-green and mergeable — waiting only on a maintainer click. This PR is ready to merge, but the bot has pull-only access to this repo and can't self-merge — surfacing it here so it isn't lost. The monitoring loop will stop re-flagging it now that this note is posted. |
🤖 AI code reviewAdds Safe to merge — no P0/P1 findingsConfidence 5/5 ✅ No findings. The diff looks correct to me on this pass. Files changed (4) — the diff as I read it
Previous review passes
Reviewed Maintainer commands
|
Git-Session-Id: cfbdd79b-4769-5866-a6cd-39e8e2d08a93
|
@greptileai review |
Git-Session-Id: bcaf3f21-fecb-5b96-9860-8826b07cbfc2
Git-Session-Id: bcaf3f21-fecb-5b96-9860-8826b07cbfc2
Git-Session-Id: bcaf3f21-fecb-5b96-9860-8826b07cbfc2
Carry of #127 onto current master, with credit to @liv10let.
The original replaced aw-client's private
_get/_post/_delete. That matches locked aw-client 0.5.14, but would drop API-key headers and the loopback proxy bypass on current aw-client master. This injectsauth=(user, password)on the client module'srequestscalls so whichever kwargs the installed client already sends are preserved.Also:
swiftstrategy (heartbeats come from a separate binary with no auth) — same fail-closed pattern asprivacy_filterAuthorization)auth_user/auth_passwordinto the first-run config template--auth-passwordis visible in the process list; prefer the TOML configauth_password = "") is honoured, not treated as "unset" —Nonemeans unsetVerification (2026-11-07, Linux)
Live nginx
auth_basicreverse proxy in front of a real aw-server v0.14.1 (isolated--profile, port 5666; nginx on 5667 with anhtpasswdfile). Three legs:GET /api/0/info→ 401 with no credentials, 401 with a wrong password, 200 with correct ones.aw_client.ActivityWatchClientwrite path fails with 401 without_enable_basic_auth(...)and succeeds with it — bucket created, heartbeat posted, event read back through the authenticated proxy.xvfb-run .venv/bin/python -m aw_watcher_window --host 127.0.0.1 --port 5667 --auth-user alice --auth-password secretlogsHTTP Basic Auth enabled for user: alice, thenPOST /api/0/buckets/aw-watcher-window_bob→ 200 and heartbeats → 200, with nginx's access log showing the authenticated requests and the bucket present on the server.Unit coverage: 214 passed, 6 skipped;
mypy aw_watcher_window/ --ignore-missing-importsclean on 16 source files (the CLI itself is exercised bymake test). Both Greptile P2s from the earlier head are addressed: empty passwords no longer disable auth, and the auth tests restore the patched request methods instead of leaking them to later tests.Rebased onto master (now includes the CI Ubuntu 24.04 pin and the repeatable
--exclude-*flags).Scope
Watcher-local, not first-class aw-client support. That is the only option available today: aw-client master has no Basic Auth support and no open issue or PR for one — its only
Authorizationuse is the local server API key, and the two are mutually exclusive on that header (handled by the refusal above).Does not merge or close #127; that disposition is #127's own.