Repository navigation
Description
Why
#7199 ports Entra on-behalf-of (OBO) backend auth to OSS (PR #7201). It is covered by unit tests, envtest reconcile tests, and a vMCP integration test against a mock Entra token endpoint. Nothing yet runs the whole path against a real Microsoft Entra tenant in a real cluster:
- a real user token is validated by the incoming OIDC middleware;
- the proxyrunner or vMCP pod reads the client secret the operator mounted;
- Entra performs the exchange;
- a backend receives and accepts the token.
Mocks can't catch real-Entra behavior: v1 vs v2 token issuers, aud formats (api://... vs a GUID), .default scope handling, consent errors, or conditional-access responses.
We can't run this in CI: it needs a tenant, app registrations, and a test user's credentials. Instead, a maintainer runs it locally as validation before releases or when OBO code changes.
What
Add an opt-in operator e2e suite that runs on the existing Kind workflow (task kind-setup-e2e → operator-deploy-local) and exercises OBO against a real tenant.
Gating
- Skip the whole suite unless every required env var is set. This follows the
TOOLHIVE_E2E_PODMAN_NATIVEpattern intest/e2e/network_isolation_podman_linux_test.go. - Give the suite a Ginkgo label (e.g.
Label("entra-live")) so it can be selected on its own. - CI never sets the env vars, so the suite always skips in
thv-operator-e2e-test. Also exclude the label explicitly in CI so a misconfigured runner can't reach a real tenant. - Add a task, e.g.
task thv-operator-e2e-test-entra, that runs only this label against an existing cluster.
Required configuration (proposed names)
| Env var | Purpose |
|---|---|
TOOLHIVE_E2E_ENTRA_TENANT_ID |
Tenant GUID or domain |
TOOLHIVE_E2E_ENTRA_PROXY_CLIENT_ID / _CLIENT_SECRET |
Middle-tier (confidential client) app that the proxy and vMCP use for OBO; also the audience of the incoming user token |
TOOLHIVE_E2E_ENTRA_BACKEND_SCOPE |
Downstream API scope, e.g. api://<backend-app>/.default |
TOOLHIVE_E2E_ENTRA_BACKEND_AUDIENCE |
Expected aud of the exchanged token, checked by the backend |
| User credentials | How the test gets a user token for the middle-tier app (see open question) |
Document the one-time tenant setup:
- the two app registrations;
- the exposed API and scope on each;
- the middle-tier app's API permission on the backend scope, with admin consent;
- a dedicated test user.
Scenarios
- MCPServer + OBO.
MCPOIDCConfigpoints at the tenant's v2 issuer with the middle-tier app as audience.MCPExternalAuthConfigis typeobo.- The backend is a small test server that validates the bearer token against the tenant JWKS (issuer and
aud= backend audience) and reports the claims it saw. - Assert that the call succeeds, the backend saw an exchanged token (not the user's), and its
audandsub/oidmatch the user.
- MCPRemoteProxy + OBO. Same assertions as scenario 1.
- VirtualMCPServer, inline
outgoingAuth, two OBO backends (different configs and secrets).- Both backends receive correctly scoped tokens.
- The pod has two distinct
TOOLHIVE_OBO_CLIENT_SECRET_<NAME>env vars. This is a regression check for the env var collision Support Entra on-behalf-of backend auth in OSS #7201 fixes.
- VirtualMCPServer, discovered mode, with an MCPServer backend and an MCPServerEntry backend.
- Negative cases:
- A wrong client secret gives 502 (
invalid_client) and the pod still starts. - A user token for the wrong audience gives 401 at the incoming OIDC layer.
- An unconsented scope, if cheap to set up:
invalid_grantgives 401. - Optional: if the tenant has a conditional-access policy that can target the backend app, the response is 403 and an
obo_token_exchangeaudit event is emitted.
- A wrong client secret gives 502 (
Open questions
-
How to get the user token non-interactively. Options:
- ROPC (password grant) for a dedicated, MFA-exempt test user. Simplest, but Microsoft discourages it, and it fails under some tenant policies.
- Device code flow with a cached refresh token: an interactive first run, then a refresh token passed via env.
- A pre-acquired token passed in: short-lived and manual.
A pluggable "token source" covering ROPC and refresh-token would cover most setups.
-
Should the backend validate tokens in-process (Go test server image), or just echo headers so the test decodes and checks the JWT? In-process validation also proves Entra accepts the token for that audience.
-
Can Stacklok provide a shared test tenant whose credentials live in a password manager, so any maintainer can run the suite?
Acceptance criteria
- With the env vars unset, the suite compiles and skips with a clear message;
task thv-operator-e2e-testbehaves exactly as before. - With the env vars set against a configured tenant, scenarios 1–5 pass on a local Kind cluster.
- Tenant setup, the env vars, and the run command are documented (e.g.
test/e2e/thv-operator/READMEordocs/). - No token, secret, or user credential is logged by the tests or written into any committed fixture.
Related
- Support Entra on-behalf-of (OBO) backend auth in OSS #7199 / Support Entra on-behalf-of backend auth in OSS #7201: OSS OBO port
- Remove deprecated OBO enterprise hooks and sentinels #7200: removal of the deprecated OBO hooks
Activity