Skip to content

ethrpc: add WithHTTPAuth option for HTTP and WebSocket - #225

Merged
VojtechVitek merged 1 commit into
masterfrom
ethrpc-with-http-auth
Nov 3, 2026
Merged

VojtechVitek merged 1 commit into
masterfrom
ethrpc-with-http-auth

Conversation

@VojtechVitek

Copy link
Copy Markdown
Contributor

Adds ethrpc.WithHTTPAuth(rpc.HTTPAuth), mirroring go-ethereum's rpc.WithHTTPAuth. It reuses the HTTPAuth type from the vendored go-ethereum/rpc.

The hook runs:

  • on every HTTP JSON-RPC request in Do(). A hook error aborts the request with ErrRequestFail.
  • on every WebSocket dial in streamSubscribe(), through rpc.DialOptions.

Why: the WebSocket connection had no way to carry an Authorization header. With this, a caller like the relayer can mint a fresh S2S JWT per request and per connection to node-gateway. Then the access key can come out of the node URL path.

Tests: 4 new tests in ethrpc/http_auth_test.go:

  • the HTTP header is set
  • a hook error aborts the HTTP request
  • the WebSocket handshake carries the header
  • a hook error aborts the WebSocket dial

They pass with -race against the local testchain.

Independent of #224, which removes the dead jwtToken field. Whichever merges second needs a trivial rebase in Do().

🤖 This message was generated by Claude using Opus 5.5 on behalf of Vojtech.

Authenticates the WebSocket handshake too, so S2S tokens reach node-gateway on streaming connections.

Co-Authored-By: Claude Haiku 5.5 <noreply@anthropic.com>
@VojtechVitek
VojtechVitek requested a review from a team November 3, 2026 13:18
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 3, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-03T13:19:48.202125Z d87323e PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@VojtechVitek
VojtechVitek merged commit e3fc346 into master Nov 3, 2026
14 checks passed
@VojtechVitek
VojtechVitek deleted the ethrpc-with-http-auth branch November 3, 2026 16:02
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