Skip to content

feat: add jwt auth for ateapi - #248

Merged
Zoe Zhao (zoez7) merged 17 commits into
agent-substrate:mainfrom
kagent-dev:feat/jwt-ateapi-auth
Jul 1, 2026
Merged

Zoe Zhao (zoez7) merged 17 commits into
agent-substrate:mainfrom
kagent-dev:feat/jwt-ateapi-auth

Conversation

@EItanya

@EItanya Eitan Yarmush (EItanya) commented Jun 15, 2026 •

Copy link
Copy Markdown
Collaborator

Description

Closes #222.

Adds a portable JWT authentication path for ateapi clients while keeping the
existing mTLS mode as the default.

What changed

  • Added internal/ateapiauth with:
    • mtls and jwt auth modes
    • server-side JWT gRPC interceptors
    • client-side dial options for projected ServiceAccount tokens
  • Wired JWT auth into:
    • ate-api-server
    • ate-controller
    • atenet router
    • kubectl-ate port-forward client path
  • Updated Kubernetes JWT verification to support custom HTTP clients for
    OIDC/JWKS discovery.
  • Added JWT install overlays:
    • manifests/ate-install/jwt
    • manifests/ate-install/kind-jwt
  • Updated hack/install-ate.sh to opt into JWT mode with:
    • ATE_API_AUTH_MODE=jwt
    • --auth-mode=jwt

Notes

  • Default install behavior remains mtls. I think this deserves a second look as JWT will support more clusters.

  • The JWT overlay projects short-lived ServiceAccount tokens with audience
    api.ate-system.svc and mounts the service-DNS trust bundle for ateapi TLS
    verification.

  • The current discovery mechanism for JWT mode involves reading the deployment which I really don't like, but we don't have a "config file" concept so that bit is a massive TODO.

    Validation

KIND_CLUSTER_NAME=substrate-jwt ./hack/create-kind-cluster.sh

KO_DOCKER_REPO=localhost:5001 \
ATE_INSTALL_KIND=true \
./hack/install-ate.sh --auth-mode=jwt --deploy-ate-system

Validation results:

kubectl config current-context
# kind-substrate-jwt

kubectl get pods -n ate-system
# all runtime pods Running; init jobs Completed

go run ./cmd/kubectl-ate --context kind-substrate-jwt get actors
# succeeded, empty actor list

Comment thread internal/ateapiauth/client.go Resolved
@EItanya
Eitan Yarmush (EItanya) force-pushed the feat/jwt-ateapi-auth branch 2 times, most recently from 9a1e6b3 to ba351a2 Compare June 25, 2026 17:59
Comment thread cmd/ateapi/internal/k8sjwt/k8sjwt.go Resolved
Comment thread internal/ateapiauth/client.go Resolved
Comment thread cmd/ateapi/main.go Resolved
Comment thread internal/ateapiauth/server.go Resolved
Comment thread internal/ateclient/builder.go Resolved
@EItanya

Copy link
Copy Markdown
Collaborator Author

Zoe Zhao (@zoez7) addressed your comments. Also Just FYI I changed the e2e test workflow to use a matrix and install substrate in both modes to make sure they work. Let me know if you think that's overkill

@zoez7 Zoe Zhao (zoez7) left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Thanks, let's rebase and merge.

Comment thread internal/ateclient/builder.go Resolved
Comment thread cmd/ateapi/main.go Resolved
Comment thread cmd/ateapi/main.go Resolved
@zoez7

Copy link
Copy Markdown
Collaborator

Hmm the e2e-test check is stuck even though the test cases passed, because the it's matching the exact name "e2e-test"

image

Let's add a aggregate gate job with the name e2e-test that waits for the test matrix?

@EItanya

Copy link
Copy Markdown
Collaborator Author

Done in 8422f51. I renamed the matrix job id to e2e-test-matrix and added an aggregate e2e-test job that always runs after the matrix and fails unless the matrix result is success. That should restore the exact required check name while keeping e2e-test (mtls) and e2e-test (jwt) visible.

@EItanya

Copy link
Copy Markdown
Collaborator Author

Zoe Zhao (@zoez7) a change went in to the pr workflow that caused a conflict, should be good to go now.

Comment thread .github/workflows/pr-workflow.yaml Resolved
Comment thread cmd/ateapi/internal/k8sjwt/k8sjwt.go Resolved
Comment thread internal/ateapiauth/server.go Resolved
@EItanya

Copy link
Copy Markdown
Collaborator Author

Hey there Zoe Zhao (@zoez7), the atespaces PR ended up causing my jobs to fail. fixed now

@zoez7

Copy link
Copy Markdown
Collaborator

Looks like we need another rebase.

@EItanya

Copy link
Copy Markdown
Collaborator Author

Looks like we need another rebase.

Done. Can we please try and merge this ASAP. It has been approved for a bit now but I've had to resolve merge conflicts a few times already.

@zoez7
Zoe Zhao (zoez7) merged commit 3400f7f into agent-substrate:main Jul 1, 2026
19 of 21 checks passed
Zoe Zhao (zoez7) added a commit to zoez7/substrate that referenced this pull request Jul 12, 2026
Rebased onto main and integrated with the ateapi-auth (mtls|jwt) mode that
landed on main in agent-substrate#248.

Router (client):
- ateapi-auth=mtls now performs real mutual TLS: the router presents its
  podidentity credential bundle (--ateapi-client-cert) as a client cert and
  verifies ateapi's serving cert against the servicedns trust bundle
  (--ateapi-ca-certs), instead of the previous insecure TLS dial. No insecure
  fallback: missing material is a hard error.
- ateapi-auth=jwt (from agent-substrate#248) is unchanged and still routes through
  ateapiauth.DialOptions; otel tracing/metrics are preserved.

ateapi (server):
- The ateapiauth server interceptor now injects an authenticated principal
  (internal/principal) into the request context in both modes: the mtls
  authenticator extracts the client's SPIFFE identity from its mTLS peer
  cert, and the jwt authenticator records the verified token subject
  (VerifyBearerToken now returns the principal ID). The principal carries a
  Kind (mtls|jwt) and is included in RPC request logs.

Supporting changes:
- Move credbundle to internal/credbundle and add ClientLoader for client certs.
- podcertcontroller signers, valkey, and install-ate.sh updated to provision and
  mount the podidentity/servicedns bundles; manifests mount them into the
  router and apiserver pods.
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.

Support portable JWT auth for system components

4 participants