Skip to content

Conversation

@chriswessels
Copy link
Member

@chriswessels chriswessels commented May 30, 2025

Add configurable gateway support via header-based gateway IDs

Summary

Enables users to specify alternative Graph Protocol gateways using a secure gateway ID system instead of hardcoded URLs. This provides flexibility for users who need to use different gateway endpoints while maintaining security.

Core Implementation

  • Gateway Registry: Added GATEWAY_REGISTRY HashMap mapping gateway IDs to whitelisted URLs:
  • Header-based Selection: Users can specify gateway via x-gateway-id header
  • Secure Validation: Only whitelisted gateway IDs are accepted, preventing SSRF attacks

Enhanced Error Handling

  • Descriptive Errors: Invalid gateway IDs return helpful messages listing valid options
  • New Error Type: Added InvalidGatewayId variant to SubgraphError enum

API Updates

  • Method Signatures: Updated all internal methods to accept gateway_url parameter
  • Error Propagation: All endpoints now handle gateway validation errors with clear messaging

Security Considerations

✅ SSRF Prevention: Only whitelisted gateways can be used
✅ API Key Protection: Keys are never sent to untrusted endpoints
✅ Input Validation: All gateway IDs are validated against registry

Usage

  # Default gateway (Edge & Node)
  curl -H "Authorization: Bearer YOUR_API_KEY" ...

  # GraphOps gateway
  curl -H "x-gateway-id: graphops" -H "Authorization: Bearer YOUR_API_KEY" ...

  # Invalid gateway returns helpful error
  curl -H "x-gateway-id: invalid" -H "Authorization: Bearer YOUR_API_KEY" ...
  # Error: Invalid gateway ID 'invalid'. Valid gateway IDs are: edgeandnode, graphops

@sahra-karakoc sahra-karakoc self-requested a review June 10, 2025 14:06
Copy link
Contributor

@sahra-karakoc sahra-karakoc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ty sir

@sahra-karakoc sahra-karakoc merged commit 5e750ce into main Jun 10, 2025
3 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.

3 participants