Skip to content

Upgrade Better Auth to 1.7 and migrate MCP OAuth provider - #568

Merged
cameronapak merged 5 commits into
mainfrom
devin/1795092167-better-auth-1-7
Nov 19, 2026
Merged

cameronapak merged 5 commits into
mainfrom
devin/1795092167-better-auth-1-7

Conversation

@cameronapak

@cameronapak cameronapak commented Nov 19, 2026 •

Copy link
Copy Markdown
Owner

Summary

Clears the last OSV findings left after #567 (Better Auth 1.6: GHSA-965c-763c-88jm critical, GHSA-q84f-53jg-9ppm and GHSA-r4xp-prcw-77qf high, GHSA-44jh-23m7-hpcf low). OSV now reports zero findings across root, cli/ and landing/.

Better Auth 1.7 removed the mcp plugin and oAuthDiscoveryMetadata, so MCP OAuth moves to @better-auth/mcp + @better-auth/oauth-provider (all 1.7.26).

  • Agents reconnect once (approved by Cameron). migrations/0023_better_auth_1_7.sql follows the vendor path: drops oauthAccessToken/oauthConsent/oauthApplication and legacy consent codes in verification, then creates the 1.7 tables (oauthClient, oauthResource, oauthClientResource, oauthRefreshToken, ...) plus revocation generations. Users and sessions are untouched.
  • Public MCP endpoint, its alias and both /.well-known discovery URLs are unchanged. Account-bound consent, PKCE, resource validation and hashed tokens are kept, and resolveUserId keying and signup gates are unchanged.
  • Refresh rotation/replay, revocation and account-deletion cleanup are covered by new tests. The upstream refresh-family race is mitigated with D1 generation checks and triggers and documented in ADR 0026 (not an exhaustive proof across multi-worker interleavings).
  • Local dev: 1.7's MCP provider rejects the non-loopback HTTP URL that wrangler's custom-domain simulation produces (http://app.dotflowy.com), so scripts/cf-dev.ts and dev:api now pass --local-upstream localhost:8787 --upstream-protocol http. Production HTTPS checks are unchanged.
  • scripts/mint-mcp-token.ts updated for the new consent flow. One root changeset; no CLI manifest change.

Deploy note: run bun run db:migrate:remote with the deploy. Connected agents get a 401 and must sign in again.

Testing

lint, fmt:check, typecheck (all), bun run test (1141 pass, 0 fail), build:cf, db:migrate:local on fresh and existing DBs. Manual round trip: register 201 → consent → token → MCP initialize 200 → refresh 200 (old access 401) → revoke → access/refresh 401.

Browser smoke on 5114c09, default bun run cf:dev: auth and discovery return 200; consent page → code with matching state → PKCE exchange → MCP initialize 200; outline edit, indent and outdent persist across reload and sign-out/sign-in.

Browser consent Loopback callback and MCP result
MCP consent PKCE exchange and MCP initialize 200

Prune & Cultivate opened this PR for Cameron
Implemented in session Fix security vulnerabilities in dotflowy
Review with Devin · Open in Devin Desktop



Note

Devin could not open this Pull Request as cameronapak: they have no GitHub connection usable for this repository.
As a fallback, Devin opened this PR as itself.

devin-ai-integration Bot and others added 2 commits November 19, 2026 12:58
Co-Authored-By: Cameron Pak <cameronandrewpak@gmail.com>
Co-Authored-By: Cameron Pak <cameronandrewpak@gmail.com>
@pullfrog

pullfrog Bot commented Nov 19, 2026

Copy link
Copy Markdown
Contributor

Pullfrog  | Review this ➔

@devin-ai-integration

Copy link
Copy Markdown
Contributor

I'll fix CI failures and address comments from users with write access. I'll skip comments containing "(aside)".

  • Disable automatic comment, CI, and merge conflict monitoring

devin-ai-integration Bot and others added 3 commits November 19, 2026 13:30
Co-Authored-By: Cameron Pak <cameronandrewpak@gmail.com>
Co-Authored-By: Cameron Pak <cameronandrewpak@gmail.com>
Co-Authored-By: Cameron Pak <cameronandrewpak@gmail.com>
@cameronapak
cameronapak merged commit 7ac10e5 into main Nov 19, 2026
20 checks passed
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