Move auth check to frontend for CDN-friendly caching#1253
Open
zhangzhenghao wants to merge 1 commit intogorse-io:masterfrom
Open
Move auth check to frontend for CDN-friendly caching#1253zhangzhenghao wants to merge 1 commit intogorse-io:masterfrom
zhangzhenghao wants to merge 1 commit intogorse-io:masterfrom
Conversation
- Backend: Remove login check from dashboard handler, serve static files directly - Backend: Add CacheControlFilter to disable CDN caching for all API endpoints - Frontend can use existing /api/dashboard/userinfo to check auth status (200=logged in, 401=not logged in) This change makes dashboard pages return static files that can be safely cached by CDN, while authentication logic is handled by the frontend.
312c339 to
c4b6bcb
Compare
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #1253 +/- ##
==========================================
- Coverage 73.01% 72.96% -0.05%
==========================================
Files 91 91
Lines 16694 16734 +40
==========================================
+ Hits 12189 12210 +21
- Misses 3262 3280 +18
- Partials 1243 1244 +1 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
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
This PR moves authentication check from backend to frontend for CDN-friendly caching, following the same pattern as gitrec PR #166.
Backend Changes
Remove login check from dashboard handler
dashboardfunction now serves static files directly without checking login statusAdd
/api/meendpoint{is_authenticated: true/false, user_info: {...}}Add CacheControlFilter
Cache-Control: private, no-store, no-cache, must-revalidatefor all API endpointsBenefits
Frontend Changes (Required)
Frontend repository (gorse-io/dashboard) needs to be updated separately to:
/api/mebefore accessing protected routes/loginifis_authenticatedisfalseTesting