Summary
GitHub OAuth tokens stored during authentication and GitHub-connect flows overwrite each other despite requiring different permission scopes.
As a result, users can silently lose GitHub follow permissions after re-authentication.
Affected Files
apps/backend/src/routes/auth.ts
apps/backend/src/routes/connect.ts
Root Cause
Both flows upsert into the same token record:
but store different OAuth scopes.
Login flow (auth.ts)
Stores:
Connect flow (connect.ts)
Stores:
Whichever flow runs last overwrites the previously stored token.
Realistic Failure Scenario
- User connects GitHub for follow functionality.
- Backend stores token with
user:follow.
- User later logs in again using GitHub OAuth.
- Login flow overwrites token with lower-privilege scope.
- Follow actions now fail because the token lacks
user:follow.
This failure is silent during login and only surfaces later during follow operations.
Impact
Users unexpectedly lose follow capability after re-authentication.
This creates:
- broken follow flows,
- confusing reconnect loops,
- inconsistent OAuth behavior,
- and invalid token capability assumptions.
The issue is especially difficult to debug because:
- authentication still succeeds,
- token storage succeeds,
- failures occur only later during GitHub API usage.
Proposed Fix
Separate authentication tokens from follow-capable tokens.
Possible approaches:
Option 1
Store separate platform keys:
github_auth
github_follow
Option 2
Merge scopes intelligently and retain the most permissive token.
Option 3
Store scope metadata explicitly and validate capability before overwriting.
Acceptance Criteria
- Login flow no longer removes follow capability.
- Follow-capable tokens remain persistent after re-authentication.
- Token scope ownership is explicit and deterministic.
- Existing OAuth login behavior remains unchanged.
Severity
Medium
This is a significant OAuth lifecycle/data-integrity flaw affecting persistent GitHub integrations.
Summary
GitHub OAuth tokens stored during authentication and GitHub-connect flows overwrite each other despite requiring different permission scopes.
As a result, users can silently lose GitHub follow permissions after re-authentication.
Affected Files
apps/backend/src/routes/auth.tsapps/backend/src/routes/connect.tsRoot Cause
Both flows upsert into the same token record:
but store different OAuth scopes.
Login flow (
auth.ts)Stores:
Connect flow (
connect.ts)Stores:
Whichever flow runs last overwrites the previously stored token.
Realistic Failure Scenario
user:follow.user:follow.This failure is silent during login and only surfaces later during follow operations.
Impact
Users unexpectedly lose follow capability after re-authentication.
This creates:
The issue is especially difficult to debug because:
Proposed Fix
Separate authentication tokens from follow-capable tokens.
Possible approaches:
Option 1
Store separate platform keys:
Option 2
Merge scopes intelligently and retain the most permissive token.
Option 3
Store scope metadata explicitly and validate capability before overwriting.
Acceptance Criteria
Severity
Medium
This is a significant OAuth lifecycle/data-integrity flaw affecting persistent GitHub integrations.