Skip to content

M1: __signed authentication via steemgosdk VerifySignedRequest#45

Merged
ety001 merged 2 commits into
nextfrom
m1-auth
Jul 15, 2026
Merged

M1: __signed authentication via steemgosdk VerifySignedRequest#45
ety001 merged 2 commits into
nextfrom
m1-auth

Conversation

@ety001

@ety001 ety001 commented Jul 15, 2026

Copy link
Copy Markdown
Member

Summary

M1 milestone — signature-based authentication for conveyor's RPC methods. Clients sign requests with their Steem posting key (@steemit/rpc-auth __signed protocol); the server verifies via secp256k1 public-key recovery against the account's posting authority.

Architecture

  • internal/jsonrpc/auth.go: Authenticator interface — Authenticate(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 — for authenticated methods, checks __signed presence, calls the Authenticator, injects ctx.Account, and replaces req.Params with decoded plaintext.
  • internal/server/auth.go: conveyorAuthenticator delegates to steemgosdk API.VerifySignedRequest (which internally 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: added rpc_node + admin_role with env bindings.
  • internal/server/app.go: constructs the Authenticator from rpc_node config, registers whoami.

Key audit-driven decisions (verified against koa-jsonrpc source + test suite)

  1. Missing __signed-32602 InvalidParams (not 401). koa-jsonrpc's resolveParams rejects non-__signed params for authenticated methods before validateSignature runs (confirmed: koa-jsonrpc/test/auth.ts:97-104).
  2. 401 errors carry no data field — koa-jsonrpc's VError {cause} info doesn't surface in toJSON() (confirmed: all 401 test assertions are {code, message} only).
  3. Directly call API.VerifySignedRequest rather than reassembling Validate + 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:
    • hasSignedWrapper edge cases (object/array/empty/null)
    • Missing __signed-32602
    • Signed request success → decoded params + account injection
    • Authenticator error → propagated as 401
    • Public method (hello) unaffected
    • Notifications (with and without __signed) → no response
    • Auth-not-configured → InternalError

What's NOT in M1

  • Business subsystems (drafts, flags, tags, etc. — M2–M6)
  • Real chain-based signature round-trip test (requires network; M1 uses mock Authenticator)

ety001 added 2 commits July 15, 2026 12:06
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.
@ety001
ety001 merged commit 4121151 into next Jul 15, 2026
1 check failed
@ety001
ety001 deleted the m1-auth branch July 15, 2026 04:20
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