Skip to content

Fix/legacy api key auth v2#2077

Open
Bhavy12-cell wants to merge 2 commits into
Priyanshu-byte-coder:mainfrom
Bhavy12-cell:fix/legacy-api-key-auth-v2
Open

Fix/legacy api key auth v2#2077
Bhavy12-cell wants to merge 2 commits into
Priyanshu-byte-coder:mainfrom
Bhavy12-cell:fix/legacy-api-key-auth-v2

Conversation

@Bhavy12-cell
Copy link
Copy Markdown
Contributor

Closes #1635

Fixed legacy API key authentication failure after hash migration.

Root cause:
authenticateApiKey() compared hash against api_key column for legacy
rows, but legacy rows contain plaintext — so the comparison always failed.

Fix:

  • Step 1: Try modern hashed lookup (api_key_hash column)
  • Step 2: Fallback to plaintext comparison for legacy rows
    (where api_key_hash IS NULL)
  • On successful legacy auth, backfill api_key_hash and update
    last_used_at in one update
  • New keys no longer store plaintext in api_key column
  • Uses maybeSingle() instead of single() to avoid errors on no match

@vercel
Copy link
Copy Markdown

vercel Bot commented Jun 6, 2026

@Bhavy12-cell is attempting to deploy a commit to the PRIYANSHU DOSHI's projects Team on Vercel.

A member of the Team first needs to authorize it.

@github-actions github-actions Bot added gssoc26 GSSoC 2026 contribution type:bug GSSoC type bonus: bug fix type:security GSSoC type bonus: security (+20 pts) labels Jun 6, 2026
@github-actions
Copy link
Copy Markdown

github-actions Bot commented Jun 6, 2026

GSSoC Label Checklist 🏷️

@Priyanshu-byte-coder — please apply the appropriate labels before merging:

Difficulty (pick one):

  • level:beginner — 20 pts
  • level:intermediate — 35 pts
  • level:advanced — 55 pts
  • level:critical — 80 pts

Quality (optional):

  • quality:clean — ×1.2 multiplier
  • quality:exceptional — ×1.5 multiplier

Validation (required to score):

  • gssoc:approved — counts for points
  • gssoc:invalid / gssoc:spam / gssoc:ai-slop — does not score

Type labels (type:*) are auto-detected from files and title. Review and adjust if needed.
Points formula: (difficulty × quality_multiplier) + type_bonus

@Priyanshu-byte-coder
Copy link
Copy Markdown
Owner

This PR has conflicts with main. Please rebase on main and resolve conflicts, then we can review.

@Bhavy12-cell
Copy link
Copy Markdown
Contributor Author

Hi @Priyanshu-byte-coder!

Rebased on latest main and force-pushed. No conflicts remaining. Ready for review!

@Priyanshu-byte-coder
Copy link
Copy Markdown
Owner

This PR has merge conflicts with main. Please rebase to continue:

git fetch origin
git rebase origin/main

@Bhavy12-cell
Copy link
Copy Markdown
Contributor Author

Hi @Priyanshu-byte-coder!
Rebased on latest main. Ready for review!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

gssoc26 GSSoC 2026 contribution type:bug GSSoC type bonus: bug fix type:security GSSoC type bonus: security (+20 pts)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Legacy Local-Coding API Keys Fail After Hash Migration

2 participants