Skip to content

fix(server): default file-route loader middleware to action middleware - #201

Merged
JosunLP merged 1 commit into
devfrom
fix/181-datamiddlewares-default
Jul 6, 2026
Merged

fix(server): default file-route loader middleware to action middleware#201
JosunLP merged 1 commit into
devfrom
fix/181-datamiddlewares-default

Conversation

@JosunLP

@JosunLP JosunLP commented Jul 6, 2026

Copy link
Copy Markdown
Collaborator

Summary

Fixes #181 (Low; authz footgun by omission).

Action/HTML routes received options.middlewares; the JSON loader endpoints received a separate options.dataMiddlewares. A developer who protects mutations with middlewares: [auth] but forgets dataMiddlewares exposed every route's load() output as unauthenticated JSON at ${dataPath}<route> — the loader mirrors the same data an authenticated page renders, so this is a plausible authorization bypass introduced by omission.

Fix

dataMiddlewares now defaults to middlewares when unset (options.dataMiddlewares ?? options.middlewares). Pass dataMiddlewares: [] to explicitly opt loader routes out of the action chain. Documented on the option.

Verification

  • New tests: with middlewares: [auth] and no dataMiddlewares, the generated GET loader route inherits [auth]; with an explicit dataMiddlewares: [] it opts out. The default-inheritance test fails on the pre-fix code.
  • server suites: all pass. tsc --noEmit clean.

🤖 Generated with Claude Code

Action/HTML routes got options.middlewares while the JSON loader endpoints
got a separate options.dataMiddlewares. A developer protecting mutations
with middlewares: [auth] but omitting dataMiddlewares exposed every
route's load() output as unauthenticated JSON at ${dataPath}<route> — an
authorization bypass by omission.

dataMiddlewares now defaults to middlewares when unset; pass an explicit
empty array to opt the loader routes out.

Fixes #181

Co-Authored-By: Claude Fable 5 <[email protected]>
@coderabbitai

coderabbitai Bot commented Jul 6, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 9a6f6070-d678-41af-90b6-b857e10d52ea

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/181-datamiddlewares-default

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@github-actions github-actions Bot added tests Chenges to the tests server labels Jul 6, 2026
@JosunLP
JosunLP merged commit a2323f8 into dev Jul 6, 2026
9 checks passed
@JosunLP
JosunLP deleted the fix/181-datamiddlewares-default branch July 6, 2026 19:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

server tests Chenges to the tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant