Skip to content

🛡️ Sentinel: [security improvement] Move staff verification to backend#37

Open
LVT-ENG wants to merge 1 commit intomainfrom
sentinel/move-staff-verification-to-backend-9127030693678809678
Open

🛡️ Sentinel: [security improvement] Move staff verification to backend#37
LVT-ENG wants to merge 1 commit intomainfrom
sentinel/move-staff-verification-to-backend-9127030693678809678

Conversation

@LVT-ENG
Copy link
Copy Markdown
Member

@LVT-ENG LVT-ENG commented Mar 27, 2026

The staff password verification was previously implemented in client-side JavaScript, exposing the password 'SAC_MUSEUM_2026' to anyone who inspected the source code. This PR moves the verification logic to the FastAPI backend, utilizes environment variables for secret management, and employs hmac.compare_digest to mitigate timing attacks. Frontend behavior remains identical but is now backed by secure server-side validation.


PR created automatically by Jules for task 9127030693678809678 started by @LVT-ENG

This change enhances security by moving the staff password verification from
the client-side JavaScript to a secure backend endpoint.

- Created `StaffLogin` model in `backend/models.py`.
- Implemented `/api/verify-staff` endpoint in `backend/main.py`.
- Used `hmac.compare_digest` for secure, timing-attack resistant comparison.
- Updated `js/main.js` to call the backend instead of using a hardcoded password.
- Added `STAFF_PASSWORD` to `.env.example`.
- Added comprehensive backend tests in `backend/tests/test_staff.py`.
- Verified changes with Playwright frontend tests.

Co-authored-by: LVT-ENG <214667862+LVT-ENG@users.noreply.github.com>
@google-labs-jules
Copy link
Copy Markdown
Contributor

👋 Jules, reporting for duty! I'm here to lend a hand with this pull request.

When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down.

I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job!

For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

@vercel
Copy link
Copy Markdown

vercel bot commented Mar 27, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
_deploy_build Ready Ready Preview, Comment Mar 27, 2026 5:45am
tryonyou-org Ready Ready Preview, Comment Mar 27, 2026 5:45am

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request implements a backend-based staff password verification system, replacing the previous hardcoded frontend check. Key changes include the addition of a /api/verify-staff endpoint in FastAPI using hmac.compare_digest for security, a new StaffLogin Pydantic model, and updated frontend logic in js/main.js to perform an asynchronous API call. The PR also introduces unit tests for the new endpoint and a Vite proxy configuration. Feedback was provided regarding the security risk of using a hardcoded default value for the STAFF_PASSWORD environment variable, suggesting it should be mandatory instead.


# 🛡️ Configuración Maestra (abvetos.com) - Secrets moved to environment variables
SECRET_KEY = os.getenv("LVT_SECRET_KEY", "DEVELOPMENT_SECRET_DO_NOT_USE_IN_PROD")
STAFF_PASSWORD = os.getenv("STAFF_PASSWORD", "SAC_MUSEUM_2026")
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

While using os.getenv is good for loading secrets from environment variables, providing a hardcoded default password directly in the application code (e.g., "SAC_MUSEUM_2026") is not ideal for a security-sensitive value like a staff password. In a production environment, this could lead to using a known, default password if the environment variable is not properly set.

Consider making the STAFF_PASSWORD environment variable mandatory for production deployments. For development, you could either:

  1. Set a random default if the environment variable is not found.
  2. Raise an error if the environment variable is not set, forcing explicit configuration.

This ensures that a secure password is always used and prevents accidental deployment with a known default.

Suggested change
STAFF_PASSWORD = os.getenv("STAFF_PASSWORD", "SAC_MUSEUM_2026")
STAFF_PASSWORD = os.getenv("STAFF_PASSWORD")
if not STAFF_PASSWORD:
raise ValueError("STAFF_PASSWORD environment variable not set.")

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.

1 participant