Skip to content

feat(identity): connect native credential policy enforcement - #346

Merged
FumingZhang merged 5 commits into
mainfrom
feat/credential-policy-readback
Oct 29, 2026
Merged

FumingZhang merged 5 commits into
mainfrom
feat/credential-policy-readback

Conversation

@FumingZhang

@FumingZhang FumingZhang commented Oct 28, 2026 •

Copy link
Copy Markdown
Member

Summary

Connect native OpenClaw/Hermes workloads to Broker/Connections authentication and credential-policy enforcement, rather than leaving every governed native runtime unsupported.

  • Project a purpose-bound Connections token using the existing current ServiceAccount and source pins. Only the primary Agent container receives it; it is separate from Entra's AzureADTokenExchange projection.
  • Independently verify TokenReview, current Pod/ServiceAccount/namespace/Agent identity and the protected common-executor authority at both Broker and MCP. The authority check reuses the existing Pod-admission validator through a fixed, CA-verified, identical-object dry-run request; it does not write a Pod or trust a caller-provided availability flag.
  • Wire the registered MCP Service, public CA and exactly Agent-owned Broker storage grants into current workload sources and network compilation.
  • Allow verified configuration readback to complete PolicyApplied without a bootstrap/readiness cycle. Actual credential serving still requires a Ready Agent and Running/Ready current Pod.
  • Preserve owner/service scope, record UID/version pins, ordered revocation and cleanup, and independent GitHub/Google behavior when ARM policy is unavailable.
  • Accept valid Kubernetes ServiceAccount and Pod names, including dotted/long accounts and generated 65-character StatefulSet Pod names, without relaxing namespace, current-source or UID checks.

Native execution is now connected behind explicit configuration. Live identity-provider permissions, federation and cluster/dataplane qualification are not established by these local tests.

Related issue

Continues the Broker/Connections foundation from #331. The generic Entra and managed FQDN integrations in #345 and #347 were additionally tested together in an unpublished source snapshot. Neither implementation is imported into this branch, and the default/current-ServiceAccount native path does not depend on them or on #337.

Validation

Offline checks used Go 1.27.3, Helm 3.22.0 and isolated Kubernetes 1.37.0 API-server/etcd binaries. Kubernetes, admission, directory and provider fixtures are synthetic unless explicitly described below.

Command: go -C app/internal test ./... -count=1
Result: passed.

Command: go -C app/internal test -race ./... -count=1
Result: passed.

Command: go -C app/cetirun-agent-broker test ./... -count=1
Result: passed.

Command: go -C app/cetirun-agent-broker test -race ./... -count=1
Result: passed.

Command: go -C app/cetirun-connections-mcp test ./... -count=1
Result: passed.

Command: go -C app/cetirun-connections-mcp test -race ./... -count=1
Result: passed.

Command: go -C app/cetirun-operator test ./internal/controller -count=1 -timeout=30m
Result: passed after fixing the historical chart-fixture reconstruction. The full suite was not repeated after the later name-only correction; focused regressions below passed.

Command: go -C app/cetirun-operator test -race ./internal/controller ./internal/sandboxpolicy ./internal/sandboxworkload -run 'TestNativeConnections|TestCredentialPolicy|TestConnectionsProof|TestNativeUpgradePreparesExistingAgentWithPinnedPreProxyChart' -count=1 -timeout=20m
Result: passed.

Command: go -C app/cetirun-operator test -tags=envtest ./internal/controller -run '^TestNativeConnectionsServedCurrentSourceProof$' -count=1 -timeout=20m -v
Result: passed for both harnesses. Uses API-issued Pod-bound tokens, actual TokenReview and the real local Pod-admission handler; rejects a new token for a recreated ServiceAccount and clears credential readiness.

Command: go -C app/internal test -race ./agenttools -run 'TestValidDNSSubdomainName|TestNative|TestCredentialPolicy' -count=1
Result: passed after the name correction.

Command: go -C app/cetirun-agent-broker test -race ./internal/broker -run 'TestNative|TestCredentialPolicy|TestTokenReviewRequiresRequestedAudience|TestWorkload' -count=1
Result: passed after the name correction.

Command: go -C app/cetirun-connections-mcp test -race ./internal/identity -run 'TestNative|TestAuthenticate|TestServiceAccountIdentity' -count=1
Result: passed after the name correction.

Command: bash scripts/cetirun-agent-broker-helm-test.sh
Result: passed.

Command: make -C app/cetirun-connections-mcp chart-lint
Result: passed.

Command: python3 -B -m unittest discover -s app/cetirun-chart/tests -p test_connections_mcp.py -v
Result: passed, including 11 final chart tests covering long/dotted common ServiceAccounts, invalid names and unchanged ordinary limits.

Command: python3 -B -m unittest scripts.tests.test_native_mcp_runtime -v
Result: passed.

Command: make docs-check
Result: passed after locked site dependencies became available. After the final documentation-only wording corrections, make -C site test headers passed again (106 validator tests).

Command: make license-check version-check
Result: passed.

Command: git diff --check
Result: passed; final staged whitespace check also passed.

Complete module vet/build checks also passed. The final combined-source commands were:

Command: for module in app/internal app/cetirun-agent-broker app/cetirun-connections-mcp app/cetirun-operator; do go -C "$module" vet ./...; go -C "$module" build ./...; done
Result: passed for all four modules.

Command: go -C app/cetirun-operator vet -tags=envtest ./internal/controller
Result: passed.

Additional three-PR composition checks passed in an unpublished snapshot:

  • Eight Entra/Connections/FQDN scenarios across both harnesses, with/without ingress mTLS, including stable rate-limit updates and independent control removal.
  • The served-token/PolicyApplied case with Entra, FQDN and mTLS all enabled and a dotted ServiceAccount longer than 63 characters. Real local API tokens and admission were used; Broker readback and directory responses remained fixtures.
  • Full shared/Broker/MCP module race suites, combined controller credential/lifecycle race tests, full compiler/workload tests, all four module builds/vet and Operator envtest vet.

These are offline composition checks, not a deployed Broker/MCP/Operator system. Scheduler, kubelet, model and provider observations remain synthetic. No raw diagnostic, credential or private deployment bundle is attached.

Not run: live AKS/Kata/Cilium/CSI or Istio transport, real model/provider operations, Entra federation/FIC changes, Azure permissions, kubelet token rotation, or whole-repository make check/test/lint.

Review follow-up: 2026-10-29

Merged main cfdf7c555, resolving the shared suspension/restart test helper
conflicts while retaining both native Connections and container coverage.

bf8e8a5f7 uses the documented
cetirun-sandbox-admission.<operatorNamespace>.svc TLS identity. The shared
fixture now presents only that DNS SAN and redirects socket dialing to its local
server without changing the request hostname. Real TLS tests verify that the
documented certificate succeeds and wrong Service SANs or untrusted CAs fail;
CA and hostname verification remain enabled.

Command: go -C app/internal test ./agenttools -run '^TestNativeVerifierAuthenticatesDocumentedServiceName$' -count=1
Result: reproduced the original hostname-verification failure.

Command: go -C app/internal test -race ./agenttools ./tlsreload -count=1
Result: passed after the correction, including all three certificate cases.

Command: go -C app/internal test ./... -count=1
Result: passed.

Command: go -C app/internal vet ./agenttools/...
Result: passed.

Command: go -C app/cetirun-agent-broker test -race ./... -count=1 -timeout=20m
Result: passed.

Command: go -C app/cetirun-connections-mcp test -race ./... -count=1 -timeout=20m
Result: passed.

Command: go -C app/cetirun-operator test ./internal/controller ./internal/helm -run '^Test(NativeConnections(SuspensionKeepsHomeAndKey|RetainedRestartKeepsCurrentBindings)|ContainerSandbox(RetainedRestart|SuspendResume)|NativeUpgrade|SandboxNativeProxy|SandboxPreProxy)' -count=1 -timeout=20m
Result: passed, controller 23.294s and Helm 0.489s.

Command: go -C app/cetirun-operator test -tags=envtest ./internal/controller -run '^TestNativeConnectionsServedCurrentSourceProof$' -count=1 -timeout=20m
Result: passed, 20.524s, with local API-issued tokens and served admission.

Command: go -C app/cetirun-operator vet ./internal/controller
Result: passed.

Command: make -C app/cetirun-operator build
Result: passed.

Command: make -C app/cetirun-agent-broker build
Result: passed.

Command: make -C app/cetirun-connections-mcp build
Result: passed.

Command: make docs-check HUGO="$HUGO"
Result: passed with the explicitly selected Hugo 0.164.0 extended executable.

Command: git diff --check
Result: passed.

Not run for this review correction: live AKS, Entra/provider requests, or the
whole-repository test suite. TLS verification used real local handshakes and
synthetic certificates; no deployment credentials were used.

Compatibility and operational impact

No new Agent API/status properties are introduced. The earlier status-comment/generated-description synchronization remains; runtime wiring adds no CRD/deepcopy change or dependency upgrade. Broker/Connections retain the matching 2026-10-28 internal contract and must be deployed with compatible builds.

Native integration is opt-in through Operator connectionsMCP.nativeEnabled and MCP nativeSandbox.enabled, with the matching protected peer inventory, Service, public CA, purpose audience and Operator namespace. Broker/MCP receive named read access to the fixed Pod-webhook configuration, not Pod write access. The Operator's existing Agent-owned storage grants scope Broker record access; Agent workloads receive no provider credentials or Secret API permissions.

Native Pods do not have Istio workload certificates. With native opt-in, MCP port 8443 uses application HTTPS and Pod-bound proof instead of an additional outer Istio mTLS layer. A Service-scoped DestinationRule preserves ordinary meshed clients using the same application TLS/proof. MCP-to-Broker direct mTLS remains required; the default non-native configuration remains strict.

Configuration readback is not permission to serve credentials before readiness. Missing, changed, held, suspended, deleting or unqualified workload authority is rejected. Shared personal credentials remain outside Agent ownership; cleanup does not require a still-running Pod. Generic Entra exchange and Connections purpose proofs remain distinct.

Checklist

  • The change is focused and preserves unrelated work.
  • Tests cover the changed behavior, or I explained why no new test is needed.
  • Documentation and examples match any public behavior changes.
  • Generated artifacts were updated from source, or none are affected.
  • Dependency changes include lockfiles, source attribution, and license information, or none are affected.
  • I checked the diff and attachments for secrets, private endpoints or identifiers, customer data, agent conversations, and internal information.
  • I followed the applicable CLA instructions, or asked a maintainer about an unclear check.
  • I identified checks that need credentials or a live environment and did not run them without authorization.

Apply and independently read back owned Broker enforcement records, bind credential issuance to current policy and record identities, and preserve independent connection discovery. Native workload authorization remains gated; no provider token or desired-state placeholder becomes applied evidence.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Qualify common native workloads through current Pod-bound proof and existing protected admission authority. Wire Connections transport, owned storage and policy readback without a readiness cycle, while preserving provider and owner boundaries. Accept valid Kubernetes ServiceAccount and Pod names without relaxing namespace or source checks.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@FumingZhang FumingZhang changed the title feat(identity): verify credential policy enforcement records feat(identity): connect native credential policy enforcement Oct 28, 2026
@FumingZhang
FumingZhang marked this pull request as ready for review October 28, 2026 11:00
Merge main and resolve the Agent Identity guide conflict while retaining current native authorization guidance and environment setup links. Parse endpoint ports with an explicit unsigned 16-bit range before using int32 Service ports, and cover default, boundary, overflow and backend mappings.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Comment thread app/internal/agenttools/native.go Resolved
FumingZhang and others added 2 commits October 29, 2026 01:09
Reuse the shared retained suspension and restart test helpers for both Connections and ordinary-container coverage, preserving the merged Hermes ingress changes.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Use the Kubernetes Service DNS identity promised by admission certificate configuration. Retain CA and hostname verification, and exercise a service-only certificate with socket redirection rather than rewriting the request host. Reject mismatched service names and untrusted roots across the shared Broker/MCP verifier.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

@feiskyer Pengfei Ni (feiskyer) 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.

LGTM

@FumingZhang
FumingZhang merged commit 25656da into main Oct 29, 2026
33 checks passed
@FumingZhang
FumingZhang deleted the feat/credential-policy-readback branch October 29, 2026 06:06
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.

3 participants