Skip to content

feat: authenticate with OAuth DCR and PKCE - #4

Open
ishaanxgupta wants to merge 2 commits into
mainfrom
ishaan/muse-plugin-oauth-dcr
Open

ishaanxgupta wants to merge 2 commits into
mainfrom
ishaan/muse-plugin-oauth-dcr

Conversation

@ishaanxgupta

Copy link
Copy Markdown

Browser sign-in currently opens console auth/connect and saves a long-lived sm_ API key. Login now uses the Supermemory OAuth 2.1 authorization server, the same flow as the Claude Code plugin this is based on.

  • Discover the authorization server, register a public client named "Supermemory for Muse Code" (callback 127.0.0.1:19881), and reuse the registration across logins.
  • Authorize with S256 PKCE, random state and issuer validation. Store access and refresh tokens atomically with owner-only permissions, bound to the API URL, issuer and MCP resource.
  • Hooks and the MCP proxy resolve the bearer per request. Refresh serializes across processes and always saves the rotated tokens, even when a hook stops waiting.
  • node hooks/lib/auth.js login|logout|status: login migrates a saved API key, logout revokes the refresh token, status shows auth type and client ID only. Denying consent shows an "Authorization Denied" page.
  • Env keys, a project apiKey or a saved {apiKey} keep precedence and keep working unchanged. The fallback to the Claude Code plugin's credentials now only accepts a legacy {apiKey}; Claude's OAuth tokens belong to a different client and are never read.

Verified live against the mono PR preview: consent shows "Supermemory for Muse Code" as a Plugin, API reads and writes succeed, refresh rotates tokens, and logout revokes the refresh token.

Requires https://github.com/supermemoryai/mono/pull/3087 for the consent screen to name the plugin and attribute requests to its OAuth client. Same design as supermemoryai/claude-supermemory#121 and supermemoryai/codex-supermemory#71.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant