Conversation
M1 milestone: signature-based authentication for RPC methods. Architecture: - internal/jsonrpc/auth.go: Authenticator interface (ctx, method, params) -> (decodedParams, account, err). The jsonrpc package stays agnostic of steemgosdk — the implementation lives in internal/server. - internal/jsonrpc/server.go: RegisterAuthenticated + SetAuthenticator; methods now carry an auth flag. - internal/jsonrpc/dispatch.go: auth branch — if an authenticated method lacks a __signed wrapper, return InvalidParams (-32602) matching koa-jsonrpc's resolveParams behavior (verified via koa-jsonrpc test/auth.ts:97-104). If present, call the Authenticator; on failure return the *Error (typically 401). On success, replace req.Params with the decoded plaintext and inject ctx.Account. - internal/server/auth.go: conveyorAuthenticator delegates to steemgosdk API.VerifySignedRequest (which calls steemutil rpc.Validate + VerifySignedRpc + get_accounts fetcher). Uses an intermediate struct to extract __signed (bypassing rpc.SignedRequest's int-typed ID field). - internal/config/config.go: add rpc_node + admin_role with env bindings. - internal/server/app.go: construct Authenticator, register whoami. Key audit-driven decisions: - Missing __signed -> -32602 (not 401), matching koa-jsonrpc. - 401 errors carry no data field (matching koa-jsonrpc test assertions). - Directly call API.VerifySignedRequest rather than reassembling Validate + fetcher manually. Deps: steemutil v0.0.26, steemgosdk v0.0.24. Tests: 9 new auth tests (mock Authenticator) covering: __signed detection edge cases, missing __signed -> -32602, signed success with decoded params + account injection, authenticator error propagation, public method unaffected, notifications, auth-not-configured. All green.
- internal/server/auth.go: removed unnecessary steemgosdk top-level
package import and the 'var _ = steemgosdk.GetClient' hack. Only
github.com/steemit/steemgosdk/api is needed.
- internal/jsonrpc/dispatch.go: removed stale '_ = spanCtx' (spanCtx is
now used by Authenticate on line 81). Replaced the indirect
ErrInternalError(nil).withMessage(...) / ErrInvalidParams(nil).withMessage(...)
pattern with direct &Error{Code:..., Message:...} construction for clarity.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
M1 milestone — signature-based authentication for conveyor's RPC methods. Clients sign requests with their Steem posting key (
@steemit/rpc-auth__signedprotocol); the server verifies via secp256k1 public-key recovery against the account's posting authority.Architecture
internal/jsonrpc/auth.go:Authenticatorinterface —Authenticate(ctx, method, params) → (decodedParams, account, err). The jsonrpc package stays agnostic of steemgosdk; the implementation lives ininternal/server.internal/jsonrpc/server.go:RegisterAuthenticated+SetAuthenticator; methods now carry anauthflag.internal/jsonrpc/dispatch.go: auth branch — for authenticated methods, checks__signedpresence, calls the Authenticator, injectsctx.Account, and replacesreq.Paramswith decoded plaintext.internal/server/auth.go:conveyorAuthenticatordelegates to steemgosdkAPI.VerifySignedRequest(which internally calls steemutilrpc.Validate+VerifySignedRpc+get_accountsfetcher). Uses an intermediate struct to extract__signed(bypassingrpc.SignedRequest'sint-typed ID field).internal/config/config.go: addedrpc_node+admin_rolewith env bindings.internal/server/app.go: constructs the Authenticator fromrpc_nodeconfig, registerswhoami.Key audit-driven decisions (verified against koa-jsonrpc source + test suite)
__signed→-32602 InvalidParams(not 401). koa-jsonrpc'sresolveParamsrejects non-__signedparams for authenticated methods beforevalidateSignatureruns (confirmed:koa-jsonrpc/test/auth.ts:97-104).datafield — koa-jsonrpc'sVError{cause}info doesn't surface intoJSON()(confirmed: all 401 test assertions are{code, message}only).API.VerifySignedRequestrather than reassemblingValidate+ fetcher manually — DRY, the SDK already encapsulates the full flow.Dependencies
Verification
go build ./...✅go vet ./...✅go test ./...✅ — 9 new auth tests + all M0 tests pass:hasSignedWrapperedge cases (object/array/empty/null)__signed→-32602hello) unaffected__signed) → no responseWhat's NOT in M1