Commit Graph
12 Commits
Author SHA1 Message Date
lucio cc26953d5e Add POST /api/links REST endpoint for short-link creation
Programmatic short-link creation that shares the same bearer key as the
MCP endpoint. Registered only when [mcp].enabled is true and api_key is
set, so a misconfigured server never exposes the route unauthenticated;
unauthenticated visitors hitting /api/links get a plain 404.

- POST /api/links accepts {"url","slug?"}, returns 201/200 with the
  same snake_case payload shape as the MCP create_link tool.
- Constant-time Bearer / X-API-Key auth (reuses mcpAPIKeyAuth helper).
- 4 KB body cap, DisallowUnknownFields, URL auto-scheme, dedupe on URL.
- 13 unit tests cover auth, validation, dedupe, and duplicate-slug.
2026-06-08 21:17:39 -07:00
lucioandClaude Opus 4.8 67731cfcac Persist sessions in SQLite so logins survive a server restart
Sessions were stored in an in-memory map, so every server reboot logged the
admin out. Back the session store with the database instead:

- Add a sessions table (token, expires_at, created_at) created via the existing
  migrate() (CREATE TABLE IF NOT EXISTS), backwards-compatible with deployed DBs.
- Add CreateSession / SessionValid / DeleteSession / CleanupSessions; expiry is
  checked in SQL against datetime('now') (UTC).
- sessionStore is now a thin DB-backed wrapper with the same Create/Valid/Delete
  interface; the hourly cleanup goroutine purges expired rows (plus once at
  startup). Login, logout, requireAuth, and isLoggedIn are unchanged.

The session cookie was already persistent (MaxAge), so logins now survive both
browser and server restarts until session_hours expiry.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
2026-06-05 01:08:25 -07:00
lucioandClaude Opus 4.8 87477556e2 Redesign admin Pastes page as Xiaohongshu-style cards with previews
- Replace the pastes table with a masonry card grid: each card shows the
  paste's first image as a thumbnail, a short plain-text summary, meta badges,
  and Copy link / Edit / QR / Delete actions.
- Clicking anywhere on a card (except the action buttons) opens an in-page
  preview modal with the rendered paste in an iframe; it can be expanded to the
  main content area or closed (Esc/backdrop/button). Keyboard accessible.
- Generate and cache 512px (long side) JPEG thumbnails for uploaded images on
  first request (GET /uploads/thumb/{filename}); also generated at upload time
  and invalidated on resize/delete. WebP falls back to the original.
- Sync the public paste pages (bin_view, bin_token) to the dark theme so they
  match the rest of the app and the preview iframe.
- Relax framing headers to same-origin (X-Frame-Options SAMEORIGIN,
  frame-ancestors 'self') so the same-origin preview iframe can load; cross-site
  framing stays blocked.
- Document the new thumbnail route in the README routes table.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
2026-06-05 00:23:51 -07:00
lucioandClaude Opus 4.8 1be1e0c001 Fix large image uploads failing with bogus CSRF 403 + add client-side compression
The upload handlers called verifyCSRF (which reads a form value, implicitly
triggering ParseMultipartForm) before parsing the multipart body. When a file
exceeded the MaxBytesReader cap, the parse failed, FormValue returned "", and
the request was rejected as "Invalid CSRF token" (403) instead of a proper
413 "File too large". Small images parsed fine, so only large uploads broke.

- handlers.go: parse the multipart form explicitly before the CSRF check in
  both handleUpload and handleFileUpload; report oversized bodies as 413 via
  errors.As(http.MaxBytesError) instead of a fragile error-string compare.
- upload.js: offer in-browser canvas compression (downscale + JPEG re-encode)
  for images over 10 MB before upload; falls back to the original on failure.
- server.go: allow blob: in CSP img-src so the compressor canvas can load the
  selected file.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
2026-06-04 23:03:38 -07:00
lucio 2f5c31499d security review 2026-06-02 01:24:19 -07:00
lucio 4ca04bf8ed Add authenticated MCP endpoint 2026-05-22 01:14:51 -07:00
lucioandClaude Opus 4.6 b069027d56 Add generic file upload support to pastebin (5 MB max)
Adds a new POST /admin/upload-file endpoint for uploading any file type
alongside the existing image upload. Files are served with
Content-Disposition: attachment to prevent same-origin XSS via uploaded
HTML/SVG/JS. The display filename embedded in markdown link responses is
sanitized to block markdown injection.

Co-Authored-By: Claude Opus 4.6 <[email protected]>
2026-05-21 00:48:14 -07:00
lucio b45c837c1a Add image upload functionality with management interface 2026-04-08 01:06:12 -07:00
lucio f80903c7eb Implement hidden paste feature with QR code generation and access token handling 2026-04-08 00:13:47 -07:00
lucioandClaude Opus 4.6 a22c4939c2 Replace client-side QR with server-side endpoint for admin dashboard
The JS QR library (qr.min.js) produced unscannable codes. Replaced with
a /admin/qr/{slug} endpoint using the same server-side rsc.io/qr that
already works on the home page.

Co-Authored-By: Claude Opus 4.6 <[email protected]>
2026-04-02 03:41:00 -07:00
lucioandClaude Opus 4.6 1bfad9ed7c Rename project to Glimmer for luci.ooo
Rebrand from "urlshort" to "Glimmer" across the entire codebase:
Go module/imports, build targets, HTML templates, deploy scripts
(including renaming service files), config, and README.

Co-Authored-By: Claude Opus 4.6 <[email protected]>
2026-04-02 03:00:08 -07:00
lucioandClaude Sonnet 4.6 60a09fa878 Initial commit: URL shortener + pastebin with dark admin UI and deploy scripts
Features:
- URL shortener with QR codes, click tracking, deduplication, rate limiting
- Pastebin with Markdown rendering, access tokens, raw view
- Admin dashboard: dark theme, stats bar, Quick Links tiles with favicons,
  card-based layout, format/token badges, empty states
- CSRF protection, bcrypt auth, in-memory sessions, security headers
- Pure-Go SQLite (no CGo), single self-contained binary

Deploy:
- deploy/install.sh: auto-detects systemd vs SysV init
- deploy/urlshort.service: hardened systemd unit
- deploy/urlshort.init: SysV init script for older Ubuntu

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
2026-04-02 03:00:08 -07:00