Commit 0b743db
feat: runtime inbound auth (Custom JWT) for agents (#657)
* test: add integ tests for evaluator and online-eval resource lifecycle
* test: remove redundant levels/rating-scales section
* refactor: type readProjectConfig return as AgentCoreProjectSpec
* refactor(schema): extract shared auth schemas to auth.ts
Move JWT authorizer schemas (GatewayAuthorizerTypeSchema,
CustomJwtAuthorizerConfigSchema, etc.) from mcp.ts into a dedicated
auth.ts module. Add RuntimeAuthorizerTypeSchema (AWS_IAM | CUSTOM_JWT)
for Runtime resources. The resource-agnostic AuthorizerConfigSchema
replaces GatewayAuthorizerConfigSchema (kept as deprecated alias).
* refactor(tui): extract JWT config components to shared module
Move JWT authorizer TUI components from AddGatewayScreen into
src/cli/tui/components/jwt-config/:
- types.ts: shared types and constants
- CustomClaimForm.tsx: single claim tab-field form
- CustomClaimsManager.tsx: CRUD for custom claims
- JwtConfigInput.tsx: main JWT config component
- useJwtConfigFlow.ts: hook for JWT wizard state management
AddGatewayScreen now uses the shared useJwtConfigFlow hook and
JwtConfigInput component.
* refactor(primitives): extract shared auth utilities from GatewayPrimitive
Extract buildAuthorizerConfigFromJwtConfig and createManagedOAuthCredential
into auth-utils.ts so they can be reused by AgentPrimitive for Runtime
inbound auth. GatewayPrimitive now imports these shared functions instead
of defining them as private methods.
* refactor(validation): extract shared JWT authorizer validation
Extract JWT validation logic from validateAddGatewayOptions into a
reusable validateJwtAuthorizerOptions function in auth-options.ts.
This enables reuse by the agent command for Runtime inbound auth.
* feat(schema): add authorizerType and authorizerConfiguration to AgentEnvSpec
Add Runtime inbound auth fields to the agent schema. Supports AWS_IAM
(default) and CUSTOM_JWT authorizer types with cross-field validation
ensuring authorizerConfiguration is required for CUSTOM_JWT.
* feat(tui): add inbound auth step to BYO agent wizard
Add authorizerType selection and JWT config flow to the BYO agent
creation wizard. Users can choose between AWS_IAM (default) and
CUSTOM_JWT with full OIDC configuration including discovery URL,
audience/client/scope constraints, and custom claims.
* feat(cli): wire Runtime inbound auth to AgentPrimitive and CLI flags
Add --authorizer-type, --discovery-url, --allowed-audience, --allowed-clients,
--allowed-scopes, --custom-claims, --client-id, and --client-secret CLI flags
to `agentcore add agent`. Wire auth options through to the BYO path for
authorizer configuration building and OAuth credential auto-creation.
Add validation for agent auth options reusing shared validateJwtAuthorizerOptions.
* fix(tui): add missing OAuth credential creation in BYO agent path
The TUI BYO path silently discarded OAuth client credentials when
CUSTOM_JWT was selected. Now calls createManagedOAuthCredential to
persist the credential and write secrets to .env, matching the CLI path.
* test(integ): add integration tests for agent inbound auth CLI flags
Tests adding BYO agents with CUSTOM_JWT authorizer via CLI, including:
- Audience constraints, client/scope constraints, custom claims
- OAuth credential auto-creation with .env secrets
- Default AWS_IAM behavior
- Validation of missing discovery URL, missing constraints, misplaced client credentials
* feat(tui): add inbound auth to all agent paths (create, BYO, import)
Add authorizerType and jwtConfig steps to the GenerateWizard (create/template
path) and import path, matching existing BYO path support. Auth config is
persisted to agentcore.json via schema-mapper. OAuth credential is auto-created
for CUSTOM_JWT in all three paths.
Also fix request header allowlist TextInput to allow empty submission (skip),
and add E2E test for BYO custom JWT auth flow with real Cognito.
* fix: wire auth config through useCreateFlow (agentcore create path)
The create command's useCreateFlow.ts duplicates agent creation logic
from useAddAgent.ts but was missing authorizerType/jwtConfig in the
GenerateConfig, import params, and OAuth credential creation for all
three sub-paths (create, import, BYO).
* feat(invoke): add bearer token auth for CUSTOM_JWT agents
Add thin HTTP invoke client that bypasses SigV4 when a bearer token is
provided, supporting agents configured with CUSTOM_JWT authorizers.
- Add --bearer-token CLI flag to invoke command
- Add bearer token input to invoke TUI (auto-prompts for CUSTOM_JWT agents,
press T to set/change token in chat mode)
- Build invokeWithBearerToken and invokeWithBearerTokenStreaming HTTP clients
with SSE parsing matching the SDK streaming pattern
- Wire bearerToken through InvokeOptions, useInvokeFlow, and InvokeScreen
- Expose authorizerType in invoke flow config for agent auth detection
* revert: remove allowEmpty from requestHeaderAllowlist TextInputs
Being handled separately by another agent.
* feat(invoke): auto-fetch OAuth token for CUSTOM_JWT agents
Extract shared OAuth client_credentials flow from fetchGatewayToken into
oauth-token.ts (fetchOAuthToken), then add fetchRuntimeToken for agents.
TUI: auto-fetches token on agent selection for CUSTOM_JWT agents. Shows
fetch status in header (fetching/fetched/error). Press R to refresh, T
for manual entry. Falls back to manual input on fetch failure.
CLI: auto-fetches token when --bearer-token is not provided and agent
has CUSTOM_JWT auth. Surfaces clear error with manual fallback hint.
* fix(invoke): silently skip token auto-fetch when no OAuth credential exists
Add canFetchRuntimeToken pre-check that verifies the managed OAuth
credential and client secret exist before attempting the fetch. When
credentials aren't configured, the TUI shows the manual token prompt
(T key) without an error, and the CLI proceeds without a token.
* fix(invoke): use Ctrl+T and Ctrl+R for token shortcuts
Plain T/R conflict with typing those characters in chat mode.
* refactor(invoke): replace key shortcuts with dedicated token screen
Instead of Ctrl+T/Ctrl+R shortcuts in chat mode (which conflict with
terminal input), show a dedicated bearer token screen before chat when
a CUSTOM_JWT agent is selected. The screen auto-populates with a
fetched token if OAuth credentials are configured, otherwise shows an
empty field for the user to paste into. Enter confirms, Esc skips.
* feat(fetch): extend fetch access to support agents
Add --type flag to agentcore fetch access (gateway | agent). When
--type agent is used, performs OAuth client_credentials flow for the
agent's CUSTOM_JWT credential instead of a gateway.
Usage: agentcore fetch access --type agent --name MyAgent [--json]
* feat(tui): extend fetch access screen to support both gateways and agents
The TUI fetch access screen previously only listed gateways. Now it loads
both gateways and agents, shows the resource type in the picker, and
dispatches to the correct token fetcher based on resource type.
* fix(tui): handle agent fetch access gracefully without OAuth credentials
For agents, use canFetchRuntimeToken pre-check before attempting token
fetch. AWS_IAM agents show auth guidance without fetching. CUSTOM_JWT
agents without managed credentials show a message instead of erroring.
* fix(tui): gate auth screen behind advanced config and fix lint errors
Auth type selection (CUSTOM_JWT vs AWS_IAM) now only appears when the
user selects advanced config in the generate wizard and BYO agent paths.
Skipping advanced goes directly to confirm with default AWS_IAM auth.
Also fixes 4 lint errors: unused import, optional chain preferences,
and unsafe argument type cast.
* fix(tui): fetch agent token directly instead of pre-check in fetch access
The canFetchRuntimeToken pre-check swallows all errors and returns false,
which incorrectly showed "no managed OAuth credential" even when one was
configured. For the fetch access screen (explicit user action), call
fetchRuntimeToken directly and let real errors surface in the error phase.
The pre-check remains in the invoke flow where silent skip is desired.
* fix(fetch): use _CLIENT_SECRET suffix when reading OAuth secret from env
The write path stores secrets as AGENTCORE_CREDENTIAL_{NAME}_CLIENT_SECRET
but the read path was looking for AGENTCORE_CREDENTIAL_{NAME} without the
suffix, causing token fetch to always fail with "Client secret not found".
* fix(ci): add @aws-sdk/client-cognito-identity-provider dev dependency
The e2e test for BYO custom JWT imports this SDK but it wasn't in package.json,
causing typecheck to fail in CI.
* style: fix prettier formatting across all changed files
* fix: wire auth config through handleCreatePath for template agents
handleCreatePath was silently dropping auth options (authorizerType,
discoveryUrl, etc.) because generateConfig didn't include them. This
meant `agentcore add agent --type create --authorizer-type CUSTOM_JWT`
would succeed but write agentcore.json without auth fields.
Fixes: pass authorizerType and jwtConfig into generateConfig so
mapGenerateConfigToAgent picks them up. Also fixes misleading comment
in validate.ts that said auth validation was BYO-only.
---------
Co-authored-by: Harrison Weinstock <hkobew@amazon.com>1 parent f24609f commit 0b743db
54 files changed
Lines changed: 3541 additions & 1379 deletions
File tree
- e2e-tests
- integ-tests
- src
- cli
- aws
- commands
- add
- __tests__
- fetch
- invoke
- operations
- agent
- generate
- import
- fetch-access
- __tests__
- primitives
- __tests__
- tui
- components/jwt-config
- screens
- agent
- create
- fetch-access
- __tests__
- generate
- __tests__
- invoke
- mcp
- schema/schemas
- __tests__
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
0 commit comments