Skip to content

feat: Add advanced AuthBridge config -- port exclusions, outbound policy, audience - #1177

Merged
mrsabath merged 4 commits into
rossoctl:mainfrom
mrsabath:feat/authbridge-advanced-config
Apr 9, 2026
Merged

mrsabath merged 4 commits into
rossoctl:mainfrom
mrsabath:feat/authbridge-advanced-config

Conversation

@mrsabath

@mrsabath mrsabath commented Apr 8, 2026

Copy link
Copy Markdown
Member

Summary

  • Add "AuthBridge Advanced Configuration" expandable section to Import Agent and Import Tool pages
  • Port exclusion annotations: users can specify comma-separated ports to bypass proxy interception (outbound and inbound)
  • Default outbound policy: override the go-processor default passthrough behavior
  • Expected audience: override the inbound JWT audience validation claim
  • Backend applies port exclusions as pod template annotations and writes policy/audience to authbridge-config ConfigMap

New fields

Field Type Where applied
Outbound Ports to Exclude Comma-separated ports Pod annotation kagenti.io/outbound-ports-exclude
Inbound Ports to Exclude Comma-separated ports Pod annotation kagenti.io/inbound-ports-exclude
Default Outbound Policy passthrough or exchange authbridge-config ConfigMap
Expected Audience SPIFFE ID or custom authbridge-config ConfigMap

Test plan

  • Python syntax verified (py_compile on all modified files)
  • TypeScript type-check passes for our files
  • Pre-commit hooks pass
  • CI pipeline passes
  • Manual verification: advanced config section renders and values persist

Ref #1167, #1168
Depends on #1174, #1175, #1176

@huang195 huang195 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.

Mariusz, czwarty PR w jednym dniu — produkcja idzie pełną parą, ale tu mamy kilka poważnych problemów!

Critical Issues

1. Data loss bug — kube.upsert_configmap(name="authbridge-config", data=extra_config) replaces the entire ConfigMap .data with just the 1-2 new keys. The existing authbridge-config has KEYCLOAK_URL, KEYCLOAK_REALM, ISSUER, and more — all wiped on upsert. The upsert_configmap method does existing.data = data (full replace). Fix: merge new keys into existing data.

2. Dead code — _build_common_annotations() is defined in agents.py but never called. Port exclusion annotations silently never reach agent pod templates.

3. Finalize inconsistency — tools.py finalize reads port exclusions from tool_config_dict.get(...) directly, skipping the request-override merge pattern used for all other fields. Finalize request overrides are ignored.

4. Cross-repo conflict — EXPECTED_AUDIENCE is being removed from the webhook and go-processor in rossoctl/cortex#282 (replaced by per-agent CLIENT_ID). Adding a UI field for it here would be dead on arrival. DEFAULT_OUTBOUND_POLICY is still valid.

5. CodeQL — 5 high severity log injection alerts (inherited from parent PRs + new).

Areas reviewed: Python (backend + kubernetes service), Frontend (React/TS), API types, Cross-repo (kagenti-extensions#282)
Commits: 4 (first 3 from dependency PRs), all signed-off: ✅
CI status: CodeQL failing (5 high log injection), all other checks pass

Dużo roboty, ale naprawienie tych bugów jest kluczowe — szczególnie ten upsert ConfigMap! 🔧

Comment thread kagenti/backend/app/routers/agents.py Resolved
Comment thread kagenti/backend/app/routers/agents.py Resolved
Comment thread kagenti/backend/app/routers/tools.py Resolved
Comment thread kagenti/backend/app/routers/agents.py Resolved
Comment thread kagenti/backend/app/routers/agents.py Resolved
@mrsabath
mrsabath force-pushed the feat/authbridge-advanced-config branch from 0875260 to 0ee4cda Compare April 8, 2026 22:31
@mrsabath

mrsabath commented Apr 8, 2026

Copy link
Copy Markdown
Member Author

Pushed b9bd4f44 to fix the CodeQL log injection alerts.

Root cause: CodeQL's py/log-injection rule traces taint from user-provided values to the log sink regardless of the formatting method -- %s-style parametric logging, f-strings, and even sanitizer functions all still trigger the alert. The only approach that passes is to remove user-provided values entirely from log arguments (matching the fix adopted on main in 244fea34).

What changed:

  • agents.py: _ensure_authproxy_routes f-string logger -> logger.info("Upserted authproxy-routes ConfigMap")
  • kubernetes.py: All 3 upsert_configmap loggers -> generic messages without name/namespace/e arguments

@mrsabath

mrsabath commented Apr 8, 2026

Copy link
Copy Markdown
Member Author

/run-e2e

@github-actions github-actions Bot added the safe-to-test Maintainer reviewed - safe to run E2E tests label Apr 8, 2026
@github-actions

github-actions Bot commented Apr 8, 2026

Copy link
Copy Markdown

E2E HyperShift Tests Started

Triggered by: @mrsabath
Commit: b9bd4f448fab4f57962303777550d0ecc5f88724
Workflow Run: View logs

Tests are running on OpenShift 4.20.11. This typically takes 30-45 minutes.


To re-run tests after new commits, comment /run-e2e again.

@github-actions

github-actions Bot commented Apr 8, 2026

Copy link
Copy Markdown

E2E HyperShift Tests Failed

Commit: b9bd4f448fab4f57962303777550d0ecc5f88724
Result: Tests failed - please check the logs
Workflow Run: View logs


To re-run tests after fixing issues, comment /run-e2e again.

@github-actions github-actions Bot removed the safe-to-test Maintainer reviewed - safe to run E2E tests label Apr 8, 2026
@github-actions

github-actions Bot commented Apr 8, 2026

Copy link
Copy Markdown

New Commits Detected

The safe-to-test label has been automatically removed because new commits were pushed.

New HEAD: c943bcc

For maintainers: Please review the new changes and comment /run-e2e to trigger E2E tests.

Security checklist

Before running E2E tests, verify the PR does NOT contain:

  • Changes to .github/workflows/ that bypass security
  • Changes to .github/scripts/ that could exfiltrate secrets
  • curl, wget, or nc commands to external URLs in scripts
  • Base64 encoding of environment variables
  • Printing secrets to logs (echo $SECRET)
  • Suspicious package installations

This is an automated security measure to prevent TOCTOU attacks

@huang195 huang195 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.

Re-review after fix commits 0ee4cda, b9bd4f4, c943bcc. Wszystko naprawione — i to porządnie, Mariusz!

All 6 original issues resolved ✅

Issue Fix Verdict
Data loss: upsert_configmap replaces entire .data existing.data = {**(existing.data or {}), **data} (merge semantics) ✅ Critical fix
Dead code: _build_common_annotations never called Wired into all 3 manifest builders (deployment, statefulset, job) ✅ Fixed
Tools finalize: port exclusions skip request override Added proper request.x if not None else stored pattern ✅ Fixed
Cross-repo conflict: expectedAudience vs extensions#282 Removed entirely from backend, frontend, API types ✅ Clean removal
Suggestion: defaultOutboundPolicy as free text Literal["passthrough", "exchange"] + FormSelect dropdown ✅ Better UX
CodeQL: log injection (5 high) Removed user values from log messages ✅ CodeQL now passing

CI status: All checks passing ✅ (Deploy & Test pending)
Commits: 7 (4 original + 3 fixes), all signed-off

Szybkie i solidne poprawki — gotowe do merge! 🚀

@mrsabath
mrsabath force-pushed the feat/authbridge-advanced-config branch from c943bcc to 3d95e90 Compare April 9, 2026 01:04
@mrsabath

mrsabath commented Apr 9, 2026

Copy link
Copy Markdown
Member Author

/run-e2e

@github-actions github-actions Bot added the safe-to-test Maintainer reviewed - safe to run E2E tests label Apr 9, 2026
@github-actions

github-actions Bot commented Apr 9, 2026

Copy link
Copy Markdown

E2E HyperShift Tests Started

Triggered by: @mrsabath
Commit: 3d95e9055c7eefbe89bb2d5227fb8b213e3fbcf7
Workflow Run: View logs

Tests are running on OpenShift 4.20.11. This typically takes 30-45 minutes.


To re-run tests after new commits, comment /run-e2e again.

mrsabath added 4 commits April 8, 2026 21:14
…icy, audience

Add expandable "AuthBridge Advanced Configuration" section to both
import pages with port exclusion annotations, default outbound policy,
and expected audience override.

- Port exclusion annotations (kagenti.io/outbound-ports-exclude,
  kagenti.io/inbound-ports-exclude) applied as pod template annotations
- DEFAULT_OUTBOUND_POLICY and EXPECTED_AUDIENCE written to
  authbridge-config ConfigMap via upsert
- Shipwright build annotations and finalize flow propagate all fields

Ref #1167, #1168

Assisted-By: Claude (Anthropic AI) <[email protected]>
Signed-off-by: Mariusz Sabath <[email protected]>
…ience, CodeQL

- Fix upsert_configmap to merge data keys instead of replacing entire
  ConfigMap, preventing wipe of KEYCLOAK_URL/REALM/ISSUER when writing
  DEFAULT_OUTBOUND_POLICY to authbridge-config
- Wire _build_common_annotations() into all 3 agent manifest builders
  (deployment, statefulset, job) so port exclusion annotations reach
  pod templates
- Fix tools.py finalize to use request-override-merge pattern for port
  exclusions and defaultOutboundPolicy (was reading stored config only)
- Drop expectedAudience entirely -- being removed in extensions#282
  in favor of per-agent CLIENT_ID from /shared/client-id.txt
- Use Literal["passthrough","exchange"] for defaultOutboundPolicy and
  replace free-text input with FormSelect dropdown on both import pages
- Fix label asymmetry in upsert_configmap update path
- Switch all new f-string loggers to %s-style parametric logging

Signed-off-by: Mariusz Sabath <[email protected]>
CodeQL traces taint through %s-style formatting and sanitizer
functions. The only reliable fix is to remove user-provided values
(name, namespace) from log format arguments entirely, matching the
approach adopted on main (244fea3).

Signed-off-by: Mariusz Sabath <[email protected]>
- create_tool: use request.defaultOutboundPolicy directly instead of
  undefined final_default_outbound_policy variable (F821)
- finalize_tool_shipwright_build: wire final_default_outbound_policy
  into authbridge-config ConfigMap upsert (was defined but unused, F841)

Signed-off-by: Mariusz Sabath <[email protected]>
@mrsabath
mrsabath force-pushed the feat/authbridge-advanced-config branch from 3d95e90 to 742fac4 Compare April 9, 2026 01:16
@github-actions github-actions Bot removed the safe-to-test Maintainer reviewed - safe to run E2E tests label Apr 9, 2026
@github-actions

github-actions Bot commented Apr 9, 2026

Copy link
Copy Markdown

New Commits Detected

The safe-to-test label has been automatically removed because new commits were pushed.

New HEAD: 742fac4

For maintainers: Please review the new changes and comment /run-e2e to trigger E2E tests.

Security checklist

Before running E2E tests, verify the PR does NOT contain:

  • Changes to .github/workflows/ that bypass security
  • Changes to .github/scripts/ that could exfiltrate secrets
  • curl, wget, or nc commands to external URLs in scripts
  • Base64 encoding of environment variables
  • Printing secrets to logs (echo $SECRET)
  • Suspicious package installations

This is an automated security measure to prevent TOCTOU attacks

@mrsabath

mrsabath commented Apr 9, 2026

Copy link
Copy Markdown
Member Author

/run-e2e

@github-actions github-actions Bot added the safe-to-test Maintainer reviewed - safe to run E2E tests label Apr 9, 2026
@github-actions

github-actions Bot commented Apr 9, 2026

Copy link
Copy Markdown

E2E HyperShift Tests Started

Triggered by: @mrsabath
Commit: 742fac444954dd99ddf92e3a8af70387416bb6c8
Workflow Run: View logs

Tests are running on OpenShift 4.20.11. This typically takes 30-45 minutes.


To re-run tests after new commits, comment /run-e2e again.

@github-actions

github-actions Bot commented Apr 9, 2026

Copy link
Copy Markdown

E2E HyperShift Tests Failed

Commit: 3d95e9055c7eefbe89bb2d5227fb8b213e3fbcf7
Result: Tests failed - please check the logs
Workflow Run: View logs


To re-run tests after fixing issues, comment /run-e2e again.

@mrsabath
mrsabath merged commit 959b7d1 into rossoctl:main Apr 9, 2026
22 checks passed
@mrsabath
mrsabath deleted the feat/authbridge-advanced-config branch April 9, 2026 01:26
@github-actions

github-actions Bot commented Apr 9, 2026

Copy link
Copy Markdown

E2E HyperShift Tests Failed

Commit: 742fac444954dd99ddf92e3a8af70387416bb6c8
Result: Tests failed - please check the logs
Workflow Run: View logs


To re-run tests after fixing issues, comment /run-e2e again.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

safe-to-test Maintainer reviewed - safe to run E2E tests

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

3 participants