Skip to content

Add harness sample: JWT inbound auth + OAuth-protected gateway (Issue #1397)#1398

Merged
evandrofranco merged 3 commits intoawslabs:mainfrom
dhegde-aws:main
Apr 24, 2026
Merged

Add harness sample: JWT inbound auth + OAuth-protected gateway (Issue #1397)#1398
evandrofranco merged 3 commits intoawslabs:mainfrom
dhegde-aws:main

Conversation

@dhegde-aws
Copy link
Copy Markdown
Contributor

Description

Adds a sample notebook demonstrating AgentCore harness with end-to-end OAuth:

  • Inbound auth: CUSTOM_JWT on the harness, backed by a Cognito user pool
  • Outbound auth: outboundAuth.oauth with CLIENT_CREDENTIALS grant to an
    AgentCore Gateway, via an OAuth2 credential provider in AgentCore Identity

Architecture:

  • User Auth Pool (Cognito, USER_PASSWORD_AUTH) for harness inbound auth
  • M2M Pool (Cognito, client_credentials) for gateway outbound auth
  • OAuth2 credential provider in AgentCore Identity
  • Lambda target behind AgentCore Gateway with GATEWAY_IAM_ROLE
  • harness with CUSTOM_JWT inbound + outboundAuth.oauth to gateway

Files:

  • harness_oauth_gateway.ipynb — main notebook (25 cells)
  • utils/setup_helpers.py — idempotent infra setup and cleanup functions
  • utils/lambda_function_code.py — order management Lambda handler
  • images/architecture.jpg — architecture diagram

All setup is idempotent and re-runnable. Cleanup discovers resources by name and skips gracefully if not found.

Amazon Bedrock AgentCore Samples Pull Request

Important

  1. We strictly follow a issue-first approach, please first open an issue relating to this Pull Request.
  2. Once this Pull Request is ready for review please attach review ready label to it. Only PRs with review ready will be reviewed.

Issue number: 1397

Concise description of the PR

Adds a new sample notebook for AgentCore harness with JWT inbound auth and
OAuth-protected gateway outbound auth, because there is no existing sample
showing the end-to-end CUSTOM_JWT + outboundAuth.oauth pattern with two
Cognito pools (user auth + M2M client credentials).

User experience

Before: No sample exists for harness OAuth inbound/outbound auth.
Developers must piece together docs for harness, gateway, identity, and
Cognito to wire up JWT-protected agent invocation with OAuth-protected
tool calls.

After: A single notebook walks through the full auth chain — from
creating Cognito pools, to configuring CUSTOM_JWT on the harness, to
invoking with a bearer token and watching the harness automatically
fetch M2M tokens for the gateway. All infra setup is in helper functions;
the notebook focuses on the harness auth config. Everything is idempotent
and includes cleanup.

Checklist

  • I have reviewed the contributing guidelines
  • Add your name to CONTRIBUTORS.md
  • Have you checked to ensure there aren't other open Pull Requests for the same update/change?
  • Are you uploading a dataset?
  • Have you documented Introduction, Architecture Diagram, Prerequisites, Usage, Sample Prompts, and Clean Up steps in your example README?
  • I agree to resolve any issues created for this example in the future.
  • I have performed a self-review of this change
  • Changes have been tested
  • Changes are documented

Acknowledgment

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

auth and OAuth-protected gateway outbound auth.

Architecture:
- User Auth Pool (Cognito, USER_PASSWORD_AUTH) for harness inbound auth
- M2M Pool (Cognito, client_credentials) for gateway outbound auth
- OAuth2 credential provider in AgentCore Identity
- Lambda target behind AgentCore Gateway with GATEWAY_IAM_ROLE
- harness with CUSTOM_JWT inbound + outboundAuth.oauth to gateway

Files:
- harness_oauth_gateway.ipynb — main notebook (25 cells)
- utils/setup_helpers.py — idempotent infra setup and cleanup functions
- utils/lambda_function_code.py — order management Lambda handler
- images/architecture.jpg — architecture diagram

All setup is idempotent and re-runnable. Cleanup discovers resources
by name and skips gracefully if not found.
@review-notebook-app
Copy link
Copy Markdown

Check out this pull request on  ReviewNB

See visual diffs & provide feedback on Jupyter Notebooks.


Powered by ReviewNB

@github-actions github-actions Bot added the 01-tutorials 01-tutorials label Apr 24, 2026
@github-actions
Copy link
Copy Markdown

Latest scan for commit: 95805c6 | Updated: 2026-04-24 14:01:30 UTC

Security Scan Results

Scan Metadata

  • Project: ASH
  • Scan executed: 2026-04-24T14:01:13+00:00
  • ASH version: 3.0.0

Summary

Scanner Results

The table below shows findings by scanner, with status based on severity thresholds and dependencies:

Column Explanations:

Severity Levels (S/C/H/M/L/I):

  • Suppressed (S): Security findings that have been explicitly suppressed/ignored and don't affect the scanner's pass/fail status
  • Critical (C): The most severe security vulnerabilities requiring immediate remediation (e.g., SQL injection, remote code execution)
  • High (H): Serious security vulnerabilities that should be addressed promptly (e.g., authentication bypasses, privilege escalation)
  • Medium (M): Moderate security risks that should be addressed in normal development cycles (e.g., weak encryption, input validation issues)
  • Low (L): Minor security concerns with limited impact (e.g., information disclosure, weak recommendations)
  • Info (I): Informational findings for awareness with minimal security risk (e.g., code quality suggestions, best practice recommendations)

Other Columns:

  • Time: Duration taken by each scanner to complete its analysis
  • Action: Total number of actionable findings at or above the configured severity threshold that require attention

Scanner Results:

  • PASSED: Scanner found no security issues at or above the configured severity threshold - code is clean for this scanner
  • FAILED: Scanner found security vulnerabilities at or above the threshold that require attention and remediation
  • MISSING: Scanner could not run because required dependencies/tools are not installed or available
  • SKIPPED: Scanner was intentionally disabled or excluded from this scan
  • ERROR: Scanner encountered an execution error and could not complete successfully

Severity Thresholds (Thresh Column):

  • CRITICAL: Only Critical severity findings cause scanner to fail
  • HIGH: High and Critical severity findings cause scanner to fail
  • MEDIUM (MED): Medium, High, and Critical severity findings cause scanner to fail
  • LOW: Low, Medium, High, and Critical severity findings cause scanner to fail
  • ALL: Any finding of any severity level causes scanner to fail

Threshold Source: Values in parentheses indicate where the threshold is configured:

  • (g) = global: Set in the global_settings section of ASH configuration
  • (c) = config: Set in the individual scanner configuration section
  • (s) = scanner: Default threshold built into the scanner itself

Statistics calculation:

  • All statistics are calculated from the final aggregated SARIF report
  • Suppressed findings are counted separately and do not contribute to actionable findings
  • Scanner status is determined by comparing actionable findings to the threshold
Scanner S C H M L I Time Action Result Thresh
bandit 0 0 0 0 5 0 763ms 0 PASSED MED (g)
cdk-nag 0 0 0 0 0 0 27.8s 0 PASSED MED (g)
cfn-nag 0 0 0 0 0 0 6ms 0 PASSED MED (g)
checkov 0 0 0 0 0 0 4.5s 0 PASSED MED (g)
detect-secrets 0 0 0 0 0 0 727ms 0 PASSED MED (g)
grype 0 0 0 0 0 0 35.4s 0 PASSED MED (g)
npm-audit 0 0 0 0 0 0 196ms 0 PASSED MED (g)
opengrep 0 0 0 0 0 0 <1ms 0 SKIPPED MED (g)
semgrep 0 0 0 0 0 0 <1ms 0 MISSING MED (g)
syft 0 0 0 0 0 0 2.0s 0 PASSED MED (g)

Copy link
Copy Markdown
Contributor

@evandrofranco evandrofranco left a comment

Choose a reason for hiding this comment

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

OK

@evandrofranco evandrofranco merged commit d846543 into awslabs:main Apr 24, 2026
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

01-tutorials 01-tutorials

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants