Skip to content

fix(jsonrpc): enable HTTP basic auth in WS client (backport #2434)#2451

Merged
melekes merged 2 commits intov0.38.xfrom
mergify/bp/v0.38.x/pr-2434
Feb 27, 2024
Merged

fix(jsonrpc): enable HTTP basic auth in WS client (backport #2434)#2451
melekes merged 2 commits intov0.38.xfrom
mergify/bp/v0.38.x/pr-2434

Conversation

@mergify
Copy link
Contributor

@mergify mergify bot commented Feb 27, 2024

This is an automatic backport of pull request #2434 done by Mergify.
Cherry-pick of 8bf81d4 has failed:

On branch mergify/bp/v0.38.x/pr-2434
Your branch is up to date with 'origin/v0.38.x'.

You are currently cherry-picking commit 8bf81d423.
  (fix conflicts and run "git cherry-pick --continue")
  (use "git cherry-pick --skip" to skip this patch)
  (use "git cherry-pick --abort" to cancel the cherry-pick operation)

Changes to be committed:
	new file:   .changelog/unreleased/improvements/2434-jsonrpc-websocket-basic-auth.md

Unmerged paths:
  (use "git add <file>..." to mark resolution)
	both modified:   rpc/jsonrpc/client/ws_client.go

To fix up this pull request, you can check it out locally. See documentation: https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/reviewing-changes-in-pull-requests/checking-out-pull-requests-locally


Mergify commands and options

More conditions and actions can be found in the documentation.

You can also trigger Mergify actions by commenting on this pull request:

  • @Mergifyio refresh will re-evaluate the rules
  • @Mergifyio rebase will rebase this PR on its base branch
  • @Mergifyio update will merge the base branch into this PR
  • @Mergifyio backport <destination> will backport this PR on <destination> branch

Additionally, on Mergify dashboard you can:

  • look at your merge queues
  • generate the Mergify configuration with the config editor.

Finally, you can contact us on https://mergify.com

Hello,

I noticed that the JSON-RPC client is compatible with URLs containing
**HTTP basic auth**, but not on the WebSocket side.

For instance:

```golang
client, err := http.New("https://foo:bar@example.org:443", "/websocket")

client.Block(ctx, nil) // works

client.Start() // websocket error: the client doesn't forward auth headers
```

The HTTP client handle the username/password from the given endpoint
correctly:
-
https://github.com/cometbft/cometbft/blob/v0.38.5/rpc/jsonrpc/client/http_json_client.go#L140-L141
-
https://github.com/cometbft/cometbft/blob/v0.38.5/rpc/jsonrpc/client/http_json_client.go#L184-L185

So this PR brings the same logic for the WS client.

---

#### PR checklist

- [ ] Tests written/updated
- [x] Changelog entry added in `.changelog` (we use
[unclog](https://github.com/informalsystems/unclog) to manage our
changelog)
- [ ] Updated relevant documentation (`docs/` or `spec/`) and code
comments
- [x] Title follows the [Conventional
Commits](https://www.conventionalcommits.org/en/v1.0.0/) spec

(cherry picked from commit 8bf81d4)

# Conflicts:
#	rpc/jsonrpc/client/ws_client.go
@mergify mergify bot requested a review from a team as a code owner February 27, 2024 09:32
@mergify mergify bot added the conflicts label Feb 27, 2024
@melekes melekes merged commit 851fd2b into v0.38.x Feb 27, 2024
@melekes melekes deleted the mergify/bp/v0.38.x/pr-2434 branch February 27, 2024 10: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.

3 participants