Skip to content

[backport] OAuth 2.1 core library — PKCE + device flows (upstream main) #10

Description

@gastrodon

Summary

Introduces internal/oauth, a self-contained OAuth 2.1 login library for the stdio server. Provides:

  • Authorization-code + PKCE flow with a local loopback callback server (state/CSRF, XSS-safe result pages)
  • Device-authorization flow as headless/container fallback
  • A Manager that selects the most secure available channel (browser → URL elicitation → last-resort message) and exposes a refreshing TokenSource
  • Both GitHub OAuth Apps and GitHub Apps are supported; expiring GitHub App tokens are refreshed automatically via x/oauth2
  • Prompter interface decouples MCP client interaction from the OAuth flow so tests are runnable without a live session
  • internal/oauth/env.go for detecting headless environments; internal/oauth/callback.go for loopback receiver

Upstream reference

Fork conflict

None. internal/oauth is a new package with no overlap with the fork's project-management additions.

Context

The stdio server previously required a pre-provisioned PAT. This library is the foundation for zero-config OAuth login — users on github.com can authenticate on first tool call without generating a token, removing a significant friction point for new adopters.

Metadata

Metadata

Assignees

No one assigned

    Labels

    backportBackport from upstreamfeatureNew featureno-opFork already has equivalent functionality

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions