Skip to content

feat: Wire built-in plugins into pipeline and listeners - #359

Merged
huang195 merged 2 commits into
rossoctl:mainfrom
huang195:feat/pipeline-plugins
May 1, 2026
Merged

huang195 merged 2 commits into
rossoctl:mainfrom
huang195:feat/pipeline-plugins

Conversation

@huang195

@huang195 huang195 commented May 1, 2026

Copy link
Copy Markdown
Member

Summary

  • Introduces authlib/plugins/ package with jwt-validation and token-exchange plugins that delegate to auth.HandleInbound/HandleOutbound
  • Rewires all four listeners (ext_proc, ext_authz, forward-proxy, reverse-proxy) to execute through pipeline.Pipeline instead of calling *auth.Auth directly
  • Adds pipeline: YAML config section for plugin composition with programmatic fallback defaults
  • Supports waypoint audience derivation via WithAudienceDeriver functional option

Details

This is PR 2 of the plugin architecture series. PR 1 (merged in #358) added the pipeline package with types and runner. This PR proves the architecture works by wrapping existing auth logic as plugins -- behavior is identical, just executed through the pipeline path.

New files:

  • authlib/plugins/jwtvalidation.go -- inbound JWT validation plugin
  • authlib/plugins/tokenexchange.go -- outbound token exchange plugin
  • authlib/plugins/registry.go -- name-to-factory registry + Build() constructor
  • authlib/plugins/defaults.go -- default/waypoint pipeline constructors
  • authlib/plugins/plugins_test.go -- 13 unit tests

Modified files:

  • All four listener/*/server.go -- accept *pipeline.Pipeline instead of *auth.Auth
  • cmd/authbridge/main.go -- builds pipelines from config, passes to listeners
  • authlib/config/config.go -- adds PipelineConfig struct

Test plan

  • authlib/plugins tests pass (13/13)
  • cmd/authbridge/listener/extproc tests pass
  • cmd/authbridge/listener/extauthz tests pass
  • cmd/authbridge/listener/forwardproxy tests pass
  • cmd/authbridge/listener/reverseproxy tests pass
  • go vet ./... clean
  • Existing behavior unchanged (same allow/deny/replace-token responses)

Assisted-By: Claude (Anthropic AI) [email protected]

Wrap jwt-validation and token-exchange as pipeline plugins that delegate
to auth.HandleInbound/HandleOutbound. All listeners now execute through
the pipeline rather than calling auth.Auth directly. Adds YAML config
support for pipeline composition with programmatic fallback defaults.

Behavior is unchanged — this is a refactor that proves the plugin
architecture works before adding new plugins (mcp-parser, guardrails).

Signed-off-by: Hai Huang <[email protected]>
Assisted-By: Claude (Anthropic AI) <[email protected]>
Signed-off-by: Hai Huang <[email protected]>
The audience derivation is now handled inside the WaypointInboundPipeline
via the WithAudienceDeriver option on the JWT validation plugin.

Signed-off-by: Hai Huang <[email protected]>
Assisted-By: Claude (Anthropic AI) <[email protected]>
Signed-off-by: Hai Huang <[email protected]>

@esnible esnible left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I reviewed this manually and found no problems. I disagreed with most of the review skill's comments, but this one makes sense:

  #: 1                                                                                                                                          
  File: authbridge/cmd/authbridge/listener/extauthz/server.go, extproc/server.go, forwardproxy/server.go                                        
  Line: multiple                                                                                                                                
  Severity: suggestion                                                                                                                          
  Comment: extractBearer is duplicated identically in 3 packages. Consider extracting it to a shared internal/ or authlib/ helper to avoid drift
    between copies. 

@huang195

huang195 commented May 1, 2026

Copy link
Copy Markdown
Member Author

@esnible thanks for the review. Regarding your comment:

It's a valid observation but I'd leave it. The function is 4 lines, trivial, and unlikely to drift. Extracting it to a shared package would mean either:

  1. Importing authlib/auth from the listeners just for this one helper (adds a dependency that the refactor specifically removed)
  2. Creating a new internal/ or authlib/httputil package for a single 4-line function

  Both add more complexity than they remove. If it grows or gets a bug fix, that's the time to consolidate. Three identical 4-line functions is fine.

@huang195
huang195 merged commit fc206df into rossoctl:main May 1, 2026
17 checks passed
@huang195
huang195 deleted the feat/pipeline-plugins branch May 1, 2026 12:20
boazdavid added a commit to boazdavid/cortex that referenced this pull request Nov 24, 2026
…, correct

Four real review findings on this layer:

- OpenAI chat tools store their name in function.name, not the top-level name
  envelopeOps read. A removal among them matched nothing, fell back to the
  no-saving path, and lost the saving entirely. toolsOps now falls back to
  function.name before assigning the unnamed key.

- A zero prompt-tier total (an error status with no prompt usage, or a
  context-guru call billed before an inference-router resend) dropped a
  completed operator spend along with the never-priced savings, because the
  gate in InferenceParser.accountant looked only at the prompt counters.
  Spend does not depend on them — each record prices from its own operator
  call. The gate now also asks when the request has a reported op.

- One layer deeper: Host.Compute can refuse the whole request (a rejected
  status, or more than one upstream round) independent of the prompt total,
  which discarded the spend the same way. Host.Savings now reads the raw
  reported ops directly and prices any completed spend without going through
  Compute at all when it refuses — which also means a multi-round request's
  mismatched usage/body pair still cannot corrupt the thread's persisted
  cache-effect state for later requests, the actual reason Compute refuses.

- A spend record carried no currency, so an operator's call to a different,
  differently-priced host (a credits-billed gateway beside a USD-endpoint
  call) was summed into the primary request's total as if it were the same
  unit. SpendRecord now carries Currency, SpendPrice returns it, and
  event.Figures skips a spend whose currency does not match the record's own
  rather than mixing units.

Also dismissed 2 code-scanning alerts (clear-text-logging on the session id
this package logs, log-injection on a request path it logs) as false
positives, matching the repo's own precedent for the identical pattern
(alerts rossoctl#359 and rossoctl#334 on main): the session id is validated before it is
accepted, not a credential, and slog's TextHandler already quotes a value
before it reaches the log.

Assisted-By: Claude Sonnet 5 <[email protected]>
Signed-off-by: DAVID BOAZ <[email protected]>
boazdavid added a commit to boazdavid/cortex that referenced this pull request Nov 24, 2026
…, correct

Four real review findings on this layer:

- OpenAI chat tools store their name in function.name, not the top-level name
  envelopeOps read. A removal among them matched nothing, fell back to the
  no-saving path, and lost the saving entirely. toolsOps now falls back to
  function.name before assigning the unnamed key.

- A zero prompt-tier total (an error status with no prompt usage, or a
  context-guru call billed before an inference-router resend) dropped a
  completed operator spend along with the never-priced savings, because the
  gate in InferenceParser.accountant looked only at the prompt counters.
  Spend does not depend on them — each record prices from its own operator
  call. The gate now also asks when the request has a reported op.

- One layer deeper: Host.Compute can refuse the whole request (a rejected
  status, or more than one upstream round) independent of the prompt total,
  which discarded the spend the same way. Host.Savings now reads the raw
  reported ops directly and prices any completed spend without going through
  Compute at all when it refuses — which also means a multi-round request's
  mismatched usage/body pair still cannot corrupt the thread's persisted
  cache-effect state for later requests, the actual reason Compute refuses.

- A spend record carried no currency, so an operator's call to a different,
  differently-priced host (a credits-billed gateway beside a USD-endpoint
  call) was summed into the primary request's total as if it were the same
  unit. SpendRecord now carries Currency, SpendPrice returns it, and
  event.Figures skips a spend whose currency does not match the record's own
  rather than mixing units.

Also dismissed 2 code-scanning alerts (clear-text-logging on the session id
this package logs, log-injection on a request path it logs) as false
positives, matching the repo's own precedent for the identical pattern
(alerts rossoctl#359 and rossoctl#334 on main): the session id is validated before it is
accepted, not a credential, and slog's TextHandler already quotes a value
before it reaches the log.

Assisted-By: Claude Sonnet 5 <[email protected]>
Signed-off-by: DAVID BOAZ <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants