Skip to content

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

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

net: request-token auth, deferred who, and always-on endorsement#31
samlown wants to merge 6 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 3 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>
Adopts gobl/net's search semantics: the inbox delegates the audience
binding to VerifyEnvelope (any valid sender signature bound to this
inbox, replacing the positional first-signature check), and the /who
publication detection searches for an audience-free self-signature
anywhere aboard — an endorsed envelope saved as the party file is now
served correctly instead of gaining a redundant signature each start.
Drops the local replace directive for a pinned gobl pseudo-version so
the branch builds anywhere, and blank-imports the dk-oioubl and
fi-finvoice addon modules that v0.504 approves.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@codecov-commenter

codecov-commenter commented Aug 11, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 76.96793% with 79 lines in your changes missing coverage. Please review.
✅ Project coverage is 77.02%. Comparing base (812fc38) to head (f1354b2).

Files with missing lines Patch % Lines
internal/ops/net_serve.go 81.08% 20 Missing and 8 partials ⚠️
internal/ops/net_requests.go 58.33% 15 Missing and 10 partials ⚠️
internal/ops/verify.go 42.30% 10 Missing and 5 partials ⚠️
cmd/gobl/net_who.go 50.00% 5 Missing ⚠️
internal/ops/net_who.go 80.95% 2 Missing and 2 partials ⚠️
cmd/gobl/net_send.go 87.50% 1 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##              net      #31      +/-   ##
==========================================
- Coverage   77.95%   77.02%   -0.94%     
==========================================
  Files          57       59       +2     
  Lines        2908     2990      +82     
==========================================
+ Hits         2267     2303      +36     
- Misses        527      559      +32     
- Partials      114      128      +14     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

samlown and others added 2 commits August 11, 2026 21:41
Party envelopes carry no audience binding (spec §8.3); the inbox
accepts its own identity returns (subject == this address) without
endorsement, alongside the existing deferred-who fulfilment. Other
documents keep the searched audience requirement. gobl pinned to
main past #924.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Adopts gobl/net's order-free API: party envelopes resolve their
subject from the document's own gobl: endpoint (VerifyParty), other
documents resolve their sender from the delivery binding
(VerifyDelivery), and the verify command checks every signature
against its issuer's published keys.

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.

2 participants