Skip to content

Add Cloudflare Worker private navigation app (bookmarks, bg, weather) - #2

Open
omaler886 wants to merge 1 commit into
mainfrom
codex/create-cf-deployable-worker-code-c0ry9l
Open

Add Cloudflare Worker private navigation app (bookmarks, bg, weather)#2
omaler886 wants to merge 1 commit into
mainfrom
codex/create-cf-deployable-worker-code-c0ry9l

Conversation

@omaler886

Copy link
Copy Markdown
Owner

Motivation

  • Provide a self-hosted, password-protected navigation / bookmarks web app served from a Cloudflare Worker with minimal infrastructure.
  • Persist user bookmarks and background settings in a KV namespace and surface daily auto backgrounds or manual overrides.
  • Offer a simple weather view using the Open-Meteo API to enrich the dashboard experience.

Description

  • Added worker.js which implements HTTP handlers for POST /api/login, POST /api/logout, GET/POST /api/bookmarks, GET/POST /api/bg, and GET /api/weather, plus root pages for the login and main app UI.
  • Implements cookie-based authentication where a session token is derived via signValue (SHA-256) from ACCESS_PASSWORD, and KV storage is accessed via the NAV_KV binding for bookmarks and background keys.
  • Client-side HTML/JS is embedded in worker.js and provides UI for navigation/bookmarks, manual/auto background selection, and weather fetching; background auto-caching uses bg:auto:YYYY-MM-DD keys and picsum.photos as a default source.
  • Added wrangler.toml with NAV_KV namespace placeholder and README.md with deployment steps and KV key documentation.

Testing

  • No automated tests were added or run as part of this change.

Codex Task

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 697a785bfa

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread worker.js
a.href = item.url;
a.target = '_blank';
a.rel = 'noreferrer';
a.innerHTML = '<strong>' + item.title + '</strong><div style="opacity:.75;margin-top:6px;font-size:12px">' + item.url + '</div>';

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Stop injecting bookmark fields via innerHTML

renderCards inserts item.title and item.url directly into a.innerHTML, but these values come from KV-backed bookmark data and are not sanitized. A crafted bookmark title like HTML with an event handler becomes persistent XSS that executes whenever the dashboard loads, allowing arbitrary script execution in the authenticated origin. Render untrusted fields with textContent/DOM nodes instead of concatenated HTML.

Useful? React with 👍 / 👎.

Comment thread worker.js
}
if (request.method === 'POST') {
const body = await safeJson(request);
if (!Array.isArray(body?.bookmarks)) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Validate bookmark entry schema before saving

The POST /api/bookmarks handler only verifies that bookmarks is an array, so payloads like [null] are accepted and persisted. On the next read, renderCards dereferences item.url/item.title; a null element throws and breaks dashboard rendering until KV data is repaired. Add per-item validation (object with string title and string url) before writing to KV.

Useful? React with 👍 / 👎.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant