Gate /jobs/ and /tracker/ behind the nginx admin auth_request, like /sb/
Test and deploy / test (push) Successful in 27s
Test and deploy / deploy (push) Successful in 15s

The bearer-token routes a session cookie never reaches stay public at
nginx and are guarded by the apps: /jobs/api/capture and the job-capture
userscript, /tracker/api/v1/ and tracker.user.js.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
2026-10-15 18:57:18 +01:00
co-authored by Claude Opus 5.5
parent 45d4aa6eb2
commit 0ac3321c41
3 changed files with 79 additions and 24 deletions
+8 -5
View File
@@ -60,8 +60,8 @@ backend icecast2 gitea sb sb-pub python | |
| silverbullet-public (notes site) | `${SILVERBULLET_PUBLIC_HOST}` | `${SILVERBULLET_PUBLIC_PORT}` | `/notes/` (**public**, read-only) | no |
| silverbullet-git | n/a | n/a | none (timer loop) | no |
| python (FastAPI) | `${PYTHON_HOST}` | `${PYTHON_PORT}` | `/py/`, docs at `/py/docs` | no |
| jobs (job tracker, published image) | `jobs` | 8080 | `/jobs/` (admin-gated by the app itself) | no |
| activity-tracker (published image, adamf/ccp) | `activity-tracker` | 8080 | `/tracker/`, prefix stripped (collectors: per-device bearer keys; pages: admin-gated by the app itself) | no |
| jobs (job tracker, published image) | `jobs` | 8080 | `/jobs/` (admin-gated by nginx `auth_request`; capture API and userscript public, bearer-token) | no |
| activity-tracker (published image, adamf/ccp) | `activity-tracker` | 8080 | `/tracker/`, prefix stripped (pages admin-gated by nginx `auth_request`; `/api/v1/` bearer/app-checked) | no |
| icecast2 + liquidsoap | `${ICECAST_HOST}` | `${ICECAST_PORT}` | `/radio/` | **harbor port only** |
| gitea | `${GITEA_HOST}` | 3000, 2222 | `/gitea/` | **3000, 2222** |
| vue | `vue` | 5173 (dev only) | `/` (dev only) | no |
@@ -86,9 +86,12 @@ in one step — never change one without the other.**
- **Per-request DNS.** Upstreams go through `set $upstream_* ...` variables with
`resolver 127.0.0.11`, so names resolve per request. nginx boots fine with a
backend down (502s until it appears) instead of refusing to start.
- **Admin gate.** `/sb/`, `/radio/admin/` and `/uploads/private/` are protected by an `auth_request`
subrequest to the backend's `/auth/validate-admin`; a failure redirects to the
SPA login. None of these services has any auth of its own at that path.
- **Admin gate.** `/sb/`, `/jobs/`, `/tracker/`, `/radio/admin/` and `/uploads/private/` are
protected by an `auth_request` subrequest to the backend's `/auth/validate-admin`; a failure
redirects to the SPA login. Most of these services have no auth of their own at that path; the
job and activity trackers also check the session themselves. Their carve-outs, which a session
cookie never reaches, stay public at nginx and are guarded by bearer tokens in the apps:
`/jobs/api/capture` and `/jobs/job-capture.user.js`, `/tracker/api/v1/` and `/tracker/tracker.user.js`.
- **Public notes privacy boundary.** `/notes/` is public, and the only thing
keeping `private/` (and `templates/`, `.git`, `.obsidian`) off it is a pair of
nginx deny blocks. SilverBullet's `SB_SPACE_IGNORE` only hides paths from its
+9 -6
View File
@@ -482,9 +482,11 @@ services:
# database role of its own. A variable the tracker reads must be added to
# the list below as well as .env.example.
#
# It has no login. AUTH_VALIDATE_URL is the backend's validate-admin route
# (the one nginx's auth_request uses), which the tracker asks with the
# visitor's cookies on each admin request.
# It has no login. nginx's auth_request gates /jobs/ like /sb/ (except the
# bearer-token capture API and the userscript), and the tracker checks
# again itself: AUTH_VALIDATE_URL is the backend's validate-admin route
# (the one nginx's auth_request uses), which it asks with the visitor's
# cookies on each admin request.
#
# ./jobs-data holds the Microsoft Graph session and the capture token. The
# image runs as uid 1000, so the directory must be owned by it.
@@ -564,9 +566,10 @@ services:
# Two kinds of auth. Collectors send per-device bearer keys, made on the
# tracker's /tracker/setup page or with `docker exec activity-tracker
# tracker apikey create`. The dashboard and setup pages have no login of
# their own: like jobs, the tracker asks AUTH_VALIDATE_URL (the backend's
# validate-admin) with the visitor's cookies and sends anyone else to
# /admin/login.
# their own: nginx's auth_request gates them like /sb/ (everything but
# /tracker/api/v1/ and the userscript), and like jobs the tracker also asks
# AUTH_VALIDATE_URL (the backend's validate-admin) with the visitor's
# cookies and sends anyone else to /admin/login.
activity-tracker:
image: adam-french.co.uk/adamf/activity-tracker:${ACTIVITY_TRACKER_IMAGE_TAG:-latest}
container_name: activity-tracker
+62 -13
View File
@@ -372,15 +372,18 @@
# ---- Job tracker (/jobs/) ----
# Its own container (the adamf/job-tracker repo), which serves its SPA
# and its API from the same prefix. The prefix is NOT stripped: the
# app is built to live at /jobs/. There is no auth_request here: the
# SPA's files are public, and every API route that is not checks the
# session itself, by asking the backend's validate-admin with the
# visitor's cookies. ^~ so no regex location can claim a /jobs/ path.
# app is built to live at /jobs/. Gated like /sb/: everything under
# /jobs/ needs the admin session, checked here by auth_request before
# the app sees it (the app still checks the session itself too). Two
# exceptions, below, that a session cookie can never reach. ^~ so no
# regex location can claim a /jobs/ path.
location = /jobs {
return 301 /jobs/;
}
location ^~ /jobs/ {
auth_request /internal/auth/admin-validate;
error_page 401 403 = @auth_denied;
limit_req zone=api burst=20 nodelay;
# "Sync now" on the Settings page runs a whole email sync before
# answering.
@@ -392,6 +395,29 @@
proxy_set_header X-Forwarded-Proto $scheme;
}
# The capture API is called by the userscript from job sites' origins,
# with the capture bearer token rather than cookies, so it cannot pass
# the session gate; the app's CaptureTokenMiddleware guards it.
location ^~ /jobs/api/capture {
limit_req zone=api burst=20 nodelay;
proxy_pass $upstream_jobs;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
# The userscript itself: userscript managers fetch its @updateURL
# without the session, and it holds no secrets (the token is entered
# after install).
location = /jobs/job-capture.user.js {
proxy_pass $upstream_jobs;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
# ---- USACO practice log (/usaco/) ----
# Its own container (the usaco repo's site/), shaped like /jobs/: SPA
# and API under one prefix that is NOT stripped, and no
@@ -417,19 +443,23 @@
# ---- Activity tracker (/tracker/) ----
# Its own container (the adamf/ccp repo): an ingest API for device
# collectors, which send batches of events with a per-device bearer
# key, plus a dashboard and setup page. The app does its own auth, so
# no auth_request: the pages check the site session by asking the
# backend's validate-admin with the visitor's cookies, as /jobs/
# does, and /tracker.user.js is public. Unlike /jobs/
# the prefix IS stripped: the server serves /api/v1/... and /readyz
# from /. Collectors must use the www host: the apex 301 would turn
# their POSTs into GETs. Health Auto Export bodies can be several MB;
# the server-wide 50M client_max_body_size covers them.
# key, plus a dashboard and setup page. Gated like /sb/: the pages
# and their assets need the admin session, checked here by
# auth_request (the app also checks it itself). Two exceptions,
# below: the API, which collectors call with bearer keys and no
# cookies (the app guards each route, by device key, admin session or
# either), and the public /tracker.user.js. Unlike /jobs/ the prefix
# IS stripped: the server serves /api/v1/... and /readyz from /.
# Collectors must use the www host: the apex 301 would turn their
# POSTs into GETs. Health Auto Export bodies can be several MB; the
# server-wide 50M client_max_body_size covers them.
location = /tracker {
return 301 /tracker/;
}
location ^~ /tracker/ {
auth_request /internal/auth/admin-validate;
error_page 401 403 = @auth_denied;
limit_req zone=api burst=20 nodelay;
rewrite ^/tracker/(.*)$ /$1 break;
proxy_pass $upstream_tracker;
@@ -439,6 +469,25 @@
proxy_set_header X-Forwarded-Proto $scheme;
}
location ^~ /tracker/api/v1/ {
limit_req zone=api burst=20 nodelay;
rewrite ^/tracker/(.*)$ /$1 break;
proxy_pass $upstream_tracker;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
location = /tracker/tracker.user.js {
rewrite ^/tracker/(.*)$ /$1 break;
proxy_pass $upstream_tracker;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
# Where the tracker used to be. The SPA routes were client-side, so
# these only catch bookmarks and typed URLs. The userscript's old
# @updateURL lands on the third, which is how installed copies find
@@ -453,7 +502,7 @@
return 301 /jobs/job-capture.user.js;
}
# ---- Admin gate (/sb/, /radio/admin/, /uploads/private/) ----
# ---- Admin gate (/sb/, /jobs/, /tracker/, /radio/admin/, /uploads/private/) ----
# (/uploads/private/ is declared in the including template, not here;
# it points at the two locations below by name.)
# `auth_request` makes nginx fire a subrequest here before serving the