fix(auth): make token optional and relax linked account type validation#1065
fix(auth): make token optional and relax linked account type validation#1065
Conversation
- Make token field optional in PrivyAuthRequest (not used for validation) - Add type normalization for Privy account types (sms→phone, github_oauth→github) - Expand valid linked account types to include twitter, passkey, smart_wallet, etc. - Log unknown types as warnings instead of rejecting them 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
|
This pull request has been ignored for the connected project Preview Branches by Supabase. |
|
Warning Rate limit exceeded
⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. ✨ Finishing touches🧪 Generate unit tests (beta)
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. Comment |
|
❌ CI pipeline failed. Auto-merge is disabled until all checks pass. |
Summary
tokenfield optional inPrivyAuthRequestschema (not currently used for validation)sms→phone,github_oauth→github, etc.)twitter,passkey,smart_wallet, etc.Context
The strict token requirement and account type validation were causing login failures:
smsbut backend only acceptedphoneSecurity Notes
Test plan
🤖 Generated with Claude Code
Greptile Overview
Greptile Summary
This PR improves authentication robustness by making the
tokenfield optional inPrivyAuthRequestand relaxing linked account type validation. The changes prevent login failures when the frontend cannot retrieve a Privy token or when Privy sends account types in different formats.Key Changes:
tokenfield optional with defaultNone(not currently used for authentication)sms→phone,github_oauth→github, etc.)twitter,passkey,smart_wallet,cross_app,walletImpact:
The changes improve authentication reliability by handling Privy's various account type formats gracefully. Since the
tokenfield is not used for actual authentication validation (user is authenticated via Privy ID), making it optional poses no security risk.Confidence Score: 4/5
tokenfield is confirmed unused for validation (onlyprivy_user_idmatters), so making it optional is safe. The relaxed account type validation is appropriate given Privy's evolving account types. One point deducted because the unusedtokenfield could be removed entirely in a future cleanup.Important Files Changed
tokenoptional and relaxes account type validation with normalization, improving login compatibility with Privy's various account typesSequence Diagram
sequenceDiagram participant Frontend participant FastAPI as FastAPI Auth Route participant Schema as PrivyAuthRequest Schema participant Validator as Account Type Validator participant Auth as Auth Handler participant DB as Database Frontend->>FastAPI: POST /auth (Privy user data) Note over Frontend,FastAPI: token field is optional now FastAPI->>Schema: Validate PrivyAuthRequest alt Token provided (optional) Schema->>Schema: Accept token (not validated) else Token missing Schema->>Schema: Accept None (no error) end Schema->>Validator: Validate linked account types alt Account type needs normalization Validator->>Validator: Normalize type<br/>(sms→phone, github_oauth→github) end alt Known account type Validator->>Validator: Return normalized type else Unknown account type Validator->>Validator: Log warning, pass through end Schema->>FastAPI: Validation successful FastAPI->>Auth: Process authentication Auth->>DB: Lookup/create user by privy_user_id DB->>Auth: User data Auth->>FastAPI: Authentication result FastAPI->>Frontend: PrivyAuthResponse with API key