Skip to content

Fix/legacy api key auth v2#2077

Open
Bhavy12-cell wants to merge 1 commit 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 1 commit 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

vercel Bot commented Jun 6, 2026

Copy link
Copy Markdown

@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

github-actions Bot commented Jun 6, 2026

Copy link
Copy Markdown

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!

@Priyanshu-byte-coder Priyanshu-byte-coder added gssoc:approved GSSoC: PR approved for scoring level:intermediate GSSoC: Intermediate difficulty (35 pts) labels Jun 9, 2026
@Priyanshu-byte-coder

Copy link
Copy Markdown
Owner

Hi! This PR has merge conflicts with the main branch. Could you please rebase or merge main into your branch to resolve them? We'd love to get this merged! 🚀

git fetch upstream
git rebase upstream/main
# resolve any conflicts
git push --force-with-lease

If you're no longer working on this, let us know and we can close it. Thanks!

@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 the main branch. Please rebase your branch on latest main and resolve the conflicts so it can be reviewed and merged.

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

Labels

gssoc:approved GSSoC: PR approved for scoring gssoc26 GSSoC 2026 contribution level:intermediate GSSoC: Intermediate difficulty (35 pts) 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