Skip to content

Desktop: authenticate local runtime requests - #397

Merged
priethor merged 3 commits into
mainfrom
priethor/docs/distribuir-app-macos
Jul 28, 2026
Merged

Desktop: authenticate local runtime requests#397
priethor merged 3 commits into
mainfrom
priethor/docs/distribuir-app-macos

Conversation

@priethor

@priethor priethor commented Jul 24, 2026

Copy link
Copy Markdown
Collaborator

What

Require a new random token on every launch before the desktop app serves WordPress or static files. Direct requests to the fixed localhost port now get 403; Cortext can still reload and open internal links in new windows.

External links open in the system browser. The app blocks external frames and document redirects from entering its private session. Desktop publishing and copy-link controls stay hidden, and published localhost URLs remain unavailable outside the app.

Why

Desktop autologin makes every accepted WordPress request an administrator request. A web page or accidental localhost client should not gain that access just by knowing the port.

How

All Cortext windows share a dedicated Electron session that keeps browser preferences between launches but never stores the token. Older desktop builds kept these preferences in Electron's default session, so this move resets them once. WordPress data and app settings are unchanged.

The PHP router and the experimental Caddy runtimes check the token before serving content. Caddy removes the header before PHP and redacts it from error logs.

Testing Instructions

  1. Build the desktop snapshot and start Cortext.
  2. Confirm that the initial document opens, then use View > Reload or Cmd+R and confirm that Cortext returns instead of showing "Forbidden".
  3. Change a browser-backed preference such as the color scheme, quit, reopen Cortext, and confirm that the preference remains.
  4. While Cortext is open, run curl -i http://127.0.0.1:9402/wp-includes/images/blank.gif and confirm that it returns 403 Forbidden.
  5. Close Cortext and confirm that its local PHP process exits.

I used Claude to help implement these changes. I guided the work, then tested and reviewed the result.

@priethor priethor added type: enhancement Improvement to existing behavior. area: desktop Desktop app, PHP runtime, snapshots, and desktop packaging. labels Jul 24, 2026
priethor added 2 commits July 27, 2026 18:35
Blocking every third-party subframe made the Embed block render blank.
The token now rides only on requests whose frame origin is Cortext's
own, so a provider iframe renders while its requests, nested frames,
popups, and service workers stay unauthenticated at the runtime. A
request with no frame behind it is never authenticated, and an embedded
frame cannot navigate the app window either.
@priethor
priethor merged commit 734c520 into main Jul 28, 2026
14 checks passed
@priethor
priethor deleted the priethor/docs/distribuir-app-macos branch July 28, 2026 18:21
@github-actions github-actions Bot added this to the 0.2.0 milestone Jul 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: desktop Desktop app, PHP runtime, snapshots, and desktop packaging. type: enhancement Improvement to existing behavior.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant