Skip to content

feat(oauth): add Coinbase OAuth provider#152

Draft
halvaradop wants to merge 2 commits intomasterfrom
feat/add-coinbase-aouth
Draft

feat(oauth): add Coinbase OAuth provider#152
halvaradop wants to merge 2 commits intomasterfrom
feat/add-coinbase-aouth

Conversation

@halvaradop
Copy link
Copy Markdown
Member

@halvaradop halvaradop commented Apr 23, 2026

Description

This pull request adds the Atlassian OAuth provider to the list of supported OAuth integrations in the Aura Auth library.
With this addition, Aura Auth now supports seven OAuth providers: GitHub, Bitbucket, Figma, Discord, GitLab, Spotify, X, Strava and Atlassian

Usage

import { createAuth } from "@aura-stack/auth"

export const auth = createAuth({
  oauth: ["coinbase"],
})

export const { handlers } = auth

Note

This Coinbase OAuth provider was developed based on the Officials Docs for App OAuth 2.0 Integration, covering the authorization URL, access token exchange, and profile retrieval. However, the provider cannot currently be verified because the documentation lacks clear instructions on how to obtain a Client ID and Client Secret. Consequently, this PR will remain a draft until these credentials can be acquired to verify the end-to-end OAuth 2.0 flow.

@vercel
Copy link
Copy Markdown
Contributor

vercel Bot commented Apr 23, 2026

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

Project Deployment Actions Updated (UTC)
auth Ready Ready Preview, Comment Apr 23, 2026 7:29pm

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 23, 2026

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: a514f9af-bdec-4d62-a05b-1bcde274d9d4

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

This pull request adds Coinbase as a new built-in OAuth provider. Changes include a provider module with profile mapping, integration into the OAuth registry, and comprehensive documentation covering setup, configuration, and usage across client and server contexts.

Changes

Cohort / File(s) Summary
Coinbase OAuth Provider
packages/core/src/oauth/coinbase.ts, packages/core/src/oauth/index.ts
New Coinbase OAuth provider implementation with profile mapping (sub, name, image), authorization endpoint configuration, token endpoint setup, and registration in the built-in providers registry. Defines CoinbaseProfile interface for /v2/user response payload.
Documentation
docs/src/content/docs/oauth/coinbase.mdx
Comprehensive guide for configuring Coinbase OAuth including application setup (API key/secret, IP allowlist, callback URL), environment variable configuration with security callout, createAuth setup enabling oauth: ["coinbase"], sign-in initiation methods (browser navigation, client-side via createAuthClient, server-side via api.signIn), and session retrieval examples.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Possibly related PRs

Suggested labels

oauth

Poem

🐰 A new chain awaits, with Coinbase's embrace,
Credentials flow swift through this protocol space,
OAuth dance perfected, in tokens we trust,
Profile mapped cleanly—identity's just!

🚥 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 'feat(oauth): add Coinbase OAuth provider' directly and clearly describes the main change: adding Coinbase as a new OAuth provider.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
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.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/add-coinbase-aouth

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 and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 8

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@docs/src/content/docs/oauth/coinbase.mdx`:
- Line 203: The inline comment mistakenly references GitHub; update the comment
attached to session?.user to correctly describe the Coinbase authenticated user
profile (or use a neutral phrase like "The authenticated user profile") so the
comment no longer mentions GitHub; locate the console.log(session?.user) line
and replace the comment text accordingly.
- Around line 180-191: The server-side example in serverSignIn incorrectly calls
api.signIn("github", ...) on the Coinbase docs page; update the provider id in
the serverSignIn function to the correct provider string ("coinbase") by
changing the api.signIn call in serverSignIn to api.signIn("coinbase", {
redirectTo: "http://localhost:3000/dashboard" }) so the example matches the
Coinbase guide.
- Around line 116-131: The example OAuth scopes in the auth.ts snippet are
GitHub scopes (read:user, user:email) and must be replaced with valid Coinbase
scopes; update the coinbase provider configuration in the auth constant
(createAuth call) to set authorize.params.scope to appropriate Coinbase scopes
(e.g., wallet:accounts:read or other wallet:* scopes as required) so the
coinbase(...) invocation uses provider-compatible scopes for authorization.
- Line 65: The sentence mistakenly mentions "GitHub credentials" instead of
"Coinbase credentials"; update the documentation sentence so it refers to
configuring the environment variables required by Aura Auth including the
Coinbase credentials and the encryption secrets (i.e., change the phrase "GitHub
credentials" to "Coinbase credentials" in the existing line).
- Line 3: Update the frontmatter "description" value in the coinbase.mdx file to
correct the grammar; replace "Add Coinbase authorization provider to Aura Auth
to authentication and authorize" with a grammatically correct phrase such as
"Add Coinbase authorization provider to Aura Auth to authenticate and authorize
users" so the description uses the verbs "authenticate" and "authorize"
(reference the frontmatter "description" field in coinbase.mdx).

In `@packages/core/src/oauth/coinbase.ts`:
- Around line 38-46: Remove the debug console.log in the profile handler for the
Coinbase OAuth provider and stop coercing the id with String(...); update the
profile method (the profile: (profile) => { ... } function in
packages/core/src/oauth/coinbase.ts) to return a DefaultUser using
profile.data.id directly (it is already a string) and omit any console output so
PII (name, avatar_url, etc.) is not logged.
- Line 32: The Coinbase OAuth config's scope string uses a '+' separator which
becomes percent-encoded and yields a single malformed scope token; update the
scope value in the Coinbase provider config (the scope property in
packages/core/src/oauth/coinbase.ts) to use a space-delimited string
("wallet:user:read wallet:user:email") so setSearchParams (authorization-url.ts:
setSearchParams usage) sends two separate scope tokens per RFC 6749 §3.3.
- Around line 26-48: The provider factory currently returns a default provider
object and then shallow-spreads ...options which will completely overwrite
nested objects like authorize, accessToken, and userInfo if the caller supplies
partial overrides; update the factory to deep-merge those nested fields instead
of shallow-spreading so callers can pass partial authorize.params without losing
url/responseType. Specifically, in the Coinbase provider (and apply across all
providers) merge defaults.authorize with options.authorize (and their params
sub-objects), and likewise merge defaults.accessToken and defaults.userInfo with
options.accessToken/options.userInfo before returning the provider object so
that symbols authorize, authorize.params, accessToken, and userInfo are
preserved and extended rather than replaced.
🪄 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: 9cc75d51-a2d9-4daf-ab55-985416f155ba

📥 Commits

Reviewing files that changed from the base of the PR and between ad52cb8 and ead0aed.

📒 Files selected for processing (3)
  • docs/src/content/docs/oauth/coinbase.mdx
  • packages/core/src/oauth/coinbase.ts
  • packages/core/src/oauth/index.ts

@@ -0,0 +1,224 @@
---
title: Coinbase Authorization Provider
description: Add Coinbase authorization provider to Aura Auth to authentication and authorize
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Grammar fix in frontmatter description.

🔧 Proposed fix
-description: Add Coinbase authorization provider to Aura Auth to authentication and authorize
+description: Add the Coinbase authorization provider to Aura Auth to authenticate and authorize users
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
description: Add Coinbase authorization provider to Aura Auth to authentication and authorize
description: Add the Coinbase authorization provider to Aura Auth to authenticate and authorize users
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@docs/src/content/docs/oauth/coinbase.mdx` at line 3, Update the frontmatter
"description" value in the coinbase.mdx file to correct the grammar; replace
"Add Coinbase authorization provider to Aura Auth to authentication and
authorize" with a grammatically correct phrase such as "Add Coinbase
authorization provider to Aura Auth to authenticate and authorize users" so the
description uses the verbs "authenticate" and "authorize" (reference the
frontmatter "description" field in coinbase.mdx).

Comment thread docs/src/content/docs/oauth/coinbase.mdx Outdated
Comment thread docs/src/content/docs/oauth/coinbase.mdx
Comment thread docs/src/content/docs/oauth/coinbase.mdx
Comment thread docs/src/content/docs/oauth/coinbase.mdx Outdated
Comment on lines +26 to +48
return {
id: "coinbase",
name: "Coinbase",
authorize: {
url: "https://login.coinbase.com/oauth2/auth",
params: {
scope: "wallet:user:read+wallet:user:email",
responseType: "code",
},
},
accessToken: "https://login.coinbase.com/oauth2/token",
userInfo: "https://api.coinbase.com/v2/user",
profile: (profile) => {
console.log("Coinbase profile", profile)
return {
sub: String(profile.data.id),
name: profile.data.name,
image: profile.data.avatar_url,
email: null,
} as DefaultUser
},
...options,
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🔴 Critical

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# How do existing providers handle partial option merging?
fd -e ts . packages/core/src/oauth --exec rg -nH -C2 '\.\.\.options' {}

Repository: aura-stack-ts/auth

Length of output: 4630


🏁 Script executed:

cat packages/core/src/oauth/coinbase.ts

Repository: aura-stack-ts/auth

Length of output: 1642


🏁 Script executed:

head -150 docs/src/content/docs/oauth/coinbase.mdx | tail -30

Repository: aura-stack-ts/auth

Length of output: 641


🏁 Script executed:

rg -nH 'OAuthProviderCredentials' packages/core/src/@types --max-count=5

Repository: aura-stack-ts/auth

Length of output: 714


🏁 Script executed:

cat packages/core/src/@types/index.ts | head -100

Repository: aura-stack-ts/auth

Length of output: 1932


🏁 Script executed:

cat packages/core/src/@types/oauth.ts

Repository: aura-stack-ts/auth

Length of output: 2800


🏁 Script executed:

fd -e test -e spec . packages/core --type f | head -20

Repository: aura-stack-ts/auth

Length of output: 44


🏁 Script executed:

rg -l "coinbase" --type ts packages/ | grep -i test

Repository: aura-stack-ts/auth

Length of output: 44


🏁 Script executed:

cat packages/core/src/oauth/discord.ts

Repository: aura-stack-ts/auth

Length of output: 3591


🏁 Script executed:

cat packages/core/src/oauth/github.ts

Repository: aura-stack-ts/auth

Length of output: 2860


This is a systemic issue affecting all OAuth providers, not just Coinbase.

The shallow spread pattern with ...options is used by all 16+ providers (GitHub, Discord, Spotify, etc.). When users follow the documented pattern and pass a partial authorize object (e.g., { authorize: { params: { scope: "..." } } }), it replaces the entire authorize object, silently losing the url and responseType. This breaks the OAuth flow.

The fix should apply uniformly across all providers—either deep-merge authorize/accessToken/userInfo fields, or update documentation to clarify that overrides must be complete objects. The current approach creates a footgun where the documented usage pattern in docs/src/content/docs/oauth/coinbase.mdx (lines 122-129) would silently fail.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/core/src/oauth/coinbase.ts` around lines 26 - 48, The provider
factory currently returns a default provider object and then shallow-spreads
...options which will completely overwrite nested objects like authorize,
accessToken, and userInfo if the caller supplies partial overrides; update the
factory to deep-merge those nested fields instead of shallow-spreading so
callers can pass partial authorize.params without losing url/responseType.
Specifically, in the Coinbase provider (and apply across all providers) merge
defaults.authorize with options.authorize (and their params sub-objects), and
likewise merge defaults.accessToken and defaults.userInfo with
options.accessToken/options.userInfo before returning the provider object so
that symbols authorize, authorize.params, accessToken, and userInfo are
preserved and extended rather than replaced.

Comment thread packages/core/src/oauth/coinbase.ts
Comment thread packages/core/src/oauth/coinbase.ts
@halvaradop halvaradop added the oauth Changes related to OAuth flows, providers, tokens, or authentication integration. label Apr 23, 2026
@halvaradop halvaradop marked this pull request as draft April 23, 2026 19:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

oauth Changes related to OAuth flows, providers, tokens, or authentication integration.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant