Skip to content

replace TRUST_PROXY_HEADERS with ADMIN_API_KEY for admin auth#32

Draft
aspiers wants to merge 2 commits intomainfrom
admin-secret
Draft

replace TRUST_PROXY_HEADERS with ADMIN_API_KEY for admin auth#32
aspiers wants to merge 2 commits intomainfrom
admin-secret

Conversation

@aspiers
Copy link
Contributor

@aspiers aspiers commented Feb 12, 2026

DO NOT MERGE UNTIL #31 is merged! This is stacked on top, so will need a rebase for clean history.

Remove the insecure TRUST_PROXY_HEADERS mechanism which allowed anyone to
spoof admin identity via the X-User-DID header. Replace with ADMIN_API_KEY:
a shared secret that must be sent as a Bearer token alongside X-User-DID.

  • Add ADMIN_API_KEY env var to config
  • Gate X-User-DID trust on constant-time API key validation
  • Add auth bar (API key + DID inputs) to admin GraphiQL page
  • Credentials persisted in localStorage for convenience
  • Update CORS to allow X-User-DID header when API key is configured

aspiers and others added 2 commits February 12, 2026 23:35
Without this patch, GraphiQL endpoints were configured with absolute
URLs constructed from ExternalBaseURL. This caused GraphiQL to fail
when the service was accessed through a different domain (e.g., via
proxy, load balancer, or alternate hostname) because it would always
try to connect to the configured base URL rather than the domain the
user was actually using.

This is a problem because it prevents GraphiQL from working in
multi-domain deployments and makes local development harder when
accessing the service through different hostnames.

This patch solves the problem by changing GraphiQLConfig to accept
relative paths (EndpointPath and SubscriptionPath) instead of absolute
URLs. The GraphiQL HTML template now uses JavaScript to dynamically
construct the full URLs from window.location at runtime, ensuring the
page always connects to the correct domain. The WebSocket protocol is
also derived dynamically (ws: for http:, wss: for https:).

Changes:
- Replace Endpoint/SubscriptionEndpoint with EndpointPath/SubscriptionPath
- Use window.location.origin to build full GraphQL URL at runtime
- Derive WebSocket protocol from page protocol dynamically
- Update tests to verify path-based configuration

Co-authored-by: Claude Code <claude-code@noreply.anthropic.com>
Remove the insecure TRUST_PROXY_HEADERS mechanism which allowed anyone to
spoof admin identity via the X-User-DID header. Replace with ADMIN_API_KEY:
a shared secret that must be sent as a Bearer token alongside X-User-DID.

- Add ADMIN_API_KEY env var to config
- Gate X-User-DID trust on constant-time API key validation
- Add auth bar (API key + DID inputs) to admin GraphiQL page
- Credentials persisted in localStorage for convenience
- Update CORS to allow X-User-DID header when API key is configured
@vercel
Copy link

vercel bot commented Feb 12, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
hyperindex Ready Ready Preview, Comment Feb 12, 2026 0:25am

Request Review

@railway-app
Copy link

railway-app bot commented Feb 12, 2026

🚅 Environment hyperindex-pr-32 in hypercerts has no services deployed.

4 services not affected by this PR
  • PDS entryway
  • sds-eu-west4
  • pds-eu-west4
  • pds1

@aspiers aspiers marked this pull request as draft February 12, 2026 12:26
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.

1 participant