Fix authentication bypass on unknown routes#179
Merged
brian7704 merged 1 commit intobrian7704:masterfrom Apr 17, 2026
Merged
Conversation
Unauthenticated users hitting any non-existent route (e.g. /abc123) saw the full UI shell (navbar, sidebar, header) because DefaultLayout rendered unconditionally — the auth check only existed inside AppContent's PrivateRoute wrapper, which didn't cover the shell itself. Add an auth check at the top of DefaultLayout that redirects to /login if the user isn't authenticated. This prevents the shell from rendering at all for unauthenticated users, regardless of the route. Note: as Brian confirmed in #247, the backend API endpoints already properly reject unauthenticated requests — this was a UI-only issue where the shell appeared to be logged in but API calls would fail. The truststore download remains intentionally public. Fixes brian7704/OpenTAKServer#247 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
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.
Summary
Unauthenticated users hitting any non-existent route (e.g.
/abc123) saw the full UI shell (navbar, sidebar, header) becauseDefaultLayoutrendered unconditionally. The auth check only existed insideAppContent'sPrivateRoutewrapper, which didn't cover the shell itself.This adds an auth check at the top of
DefaultLayoutthat redirects to/loginif the user isn't authenticated, preventing the shell from rendering at all for unauthenticated users regardless of the route.What this does NOT change
As Brian noted in brian7704/OpenTAKServer#247, the backend API endpoints already properly reject unauthenticated requests — this was a UI-only issue where the shell appeared to be logged in but API calls would fail.
The truststore (
GET /api/truststore) remains intentionally available without authentication as it is a public key. While the UI navbar will no longer be visible to unauthenticated users (so they won't see the download button), the endpoint itself is unchanged and the truststore can still be downloaded directly by anyone who knows the URL.Test plan
https://<server>/abc123— should redirect to/loginhttps://<server>/users— should redirect to/logincurl https://<server>/api/truststorewithout auth — still returns the truststore fileFixes brian7704/OpenTAKServer#247
🤖 Generated with Claude Code