Skip to content

feat(auth): OIDC Discovery and redirect_uri support for OAuth compliance#97

Open
getlarge wants to merge 2 commits intoplatformatic:mainfrom
getlarge:feat/oidc-compliance
Open

feat(auth): OIDC Discovery and redirect_uri support for OAuth compliance#97
getlarge wants to merge 2 commits intoplatformatic:mainfrom
getlarge:feat/oidc-compliance

Conversation

@getlarge
Copy link

Summary

This PR adds OIDC compatibility for OAuth providers like Ory Hydra that use non-standard endpoint paths.

Closes #95

Changes

1. OIDC Discovery

  • Fetch endpoints from /.well-known/openid-configuration with 5-minute caching
  • Graceful fallback to default /oauth/* paths for backwards compatibility

2. redirect_uri Support (OIDC 1.0 Required)

  • Include redirect_uri in authorization request
  • Pass redirect_uri to token exchange (must match authorization request)
  • Store callbackUrl in session for token exchange

3. Auth Prehandler Improvements

  • Skip /oauth/callback in auth prehandler (was missing)
  • Add excludedPaths option for custom routes to bypass authorization (e.g., health checks)

Files Changed

  • src/auth/oauth-client.ts - OIDC discovery, redirect_uri in token exchange
  • src/auth/prehandler.ts - Skip callback, excludedPaths support
  • src/routes/auth-routes.ts - Include redirect_uri, store in session
  • src/types/auth-types.ts - Add excludedPaths to config type
  • test/integration.test.ts - Fix type guards for discriminated unions (unrelated pre-existing issue)

Backwards Compatibility

  • OIDC discovery fails gracefully to default /oauth/* paths
  • All existing authorization configs continue working
  • excludedPaths is optional

Test Plan

  • TypeScript compiles (npm run typecheck)
  • Existing tests pass (npm run test)
  • Manual testing with Ory Hydra

🤖 Generated with Claude Code

getlarge and others added 2 commits January 25, 2026 16:22
…on tests

The MCP SDK types use discriminated unions (e.g., text | image content).
TypeScript requires type narrowing before accessing type-specific properties.

This fixes typecheck failures introduced by SDK type changes.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Add OIDC discovery to fetch endpoints from /.well-known/openid-configuration
  with 5-minute caching and fallback to default /oauth/* paths
- Include redirect_uri in authorization request (required for OIDC 1.0)
- Pass redirect_uri to token exchange (must match authorization request)
- Skip /oauth/callback in auth prehandler
- Add excludedPaths option for custom routes to bypass authorization
  (e.g., health checks)

This enables compatibility with OAuth providers like Ory Hydra that use
non-standard endpoint paths (e.g., /oauth2/auth instead of /oauth/authorize).

Closes platformatic#95

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
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.

feat(auth): OIDC Discovery and redirect_uri support for OAuth compliance

1 participant