Feat: Implement Global Master Authentication Middleware#145
Open
ArshVermaGit wants to merge 2 commits into
Open
Feat: Implement Global Master Authentication Middleware#145ArshVermaGit wants to merge 2 commits into
ArshVermaGit wants to merge 2 commits into
Conversation
ArshVermaGit
commented
May 28, 2026
Contributor
Author
|
@siddu-k conflicts are resolved please review and merge |
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.
Overview
This pull request introduces a highly robust, application-wide Master Lock authentication system to mitigate the critical Missing Authentication & Authorization vulnerability.
Previously, most of the application's sensitive endpoints (e.g., file reading/writing, git operations) were completely unprotected, allowing attackers to bypass script-level locks. This architecture introduces a global security perimeter using the existing PBKDF2-HMAC-SHA256 cryptographic hashing mechanism while maintaining the UI's smooth single-page flow.
Resolved Issue
Resolves #144
Key Changes
Backend (
app.py)@app.before_requesthook that intercepts all traffic to/api/*(excluding the public status endpoint). If the__master__lock exists inlocks.json, the middleware validates theX-Master-Passwordheader.401 Unauthorizedwith{"master_locked": true}if the authentication header is missing or incorrect.GET /api/master/statusto allow the frontend to asynchronously verify if the application is locked.Frontend (
ui/app.js&ui/index.html)window.fetchto natively and transparently inject theX-Master-Passwordheader into every outgoing API request.master_locked: true401 response, it intercepts the promise, launches the new#master-auth-modal, waits for the user to submit the password, caches it in memory, and automatically replays the original API request without dropping any state or user actions.Security Impact