Repository navigation
refactor: share the auth callback parameters and secure random helpers - #1744
Conversation
Centralizes the auth callback URL parameter vocabulary (including the reserved sb_flow_id parameter) in supabase_common so the packages that read the parameters and the package that strips them from a callback URL cannot drift apart. Adds shared randomBytes and randomHex helpers and uses them in the PKCE verifier generation, the PKCE flow id generation, the raw nonce generation, and the iceberg idempotency key. Also switches iceberg to the shared isSuccessStatusCode and postgrest to the shared sendWith transport helper.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (13)
💤 Files with no reviewable changes (1)
Included review availability: Your plan provides up to 4 included reviews per hour; 2 remain after this review. 📝 WalkthroughWalkthroughThe PR adds shared callback and secure-random utilities. Authentication, Flutter, and Iceberg adopt them. PostgREST sends abortable requests through its configured client. Iceberg uses shared success-status validation. ChangesShared utilities and auth integration
HTTP execution cleanup
Estimated code review effort: 3 (Moderate) | ~20 minutes Merge Risk: ⚪ Minimal · up to This refactor centralizes existing authentication, randomness, status, and transport helpers without public API changes; no actionable merge-blocking risk remains beyond normal checks and review. Possibly related PRs
Suggested labels: Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ 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 |
…trix (#1787) ## What The capability-ID sync in #1786 added `auth.sign_in.concurrent_pkce_flows` to `sdk-compliance.yaml` with the default `not_implemented` status. The capability is already implemented, so this marks it `implemented` and gives it the symbols that describe it. ## Why it is already implemented The canonical capability asks for each PKCE code verifier to live in its own bounded, per-flow slot keyed by a generated flow id, with the code exchange accepting an optional flow id to select the right verifier. That is what `PKCEVerifierStore` does, landed in #1662 and refactored in #1744: - Each flow gets its own storage slot, pending ids are tracked in an index entry, and starting another flow past `AuthConstants.pkceMaxConcurrentFlows` (5) evicts the oldest. - `AuthClient.exchangeCodeForSession` takes an optional `flowId` and validates it before building a storage key. - `AuthClient.appendPkceFlowIdToRedirects` and `AuthClientOptions.appendPkceFlowIdToRedirects` put the id on the callback URL, and `getOAuthSignInUrl` / `getLinkIdentityUrl` return it as `OAuthResponse.flowId`. ## Changes `AuthClient.appendPkceFlowIdToRedirects`, `AuthClientOptions.appendPkceFlowIdToRedirects` and `OAuthResponse.flowId` move from `auth.sign_in.exchange_code_for_session` to the new capability, which is where they belong now that it exists. `exchange_code_for_session` keeps `AuthClient.exchangeCodeForSession`. No note is added, since the implementation matches expected parity. ## Verification The supabase/sdk compliance tooling was run locally against this branch: ``` validate-compliance OK — compliance file is valid. check-api-symbols All new public API symbols are covered in the capability matrix. check-drift No capability matrix drift detected. ``` <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **New Features** * Added support for handling multiple concurrent PKCE authentication flows. * **Bug Fixes** * Updated sign-in capability reporting to accurately associate PKCE flow support with concurrent authentication flows. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
Follow-up to #1572 (SDK-1281): a duplication sweep after the extraction tiers landed surfaced a few remaining production-code items.
Changes
sb_flow_idliteral was hardcoded insupabase_flutterbecauseAuthConstantsis internal tosupabase_auth, and the set of auth callback URL parameters was listed independently insupabase_authandsupabase_flutter. Both now come fromsupabase_common(pkceFlowIdParam,authCallbackParameters), so the package that reads the parameters and the package that strips them from a callback URL cannot drift apart.randomBytesandrandomHexinsupabase_commonreplace four hand-rolled "generate N secure random bytes and encode them" sites: the PKCE verifier generation, the PKCE flow id generation,generateRawNonceinsupabase_flutter(public API unchanged, only the body moved), and the UUIDv7 idempotency key iniceberg.iceberguses the sharedisSuccessStatusCodeinstead of an inlined status range check, the last local status check in the repo.postgrestuses the sharedsendWithtransport helper instead of hand-rolling the "create a one-off client when none is injected and close it afterwards" dance that storage, functions, and iceberg already get fromsupabase_common.No public API changes;
AuthConstants.pkceFlowIdParamwas@internal.Testing
dart analyzeclean on all touched packagessupabase_common,iceberg,postgrest,supabase_auth,supabase, andsupabase_flutterpass against the local CLI stackSummary by CodeRabbit
New Features
Bug Fixes