swapruntime: authenticate swap mailbox clients - #474
Conversation
There was a problem hiding this comment.
Code Review
This pull request introduces a mechanism for authenticating mailbox RPCs using the daemon's identity key. It adds a SignMailboxAuth method to the RPC server and implements a signingMailboxClient wrapper that automatically attaches Schnorr signatures to outgoing mailbox requests (Send, Pull, and AckUpTo). The newSwapServerClients function was updated to integrate this signing logic, and corresponding tests were added to verify the inclusion of the authentication header. I have no feedback to provide.
There was a problem hiding this comment.
Pull request overview
This PR adds daemon-backed mailbox authentication signing so the swap client subserver can authenticate swapserver mailbox gateway RPCs (Send/Pull/AckUpTo) using the daemon identity key, and extends tests to verify REST header propagation.
Changes:
- Expose
RPCServer.SignMailboxAuthto allow optional subservers to request a mailbox auth signature without direct wallet/key access. - Wrap swapserver mailbox clients with a signing decorator that injects
x-mailbox-auth-sigper mailbox ID for gRPC and REST transports. - Extend
swapclientserverREST transport tests to validate mailbox auth header propagation (currently for Pull).
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| swapclientserver/service.go | Introduces a signing mailbox client wrapper and wires it into swapserver client construction. |
| swapclientserver/service_test.go | Updates REST client test harness to assert mailbox auth header propagation and adapts to new constructor signature. |
| darepod/rpc_server.go | Adds a public RPCServer helper for producing hex-encoded mailbox auth signatures. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| return metadata.AppendToOutgoingContext( | ||
| ctx, serverconn.AuthHeaderKey, sig, | ||
| ), nil |
| case "/v1/mailbox/pull": | ||
| require.Equal( | ||
| t, "auth-mailbox", | ||
| r.Header.Get(serverconn.AuthHeaderKey), | ||
| ) | ||
|
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: beed06a11d
ℹ️ 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".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| swapClients, err := newSwapServerClients( | ||
| cfg, swapAddr, rpcServer.SignMailboxAuth, | ||
| ) |
There was a problem hiding this comment.
Delay mailbox signer wiring until identity key is derived
Wiring rpcServer.SignMailboxAuth at subserver registration time introduces a startup race: Register() calls resumePending immediately, so pending receive-swap workers can issue mailbox Pull/AckUpTo before darepod reaches startWalletReadyServices (connectAndBootstrapMailbox) where s.clientKeyDesc is derived. In that window, signMailboxAuth reads s.clientKeyDesc.PubKey and can panic when building the auth message (or fail the worker), causing restart-time receive swaps to stop unexpectedly in swapruntime builds with pending sessions.
Useful? React with 👍 / 👎.
e783f34 to
efab26d
Compare
efab26d to
2303cc4
Compare
2303cc4 to
38abc79
Compare
2ec924c to
c019e0b
Compare
c019e0b to
489cfe1
Compare
|
@claude please review |
|
Claude finished @sputn1ck's task in 5m 37s —— View job Code Review
The overall shape of the PR is clean — exporting the auth wrapper from High Priority1. Startup race:
|
d929dfd to
bde3056
Compare
| ), | ||
| }, nil | ||
|
|
||
| default: |
There was a problem hiding this comment.
codex: This drops the old loopback/plaintext default, but DefaultConfig still points swapruntime at localhost:10030 with ServerInsecure left false. As a result a stock swapruntime daemon now builds TLS credentials here and the first call to the local dev swap server fails the handshake (first record does not look like a TLS handshake); REST has the same issue because swapServerRESTBaseURL now returns https://localhost:10030 unless the user explicitly sets swap.serverinsecure=true. Either the local default needs to set ServerInsecure: true, or the loopback dev fallback needs to stay in this transport selection so the documented local/regtest default remains usable.
There was a problem hiding this comment.
Addressed in f2c20b4: restored the loopback/unix plaintext fallback when no TLS cert path is configured, kept explicit TLS cert paths authoritative, and added tests for local default, remote TLS default, and TLS-cert override behavior.
Add the client-only mailbox auth wrapper used by swap gRPC and REST mailbox transports. Expose daemon signing and client TLS certificates to the swap runtime so swapd can require mailbox metadata auth without duplicating server policy in the client repo.
bde3056 to
f2c20b4
Compare
…uto-board client: Bump submodule to 9eb2782 + migration 15 hotfix
Summary
Used by:
Validation
go test ./serverconn ./darepod -count=1go test -tags swapruntime ./swapclientserver -count=1go test ./swaprpc -count=1Note:
make lint-localstill reports existing line-length issues incmd/darepocli/internal/gen-devrpc/main.goon this base.