Skip to content

net: request-token auth, deferred who, and always-on endorsement - #31

Draft
samlown wants to merge 3 commits into
netfrom
net-request-tokens
Draft

net: request-token auth, deferred who, and always-on endorsement#31
samlown wants to merge 3 commits into
netfrom
net-request-tokens

Conversation

@samlown

@samlown samlown commented Jul 25, 2026

Copy link
Copy Markdown
Contributor

Syncs the GOBL Net reference server and CLI to the revised protocol spec (invopop/gobl#909). Targets the net branch.

  • Request tokens: /who and /inbox reject requests without a valid Authorization: Bearer token (401); a requireAuth middleware verifies tokens and its structured log entries (token_missing/token_invalid/token_expired, requester address) double as the request audit log. CORS allows the Authorization header; key endpoints stay open.
  • /who: static self-signed envelope served with Cache-Control: private; missing party.json → receive-only 204; a who-deferred marker answers 202 and records requests for the new gobl net requests / gobl net approve commands. Approved parties are signed for the requester and delivered to their inbox, where the pending who request exempts them from endorsement.
  • Endorsement always on: inbox senders must be endorsed by a trusted authority (lookup.gobl.org by default; --authority supplements) with a confirmed verifier. --allow-unverified relaxes only the verifier requirement, for sandboxes and tests.
  • CLI: gobl net who/send take --from identities to mint tokens; NetWho/NetSend are rebuilt on net.Client. The --insecure flags and the manual single-identity serve mode (with its auth-disabled carve-out) are removed — domains come from config-dir discovery and requests are always authenticated.
  • Fixes a latent flake: generated keys floor valid_from to the second so signatures made in the same second verify.

Draft because go.mod pins replace github.com/invopop/gobl => ../gobl; swap for the next gobl release before merging.

🤖 Generated with Claude Code

Syncs the reference server and CLI to the revised GOBL Net spec:

- /who and /inbox require a bearer request token (spec §5.5),
  verified by a requireAuth middleware whose structured log doubles
  as the request audit log (token_missing / token_invalid /
  token_expired reasons); CORS allows the Authorization header.
- The static /who response is self-signed once at startup and served
  with Cache-Control: private; a missing party.json makes the domain
  receive-only (204). The who-deferred marker answers 202 and records
  requests for the new `gobl net requests` / `gobl net approve`
  commands; approval signs the party for the requester and delivers
  it to their inbox, where a pending who request exempts it from
  endorsement.
- Sender endorsement is always enforced on the inbox: senders must be
  endorsed by a trusted authority (lookup.gobl.org by default,
  --authority supplements) with a confirmed verifier;
  --allow-unverified relaxes only the verifier requirement for
  sandboxes and tests.
- gobl net who/send gain --from identities to mint tokens; NetWho is
  rebuilt on net.Client.Who and NetSend on net.Client.Send.
- Local development options removed: --insecure client flags and the
  manual single-identity serve mode (with its auth-disabled path).
  Domains come from config-dir discovery; requests are always
  authenticated; clients always dial https.
- Keys generated at startup floor valid_from to the second so
  signatures made within the same second verify.

Pinned to the local gobl via a replace directive until the next gobl
release; drop it before merging.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
samlown and others added 2 commits July 25, 2026 18:01
Follows the gobl core change dropping the URI scheme from signed
iss/aud/verifier claims: sign options and payload comparisons use
Address.String(), SignOptions.Issuer/Audience are plain strings, and
the inbox audience check canonicalizes both sides with
net.ParseAddress, mirroring gobl's VerifyEnvelope. The gobl: scheme
remains on org.Endpoint URIs and the unsigned header from/to.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Absorb gobl's review fixes: transient conditions (network failures,
429, 5xx) now surface as net.ErrUnavailable, distinct from invalid
tokens and failed endorsements.

- requireAuth answers 503 (reason token_unavailable) when the
  requester's key endpoint cannot be reached, instead of a
  definitive 401 clients would not retry.
- handleInbox answers 503 (reason verify_unavailable) when envelope
  or endorsement verification hits an unreachable key/who endpoint,
  instead of 401/403.
- WithAuthorities now replaces the client's trust list, so the
  server builds it as default-plus-extras to keep --authority's
  documented supplement semantics; covered by a test accepting an
  endorsement from the default authority while extras are set.
- Test fetchers implement the Fetcher interface's new Post method.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
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