Skip to content

Add dynamic redirect URI validation for OAuth proxy#131

Merged
aschlean merged 2 commits intomainfrom
claude/dynamic-redirect-uris-nRi48
Jan 30, 2026
Merged

Add dynamic redirect URI validation for OAuth proxy#131
aschlean merged 2 commits intomainfrom
claude/dynamic-redirect-uris-nRi48

Conversation

@aschlean
Copy link
Contributor

Description

This PR adds support for dynamic redirect URI validation in OAuth proxy configuration, enabling runtime evaluation of allowed redirect patterns and schemes. This allows integration with feature flags, databases, and other dynamic configuration sources.

Previously, redirect URI validation was limited to static lists defined at startup. The new feature introduces three new configuration options:

  • allowed_redirect_patterns_func: A callable that returns redirect URI patterns dynamically
  • allowed_redirect_schemes_func: A callable that returns allowed URI schemes dynamically
  • redirect_uri_validator: A custom validator function for complex validation logic

These work alongside existing static configuration options, providing flexibility for different use cases.

Changes

Core Changes

  • providers.py: Added type aliases (RedirectPatternsProvider, RedirectSchemesProvider, RedirectUriValidator) and new fields to OAuthProxyConfig for dynamic redirect URI validation
  • init.py: Exported new type aliases for public API
  • factory.py: Updated _create_oauth_proxy_provider to resolve static patterns from environment variables and pass through callable functions to the enterprise package
  • init.py (configure_oauth_proxy): Added new parameters and comprehensive documentation with examples

Testing

  • test_providers.py: Added comprehensive test suite (TestOAuthProxyDynamicRedirectUris) covering:
    • Static redirect patterns and schemes configuration
    • Callable patterns and schemes functions
    • Custom redirect URI validators
    • Mixed static and dynamic configuration
    • Environment variable resolution
    • Feature flag integration patterns
    • Database lookup simulation

Type of change

  • New feature (non-breaking change which adds functionality)
  • Documentation update

Backward Compatibility

This change is fully backward compatible. Existing code using static allowed_redirect_patterns and allowed_redirect_schemes continues to work unchanged. The new callable-based parameters are optional and only used when explicitly provided.

Use Cases

  1. Feature Flags: Dynamically enable/disable redirect URIs based on feature flag state
  2. Database-Driven Configuration: Fetch allowed URIs from a database at runtime
  3. Complex Validation: Implement custom validation logic beyond pattern matching
  4. Multi-Tenant Systems: Return different allowed URIs based on tenant context

https://claude.ai/code/session_01YLH7X7ZigGktYJQtthjQjq

Add callable function support for allowed_redirect_uris config in the OAuth
proxy, enabling dynamic configuration via feature flags or other runtime
sources without redeployment.

New features:
- allowed_redirect_patterns_func: Callable returning list of patterns
- allowed_redirect_schemes_func: Callable returning list of schemes
- redirect_uri_validator: Custom validator function for full URI validation

These callables are evaluated per-request, allowing integration with
Amplitude, LaunchDarkly, or database lookups for real-time redirect URI
management.

https://claude.ai/code/session_01YLH7X7ZigGktYJQtthjQjq
@ryvn-technologies
Copy link

Ryvn Preview

Creating preview prerelease-golf-mcp-golf for this pull request.


This comment will be automatically updated with preview details.

@aschlean aschlean merged commit 6b7a81d into main Jan 30, 2026
5 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.

2 participants