Skip to content

feat: add API Key and No Auth support for API Gateway targets#514

Merged
tejaskash merged 2 commits intomainfrom
feat/api-gateway-auth
Mar 9, 2026
Merged

feat: add API Key and No Auth support for API Gateway targets#514
tejaskash merged 2 commits intomainfrom
feat/api-gateway-auth

Conversation

@aidandaly24
Copy link
Contributor

Description

Add API Key and No Auth support for API Gateway targets, plus fix the confirm-step-skip bug for credential creation flows.

Auth Types

API Gateway targets now support three authorization modes in both the TUI wizard and CLI:

  • IAM (default): No outboundAuth — CDK uses GATEWAY_IAM_ROLE
  • API Key: outboundAuth: { type: 'API_KEY', credentialName: '...' } — shows existing API key credentials + "Create new" option
  • No Auth: outboundAuth: { type: 'NONE' } — CDK falls back to GATEWAY_IAM_ROLE
  • OAuth: Rejected by schema and CLI validation (not supported for API Gateway targets per AWS docs)

Wizard Resume Pattern

After credential creation (via AddIdentityScreen), the wizard now resumes at the confirm step with state preserved — instead of skipping confirm and creating the target immediately. This fixes a pre-existing UX issue that affected both mcpServer (OAuth) and apiGateway (API Key) flows. Implemented via initialConfig/initialStep props on the wizard hook and screen.

Deploy Pipeline Fix

The TUI deploy path (useCdkPreflightuseDeployFlow) was only passing OAuth credential ARNs to buildDeployedState, silently dropping API key credential ARNs. Renamed oauthCredentialsallCredentials and ensured the combined credentials object (API key + OAuth) is passed through.

Changes by file

  • mcp.ts (schema): Reject only OAuth for apiGateway (was rejecting all outboundAuth)
  • validate.ts: Accept --outbound-auth api-key (with --credential-name) and none, reject oauth
  • validate.test.ts: 3 new tests replacing 1 blanket rejection test
  • GatewayTargetPrimitive.ts: Add api_key to outboundAuthMap, pass outboundAuth in apiGateway CLI dispatch and createApiGatewayTarget
  • types.ts: Add api-gateway-auth step, API_GATEWAY_AUTH_OPTIONS, outboundAuth on ApiGatewayTargetConfig (narrowed to 'API_KEY' | 'NONE')
  • useAddGatewayTargetWizard.ts: Accept initialConfig/initialStep, add api-gateway-auth to step sequence, add setApiGatewayAuth setter
  • AddGatewayTargetScreen.tsx: Auth step UI (WizardSelect + credential list), initialConfig/initialStep/existingApiKeyCredentialNames props, confirm narrowing includes outboundAuth, ConfirmReview shows "IAM (default)" when no auth selected
  • AddGatewayTargetFlow.tsx: resumeConfig/resumeStep on FlowState, apiKeyCredentialNames, resume wizard after credential creation, conditional initialType for identity screen
  • useCdkPreflight.ts: Rename oauthCredentialsallCredentials, set to combined credentials
  • useDeployFlow.ts: Rename oauthCredentialsallCredentials

Related Issues

Companion to CDK PR: feat/api-gateway-auth on agentcore-l3-cdk-constructs

Type of Change

  • Bug fix
  • New feature
  • Breaking change
  • Documentation update
  • Other (please describe):

Testing

How have you tested the change?

  • Unit tests: 163 tests pass (3 new validation tests for auth type acceptance/rejection)
  • TypeScript compilation clean (npx tsc --noEmit)
  • ESLint + Prettier clean
  • Manual TUI testing: API Gateway target with IAM (default), API Key (existing credential), API Key (create new credential), No Auth
  • Manual TUI testing: mcpServer OAuth flow with wizard resume (confirm step now shown after credential creation)
  • Manual end-to-end: deployed API Gateway target with API Key auth, verified tool discovery and invocation
  • Verified deployed-state.json correctly persists API key credential ARNs after deploy

Checklist

  • I have read the CONTRIBUTING document
  • I have added any necessary tests that prove my fix is effective or my feature works
  • I have updated the documentation accordingly
  • I have added an appropriate example to the documentation to outline the feature, or no new docs are needed
  • My changes generate no new warnings
  • Any dependent changes have been merged and published

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the
terms of your choice.

@aidandaly24 aidandaly24 requested a review from a team March 9, 2026 01:40
@github-actions github-actions bot added the size/l PR size: L label Mar 9, 2026
@github-actions
Copy link
Contributor

github-actions bot commented Mar 9, 2026

Coverage Report

Status Category Percentage Covered / Total
🔵 Lines 42.76% 3726 / 8713
🔵 Statements 42.35% 3931 / 9282
🔵 Functions 44.31% 737 / 1663
🔵 Branches 44.74% 2431 / 5433
Generated in workflow #903 for commit 2c9c823 by the Vitest Coverage Report Action

- Add api-gateway-auth wizard step with IAM/API Key/No Auth options
- Implement wizard resume pattern: after credential creation, wizard
  resumes at confirm step with state preserved via initialConfig/initialStep
- Fix confirm-step-skip bug for both mcpServer and apiGateway flows
- Schema/validation: reject only OAuth for apiGateway, accept API Key and None
- Pass outboundAuth through in CLI dispatch and createApiGatewayTarget
- Narrow ApiGatewayTargetConfig.outboundAuth.type to 'API_KEY' | 'NONE'
- Add 3 new validation tests
Rename oauthCredentials to allCredentials in useCdkPreflight and
useDeployFlow — the TUI deploy path was only passing OAuth credentials
to buildDeployedState, silently dropping API key credential ARNs.
The CDK construct needs these ARNs to wire API key credentials to
gateway targets.
@aidandaly24 aidandaly24 force-pushed the feat/api-gateway-auth branch from bf4f45d to 2c9c823 Compare March 9, 2026 14:57
@github-actions github-actions bot removed the size/l PR size: L label Mar 9, 2026
@github-actions github-actions bot added the size/m PR size: M label Mar 9, 2026
Copy link
Contributor

@tejaskash tejaskash left a comment

Choose a reason for hiding this comment

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

LGTM 🚀

@tejaskash tejaskash merged commit 763b937 into main Mar 9, 2026
19 checks passed
@tejaskash tejaskash deleted the feat/api-gateway-auth branch March 9, 2026 15:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size/m PR size: M

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants