Repository navigation
Conversation
`PROTECTED_API_PATHS` listed seventeen /api prefixes under the comment "Require auth, but allow through if requireLogin is disabled". It appears exactly once in the repository: its own declaration. Nothing reads it. That is worse than not having it. A list shaped like a policy invites the next person to protect a route by adding a line to it, and the line does nothing. The name is the whole hazard -- it reads as the thing that enforces auth on those paths. The rule it describes is real, and is the deny-by-default arm for `/api/*` in proxy(): anything not on the public allow-list needs a CLI token or an authenticated session, and isAuthenticated() returns true when requireLogin is off, which is the escape hatch the comment meant. That arm covers every /api path, not the seventeen named ones, so deleting the list changes no answer. Rather than delete it on that argument alone, the rule is now held by tests over the exact paths the list named: each is rejected unauthenticated, so is a child route, so is a path invented today, the requireLogin=false hatch still opens, and /api/settings/require-login stays public even though /api/settings is not. One expectation had to be corrected while writing them: /api/mcp/ answers 403, not 401, because a stricter local-only gate runs first. Asserting 401 everywhere would have recorded that stricter answer as a failure, so the child-route case accepts either and a separate test pins the 403. 37 tests pass; the existing dashboard-guard suite is unchanged; next build compiles.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
PROTECTED_API_PATHSlists seventeen/apiprefixes under this comment:It appears exactly once in the repository — its own declaration:
Nothing reads it.
Why that is worse than not having it
The name is the hazard. A list shaped like an access-control policy invites the next person to protect a route by adding a line to it — and the line does nothing. Nobody is protected less today, but the next person to trust it would be.
The rule it describes is real
It is the deny-by-default arm for
/api/*inproxy(): anything not on the public allow-list needs a CLI token or an authenticated session, andisAuthenticated()returns true whenrequireLoginis off — which is exactly the escape hatch the comment meant. That arm covers every/apipath, not the seventeen named ones, which is why deleting the list changes no answer.Held by tests rather than by that argument
tests/unit/dashboard-guard-api-deny-by-default.test.jsruns over the exact paths the dead list named:/api/prefix, not membership of any listrequireLogin=falsehatch still opens/api/settings/require-loginstays public even though/api/settingsis notOne expectation had to be corrected while writing them, and it is worth keeping:
/api/mcp/answers 403, not 401, because a stricter local-only gate runs first. Asserting 401 everywhere would have recorded that stricter answer as a failure — so the child-route case accepts either, and a separate test pins the 403 specifically.Verification
dashboard-guard.test.js— unchanged, still passingnpx next build— ✓ compiled successfully