Skip to content

Add oauth package with RFC-compliant OAuth/OIDC utilities - #8

Closed
JAORMX wants to merge 1 commit into
mainfrom
add-oauth-package
Closed

Add oauth package with RFC-compliant OAuth/OIDC utilities#8
JAORMX wants to merge 1 commit into
mainfrom
add-oauth-package

Conversation

@JAORMX

@JAORMX JAORMX commented Feb 4, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Add oauth package providing shared types, constants, and validation utilities for OAuth 2.0 and OpenID Connect
  • Extracted from toolhive/pkg/oauth as part of THV-0032 (Tier 1 graduation)
  • No toolhive-internal dependencies - clean extraction

Components

File Description
constants.go Well-known paths (RFC 8414, 9728), grant types, response types, PKCE methods
errors.go Typed validation errors for discovery documents
discovery.go OAuth AS Metadata (RFC 8414) and OIDC Discovery types with validation
redirect.go Redirect URI validation per RFC 6749/8252 with configurable policies

Key Features

  • Discovery Documents: Types for OAuth 2.0 Authorization Server Metadata and OpenID Connect Discovery with validation methods
  • Redirect URI Validation: RFC-compliant validation with two policies:
    • RedirectURIPolicyStrict - HTTPS and HTTP loopback only (RFC 8252 Section 8.4)
    • RedirectURIPolicyAllowPrivateSchemes - Also allows custom schemes like cursor://, vscode:// (RFC 8252 Section 7.1)

Dependencies

  • github.com/ory/fosite - Well-established OAuth library used for redirect URI security checks

Test Plan

  • All unit tests pass (task test)
  • Linting passes (task lint)
  • License headers validated (task license-check)
  • Test coverage: 93.9%

🤖 Generated with Claude Code

Add the oauth package which provides shared types, constants, and
validation utilities for OAuth 2.0 and OpenID Connect. This package
serves as a foundation for both OAuth clients and servers.

Components:
- constants.go: Well-known paths (RFC 8414, 9728), grant types, PKCE
- errors.go: Validation errors for discovery documents
- discovery.go: Types for OAuth AS Metadata and OIDC Discovery (RFC 8414)
- redirect.go: Redirect URI validation per RFC 6749/8252 with policies

The package uses github.com/ory/fosite for redirect URI validation,
which is a well-established OAuth library. All code is extracted from
toolhive/pkg/oauth with no modifications needed - the package had no
toolhive-internal dependencies.

Test coverage: 93.9%

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Comment thread oauth/discovery.go
@JAORMX JAORMX closed this Feb 4, 2026
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.

2 participants