feat(federation): authorizeInbound ingress authorizer (PR-D1) - #73
Merged
Conversation
PR-D1 of auth/authz #47 (pure helper; broker wiring is PR-D2). Decodes an envelope's bearer authToken and verifies it against the roster, binding the token subject (actor) to the envelope sender: - authorizeInbound(envelope, rosters, { localOrg, audience, requiredScopes, enforce, now }) -> { accepted, reason? }. - enforce=false: no authToken -> accepted (MURMUR_ENFORCE_AUTH gate off). enforce=true: missing token -> auth-missing. - senderAgentId is BARE on the wire; parsed into an AgentAddress via localOrg before comparing to token.subject (raw-string compare would always mismatch — Codex note). - delegates to verifyAuthToken with audience + requiredScopes + requiredSubject. - AuthorizeInboundReason = AuthTokenRejectReason | auth-missing. Pure: no transport, no logging (callers audit msgId/sender/audience/reason, never the token body). Tests (federation 30/30, +5): enforce-off pass-through; enforce-on missing -> auth-missing; valid bound token accepted; different sender -> subject-mismatch (actor binding); scope-missing; audience-mismatch; garbage token -> malformed. Verified: build PASS; full npm test 0 fail; diff --check clean.
|
To use Codex here, create a Codex account and connect to github. |
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.
What (PR-D1 of auth/authz #47)
The pure ingress authorizer. Decodes an envelope's bearer
authTokenand verifies it against the roster, binding the tokensubject(actor) to the envelopesenderAgentId. (PR-D2 wires it into broker-nats behindMURMUR_ENFORCE_AUTH.)Guardrails (all from your design-review)
senderAgentIdis bare on the wire; parsed into an AgentAddress vialocalOrgbefore comparing totoken.subject(raw compare would always mismatch — your note).enforce=false→ no token passes through;enforce=true→ missing token =auth-missing.verifyAuthToken(audience + requiredScopes + requiredSubject).Tests (federation 30/30, +5)
enforce-off pass-through · enforce-on missing→auth-missing · valid bound token accepted · different sender→subject-mismatch · scope-missing · audience-mismatch · garbage→malformed.
Verification
build PASS; full
npm test0 fail;git diff --checkclean. Pure helper — no transport touched.Review by diff + CI. @codex PR-D1; PR-D2 (broker-nats enforce behind MURMUR_ENFORCE_AUTH, NACK auth-rejected:) is the final piece.