Skip to content

Fix authentication bypass on unknown routes#179

Merged
brian7704 merged 1 commit intobrian7704:masterfrom
Knobee:fix/auth-bypass-unknown-routes
Apr 17, 2026
Merged

Fix authentication bypass on unknown routes#179
brian7704 merged 1 commit intobrian7704:masterfrom
Knobee:fix/auth-bypass-unknown-routes

Conversation

@Knobee
Copy link
Copy Markdown

@Knobee Knobee commented Apr 16, 2026

Summary

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.

This adds an auth check at the top of DefaultLayout that redirects to /login if 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

  • Open an incognito window, navigate to https://<server>/abc123 — should redirect to /login
  • Open an incognito window, navigate to https://<server>/users — should redirect to /login
  • Log in normally — all pages work as before
  • curl https://<server>/api/truststore without auth — still returns the truststore file

Fixes brian7704/OpenTAKServer#247

🤖 Generated with Claude Code

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>
@brian7704 brian7704 merged commit 88cf686 into brian7704:master Apr 17, 2026
@Knobee Knobee deleted the fix/auth-bypass-unknown-routes branch April 17, 2026 15:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] Authentication bypass

2 participants