Skip to content

refactor: consolidate multiple passwords into a single master password for frontend actions - #307

Merged
dastine0308 merged 3 commits into
mainfrom
TEL-consolidate-fe-passwords
Jul 11, 2026
Merged

refactor: consolidate multiple passwords into a single master password for frontend actions#307
dastine0308 merged 3 commits into
mainfrom
TEL-consolidate-fe-passwords

Conversation

@dastine0308

@dastine0308 dastine0308 commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

Summary by CodeRabbit

  • New Features

    • Introduced a single shared master password for driver updates, finish-line changes, and snapshot creation.
    • Updated app configuration to use one consolidated password setting.
  • Bug Fixes

    • Standardized password verification across related endpoints to use the shared master password.
    • Simplified password environment setup by removing multiple dedicated password variables in favor of the new unified value.

@dastine0308
dastine0308 requested a review from a team as a code owner July 9, 2026 17:58
@vercel

vercel Bot commented Jul 9, 2026

Copy link
Copy Markdown

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

Project Deployment Actions Updated (UTC)
helios-telemetry Ready Ready Preview, Comment Jul 11, 2026 9:04pm

@coderabbitai

coderabbitai Bot commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

Action-specific passwords are consolidated into UI_MASTER_PASSWORD across ECS secret wiring, the server environment example, shared validation, and controller password checks.

Changes

UI Master Password Consolidation

Layer / File(s) Summary
Shared password validation
packages/server/src/utils/validatePassword.ts
validPassword now reads UI_MASTER_PASSWORD, and the separate driver and snapshot validators are replaced by validateMasterPassword.
Controller password gates
packages/server/src/controllers/routeControllers/driver.controller.ts, packages/server/src/controllers/routeControllers/snapshot.controller.ts, packages/server/src/controllers/LapController/LapController.ts
Driver updates, snapshot creation, and finish-line location updates call validateMasterPassword while retaining their existing invalid-password responses.
Environment and ECS secret wiring
packages/server/.env.example, packages/amplify/amplify/backend.ts
The environment example and ECS task mapping replace the three action-specific secrets with UI_MASTER_PASSWORD, sourced from HeliosPasswords.MASTER_PASSWORD.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Possibly related PRs

Suggested reviewers: burtonjong, justin-phxm, skand088

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main change: consolidating multiple frontend action passwords into one master password.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch TEL-consolidate-fe-passwords

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

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.

Actionable comments posted: 1

🧹 Nitpick comments (2)
packages/server/src/utils/validatePassword.ts (1)

35-38: 🔒 Security & Privacy | 🔵 Trivial | ⚡ Quick win

Use crypto.timingSafeEqual for password comparison.

Both validateDriverUpdatePassword and validateSnapshotPassword use ===, which short-circuits on the first mismatched byte and leaks timing information. Since validateSnapshotPassword was rewritten in this PR, this is a good opportunity to adopt a timing-safe comparison. Note that both functions are now identical (password === validPassword), so a single shared validateMasterPassword function would eliminate the duplication.

♻️ Proposed refactor: timing-safe shared validation
+import crypto from "crypto";
+
 const validPassword = process.env.MASTER_PASSWORD;

 if (!validPassword) {
   throw new Error("MASTER_PASSWORD environment variable is not configured");
 }

+function safeCompare(input: string, expected: string): boolean {
+  const a = Buffer.from(input);
+  const b = Buffer.from(expected);
+  if (a.length !== b.length) return false;
+  return crypto.timingSafeEqual(a, b);
+}
+
+export function validateMasterPassword(password: string): boolean {
+  return safeCompare(password, validPassword);
+}
+
 export function validateDriverUpdatePassword(password: string): boolean {
-  return password === validPassword;
+  return validateMasterPassword(password);
 }

 export function validateSnapshotPassword(password: string): boolean {
-  return password === validPassword;
+  return validateMasterPassword(password);
 }
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packages/server/src/utils/validatePassword.ts` around lines 35 - 38,
`validateSnapshotPassword` currently compares passwords with `===`, which is not
timing-safe and duplicates the same logic used by
`validateDriverUpdatePassword`. Update the password validation path in
`validatePassword.ts` to use `crypto.timingSafeEqual` on byte buffers, and
factor the shared comparison into a single `validateMasterPassword` helper that
both `validateDriverUpdatePassword` and `validateSnapshotPassword` call.
packages/amplify/amplify/backend.ts (1)

220-222: 🔒 Security & Privacy | 🔵 Trivial

Update the AWS HeliosPasswords secret before deployment.

The HeliosPasswords secret in AWS Secrets Manager must contain a MASTER_PASSWORD key. The old keys (DRIVER_NAME_UPDATE_PASSWORD, FINISH_LINE_UPDATE_PASSWORD, SNAPSHOT_PASSWORD) can be removed after confirming all services have been redeployed with this change. Consider a staged rollout: add MASTER_PASSWORD first, deploy, then remove old keys.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packages/amplify/amplify/backend.ts` around lines 220 - 222, The
`HeliosPasswords` Secrets Manager entry must be updated to include
`MASTER_PASSWORD` before this `backend.ts` change is deployed, since
`ecs.Secret.fromSecretsManager` now reads that key. Add `MASTER_PASSWORD` to the
secret first, verify deployment succeeds, and only then remove the legacy keys
(`DRIVER_NAME_UPDATE_PASSWORD`, `FINISH_LINE_UPDATE_PASSWORD`,
`SNAPSHOT_PASSWORD`) after all services have been rolled out with the new secret
name.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@packages/server/src/controllers/LapController/LapController.ts`:
- Around line 140-141: LapController is comparing against
process.env.MASTER_PASSWORD inline and logging the submitted password, so switch
the check to the shared validatePassword utility (or a shared
validateMasterPassword/validateFinishLinePassword helper) used by
validatePassword.ts, and ensure the env var is validated at module load instead
of call time. Update the password failure path in LapController to use that
shared validator and redact the provided password from logger.error so no secret
value is emitted.

---

Nitpick comments:
In `@packages/amplify/amplify/backend.ts`:
- Around line 220-222: The `HeliosPasswords` Secrets Manager entry must be
updated to include `MASTER_PASSWORD` before this `backend.ts` change is
deployed, since `ecs.Secret.fromSecretsManager` now reads that key. Add
`MASTER_PASSWORD` to the secret first, verify deployment succeeds, and only then
remove the legacy keys (`DRIVER_NAME_UPDATE_PASSWORD`,
`FINISH_LINE_UPDATE_PASSWORD`, `SNAPSHOT_PASSWORD`) after all services have been
rolled out with the new secret name.

In `@packages/server/src/utils/validatePassword.ts`:
- Around line 35-38: `validateSnapshotPassword` currently compares passwords
with `===`, which is not timing-safe and duplicates the same logic used by
`validateDriverUpdatePassword`. Update the password validation path in
`validatePassword.ts` to use `crypto.timingSafeEqual` on byte buffers, and
factor the shared comparison into a single `validateMasterPassword` helper that
both `validateDriverUpdatePassword` and `validateSnapshotPassword` call.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 21b045e8-01d8-46c8-a6b0-7d08ee9fcc82

📥 Commits

Reviewing files that changed from the base of the PR and between e764ca8 and abc8b30.

📒 Files selected for processing (4)
  • packages/amplify/amplify/backend.ts
  • packages/server/.env.example
  • packages/server/src/controllers/LapController/LapController.ts
  • packages/server/src/utils/validatePassword.ts

Comment thread packages/server/src/controllers/LapController/LapController.ts Outdated
VyapakBansal
VyapakBansal previously approved these changes Jul 11, 2026
alexwhelan12
alexwhelan12 previously approved these changes Jul 11, 2026

@alexwhelan12 alexwhelan12 left a comment

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.

LGTM!

@dastine0308
dastine0308 dismissed stale reviews from alexwhelan12 and VyapakBansal via f161643 July 11, 2026 21:01

@alexwhelan12 alexwhelan12 left a comment

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.

Nice!

@coderabbitai coderabbitai Bot left a comment

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.

🧹 Nitpick comments (1)
packages/server/src/utils/validatePassword.ts (1)

30-32: 🔒 Security & Privacy | 🔵 Trivial | ⚡ Quick win

Consider a constant-time comparison for the password check.

password === validPassword short-circuits on the first differing byte, leaking length/prefix timing. For a credential check, prefer a constant-time comparison (e.g. crypto.timingSafeEqual over equal-length buffers) to reduce timing side-channel risk.

🔒 Proposed constant-time comparison
+import { timingSafeEqual } from "crypto";
+
 export function validateMasterPassword(password: string): boolean {
-  return password === validPassword;
+  const a = Buffer.from(String(password));
+  const b = Buffer.from(String(validPassword));
+  return a.length === b.length && timingSafeEqual(a, b);
 }

Please confirm the Node runtime target supports crypto.timingSafeEqual (Node ≥ 6.6) in this package.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packages/server/src/utils/validatePassword.ts` around lines 30 - 32, Update
validateMasterPassword to use Node’s crypto.timingSafeEqual with equal-length
buffers for comparing password and validPassword, handling differing lengths
without calling the API on mismatched buffers. Confirm the package targets a
Node runtime that supports timingSafeEqual, while preserving the boolean
validation result.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@packages/server/src/utils/validatePassword.ts`:
- Around line 30-32: Update validateMasterPassword to use Node’s
crypto.timingSafeEqual with equal-length buffers for comparing password and
validPassword, handling differing lengths without calling the API on mismatched
buffers. Confirm the package targets a Node runtime that supports
timingSafeEqual, while preserving the boolean validation result.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 8d3b1637-de82-4115-9d77-6bde2273c9e5

📥 Commits

Reviewing files that changed from the base of the PR and between abc8b30 and f161643.

📒 Files selected for processing (6)
  • packages/amplify/amplify/backend.ts
  • packages/server/.env.example
  • packages/server/src/controllers/LapController/LapController.ts
  • packages/server/src/controllers/routeControllers/driver.controller.ts
  • packages/server/src/controllers/routeControllers/snapshot.controller.ts
  • packages/server/src/utils/validatePassword.ts
✅ Files skipped from review due to trivial changes (1)
  • packages/server/.env.example
🚧 Files skipped from review as they are similar to previous changes (1)
  • packages/amplify/amplify/backend.ts

@dastine0308
dastine0308 merged commit 1224707 into main Jul 11, 2026
8 checks passed
@dastine0308
dastine0308 deleted the TEL-consolidate-fe-passwords branch July 11, 2026 21:07
justin-phxm pushed a commit that referenced this pull request Jul 11, 2026
* Revert "fix: rename secret key for UI master password in ECS task definition (#308)"

This reverts commit c8bc134.

* Revert "refactor: consolidate multiple passwords into a single master password for frontend actions (#307)"

This reverts commit 1224707.
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.

4 participants