Stored redirect-token table and open-redirect-safe short links #13

Closed
opened 2026-06-23 23:15:13 +00:00 by rbrooks · 1 comment
Owner

Target release: v1.2.0

Add a short-link/redirect-token storage layer so that when SHORT_LINK_BASE_URL points at a redirect-only domain, tokens resolve only to stored WeatherBot-generated targets (or a tightly allowlisted set of external official/weather-media URLs). Avoid any generic unauthenticated open redirect.

Acceptance

  • Short-link/redirect-token table mapping token → stored canonical target.
  • outbound_url() can emit short redirect URLs when a redirect-only short domain is configured.
  • External URLs are returned unchanged unless explicitly allowlisted.
  • Redirect-token / open-redirect rejection tests.

Source: docs/ROADMAP.md → Notification Message Budget and Compact Link System.

**Target release:** v1.2.0 Add a short-link/redirect-token storage layer so that when `SHORT_LINK_BASE_URL` points at a redirect-only domain, tokens resolve **only** to stored WeatherBot-generated targets (or a tightly allowlisted set of external official/weather-media URLs). Avoid any generic unauthenticated open redirect. **Acceptance** - [ ] Short-link/redirect-token table mapping token → stored canonical target. - [ ] `outbound_url()` can emit short redirect URLs when a redirect-only short domain is configured. - [ ] External URLs are returned unchanged unless explicitly allowlisted. - [ ] Redirect-token / open-redirect rejection tests. Source: `docs/ROADMAP.md` → Notification Message Budget and Compact Link System.
Contributor

Done in #99 (merged). Added a redirect_tokens table (token → stored canonical target, deduped by hash) and an open-redirect-safe GET /r/{token} resolver — the 302 target is read only from the store, never from the request, and external targets must be host-allowlisted (SHORT_LINK_EXTERNAL_ALLOWLIST); unknown tokens 404. Notification links opt into {SHORT_LINK_BASE_URL}/r/{token} short links via SHORT_LINK_REDIRECT_MODE (default off keeps the existing compact-base proxy model, so no behavior change unless enabled). Tests cover resolution, open-redirect rejection, external passthrough, and the redirect-mode wiring.

Done in #99 (merged). Added a `redirect_tokens` table (token → stored canonical target, deduped by hash) and an open-redirect-safe `GET /r/{token}` resolver — the 302 target is read only from the store, never from the request, and external targets must be host-allowlisted (`SHORT_LINK_EXTERNAL_ALLOWLIST`); unknown tokens 404. Notification links opt into `{SHORT_LINK_BASE_URL}/r/{token}` short links via `SHORT_LINK_REDIRECT_MODE` (default off keeps the existing compact-base proxy model, so no behavior change unless enabled). Tests cover resolution, open-redirect rejection, external passthrough, and the redirect-mode wiring.
Sign in to join this conversation.
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
rbrooks/WeatherBot#13
No description provided.