Skip to content

feat: add OAuth2 provider support to identity - #1856

Open
nborges-aws wants to merge 1 commit into
refactorfrom
identity-oauth-support
Open

feat: add OAuth2 provider support to identity#1856
nborges-aws wants to merge 1 commit into
refactorfrom
identity-oauth-support

Conversation

@nborges-aws

Copy link
Copy Markdown
Contributor

Description

Adds command-line CRUDL for Identity OAuth2 credential providers:

  • identity oauth2-credential-provider create
  • identity oauth2-credential-provider get
  • identity oauth2-credential-provider list
  • identity oauth2-credential-provider update
  • identity oauth2-credential-provider delete

Supports two configuration paths:

  • Guided CustomOauth2: --client-id, --discovery-url, and --authorization-server-metadata build the provider config from scalar flags. Only valid with --vendor CustomOauth2
  • Provider configuration passthrough: --provider-configuration <json> accepts the complete SDK config union for any of the supported vendors. The CLI merges the resolved secret into the vendor config before sending

Secret handling follows the same pattern established with api-key-credential-provider:

  • --client-secret is source-aware (inline, file://path, or - for stdin) and marked sensitive for log redaction
  • --client-secret-reference '{"secretId":"...","jsonKey":"..."}' for external Secrets Manager secrets
  • The two are mutually exclusive

This PR also generalizes parseSecretReference to a shared identity utility (src/handlers/identity/parser.tsx) parameterized by flag name.

Related Issue

Closes #

Documentation PR

Type of Change

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

Testing

Manual tested cli by invoking all commands, both happy-path and negative validation. Expected results across the board. Additionally ran the full test suite, against latest HEAD after rebasing refactor branch:

  • bun test (402 pass, 0 fail)
  • bun run typecheck clean
  • bun run build

How have you tested the change?

  • I ran npm run test:unit and npm run test:integ
  • I ran npm run typecheck
  • I ran npm run lint
  • If I modified src/assets/, I ran npm run test:update-snapshots and committed the updated snapshots

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.

@github-actions github-actions Bot added the agentcore-harness-reviewing AgentCore Harness review in progress label Jul 29, 2026
@codecov-commenter

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 87.44076% with 53 lines in your changes missing coverage. Please review.
✅ Project coverage is 94.86%. Comparing base (9505185) to head (b5c46d3).

Files with missing lines Patch % Lines
...entity/oauth2-credential-provider/update/index.tsx 76.22% 34 Missing ⚠️
...entity/oauth2-credential-provider/create/index.tsx 85.71% 19 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##           refactor    #1856      +/-   ##
============================================
- Coverage     95.26%   94.86%   -0.41%     
============================================
  Files           176      182       +6     
  Lines          8202     8585     +383     
============================================
+ Hits           7814     8144     +330     
- Misses          388      441      +53     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@github-actions github-actions Bot removed the agentcore-harness-reviewing AgentCore Harness review in progress label Jul 29, 2026
flag(
"provider-configuration",
"complete OAuth2 provider configuration JSON (alternative to guided flags)",
z.string().optional(),

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think --provider-configuration also needs to be marked sensitive in both create and update. This flag accepts the complete SDK config, which can include clientSecret. I tested that form and the plaintext value was written to ~/.agentcore/logs while --client-secret was redacted. Marking both flag definitions sensitive should cover it.

try {
parsed = JSON.parse(raw);
} catch (error) {
throw new TypeError(

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This shared parser previously threw InputValidationError, but the move changes it to TypeError. The new OAuth handlers do the same. I reproduced a conflicting-secret invocation and the log classified it as source: "internal". These user-input failures should remain InputValidationError.

vendorConfig.clientSecretConfig = clientSecretConfig;
vendorConfig.clientSecretSource = clientSecretSource;
oauth2ProviderConfigInput = config;
} else {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The two configuration modes are not fully enforced here. Without --provider-configuration, this always builds customOauth2ProviderConfig, even for --vendor GithubOauth2, and guided Custom OAuth also allows the required discovery configuration to be omitted. I reproduced the resulting service validation error. We should require provider configuration for non-Custom vendors and one discovery form for the guided Custom path, including the equivalent update validation.

),
flag(
"client-secret-reference",
'external secret reference JSON: {"secretId":"<arn>","jsonKey":"<key>"}',

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

does this need to be sensitive or is it strictly pointers to secrets?

],
handle: async (ctx, flags) => {
if (!flags.name) {
throw new TypeError("required option '--name <name>' not specified");

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

should we throw modeled input validation errors here? (same with below)

"--provider-configuration and guided flags (--client-id, --discovery-url, --authorization-server-metadata) are mutually exclusive",
);
}
if (flags["discovery-url"] && flags["authorization-server-metadata"]) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

same question for errors here.

throw new TypeError(`--${flagName} must be a JSON object with "secretId" and "jsonKey"`);
}

const obj = parsed as Record<string, unknown>;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

could we simplify this with a strict zod schema? Something like:

 const secretReferenceSchema = z
    .object({
      secretId: z.string().min(1),
      jsonKey: z.string().min(1),
    })
    .strict(); 

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.

4 participants