Skip to content

feat: run the VeADK web UI behind a key-auth API gateway (+ SSO AgentKit example)#610

Merged
yaozheng-fang merged 5 commits into
mainfrom
example/sso-frontend-on-agentkit
Jun 15, 2026
Merged

feat: run the VeADK web UI behind a key-auth API gateway (+ SSO AgentKit example)#610
yaozheng-fang merged 5 commits into
mainfrom
example/sso-frontend-on-agentkit

Conversation

@yaozheng-fang

@yaozheng-fang yaozheng-fang commented Jun 15, 2026

Copy link
Copy Markdown
Collaborator

What

Makes the VeADK web UI work behind an API gateway that authenticates every request with a key, and adds a deployable example for VeADK web UI + VeIdentity SSO on an AgentKit runtime.

Framework

The AgentKit gateway puts the runtime key in Authorization: Bearer <key> and forwards that header to the app, which collides with VeADK's own auth. Two fixes so veadk frontend works behind it:

  • veadk/cli/cli_frontend.py — when serving the built UI, forward the page's querystring onto /assets/* URLs, so a browser behind a query-string gateway carries the key on subresource requests too. Assets are mounted explicitly; a SPA fallback renders the injected shell, registered after the API routes.
  • veadk/auth/middleware/oauth2_auth.py — ignore a non-JWT Authorization bearer (unless token introspection is enabled) so auth falls back to the session cookie instead of failing with Invalid JWT format when a header gateway forwards its opaque key. A genuine user JWT is untouched.

Example: examples/sso_frontend_on_agentkit/

  • app.py — self-contained: serves the bundled UI + ADK agent API behind VeIdentity OAuth2. Self-contains the two adaptations above so it runs on the released veadk-python>=0.5.39 (the framework fixes above land them in veadk frontend for the next release).
  • agents/sso_demo_agent/, requirements.txt, .env.example, .dockerignore.
  • README.zh.md + README.mdfully non-interactive, copy-paste deploy: non-interactive veadk agentkit config (account fields auto-create; runtime_envs merge) → launch → set callback → deploy.

Access note

The runtime key currently only supports the header location (CreateRuntime's ApiKeyLocation accepts only header), so browser access uses a header-injecting extension (e.g. ModHeader) — documented in the README.

Test plan

  • ruff check / ruff format --check clean on changed files; no new pyright errors (the 4 reported are pre-existing). markdownlint clean on both READMEs.
  • Via the real veadk frontend (both framework fixes): /?gw=... injects the querystring into asset URLs; /list-apps with a non-JWT Authorization returns 302 (login) instead of Invalid JWT format; a 3-part JWT is still validated as a user token.
  • Non-interactive veadk agentkit config verified to run without prompts and write a valid agentkit.yaml.
  • Example deployed end-to-end to an AgentKit runtime: /, /web/auth-config, /oauth2/login (302 to the user pool), assets, and post-login /list-apps all verified.

🤖 Generated with Claude Code

Deploy the VeADK web UI together with VeIdentity SSO to an AgentKit runtime.
The self-contained app.py serves the bundled UI + agent API behind VeIdentity
OAuth2, with two adaptations for the AgentKit gateway:

- strips the gateway key from the Authorization header before the SSO
  middleware runs, so SSO falls back to its session cookie instead of failing
  with "Invalid JWT format" (the gateway forwards its key in Authorization,
  which the middleware would otherwise try to decode as a user JWT);
- forwards the page querystring onto /assets/* URLs, for gateways configured
  to take the key from the query string.

Runs on stock veadk-python>=0.5.39. Bilingual README with paste-able deploy
commands (config -> launch -> set callback -> deploy -> add header in browser).
Two changes so `veadk frontend` works behind a gateway (e.g. an AgentKit
runtime) that authenticates every request with a key and forwards the
Authorization header to the app:

- cli_frontend: when serving the built UI, forward the page's querystring onto
  the /assets/* URLs, so a browser behind a query-string gateway carries the key
  on subresource requests too. Assets are mounted explicitly and a SPA fallback
  renders the injected shell, registered after the API routes.
- oauth2 middleware: ignore a non-JWT Authorization bearer (unless token
  introspection is enabled) so authentication falls back to the session cookie
  instead of failing with "Invalid JWT format" when the gateway puts its opaque
  key in Authorization. A genuine user JWT is left untouched.
Replace the interactive `veadk agentkit config` step with the non-interactive
flag form (account-specific fields auto-create when omitted; runtime_envs are
merged), so the whole deploy is copy-paste: config -> launch -> set the callback
-> deploy. Note that the gateway adaptations are built into `veadk frontend`
from the next release.
@yaozheng-fang yaozheng-fang force-pushed the example/sso-frontend-on-agentkit branch from 298c7b8 to 7adaa53 Compare June 15, 2026 06:11
@yaozheng-fang yaozheng-fang changed the title feat(examples): add sso_frontend_on_agentkit deploy example feat: run the VeADK web UI behind a key-auth API gateway (+ SSO AgentKit example) Jun 15, 2026
Only the two VeIdentity UIDs (OAUTH2_USER_POOL_ID / OAUTH2_USER_POOL_CLIENT_ID,
which hold the pool/client UIDs) go into --runtime_envs. Drop MODEL_AGENT_* (the
model is provided by the runtime) and the Volcengine AK/SK (the runtime uses its
service-role credentials for the VeIdentity API; AK/SK stay in .env only for the
local build & deploy). Also explain why OAUTH2_REDIRECT_URI is needed on the
runtime but not locally.
Verified end-to-end against an AgentKit runtime: the runtime has no usable role
credentials (the instance-metadata endpoint times out), so VeIdentity API calls
need AK/SK explicitly. Without them the container crashes on startup with
"User pool ... not found". Put VOLCENGINE_ACCESS_KEY/SECRET_KEY back into the
config command and fix the surrounding notes. The model stays out of
runtime_envs (the UI serves without it; the agent loads lazily).
@yaozheng-fang yaozheng-fang merged commit b1c8f78 into main Jun 15, 2026
13 of 14 checks passed
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.

2 participants