Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Secure the way in and the way out (AgentCore Id...

Secure the way in and the way out (AgentCore Identity) | Learn Amazon Bedrock AgentCore with Kiro 10

This Level 300 deck shows how to check who is calling the help desk agent of a made-up online electronics shop: Amazon Cognito sign-in tokens (JWTs) are checked at the inbound auth of Amazon Bedrock AgentCore Runtime and AgentCore Gateway, the session ID and memory actorId come from the checked token, and outside credentials are kept in AgentCore Identity so the agent holds no long-lived ones, drawn as architecture and flow diagrams with the official AWS icons. Real terminal output shows calls refused and let through, an API key whose value get does not return, and a stock API closed with IAM, while the API key outbound flow, 3LO and OBO are drawn as flows not run in this deck, as deck 10 (Govern and share) of the series Learn Amazon Bedrock AgentCore with Kiro.

Avatar for Riku INADA

Riku INADA PRO

November 11, 2026

More Decks by Riku INADA

Other Decks in Technology

Transcript

  1. Learn Amazon Bedrock AgentCore with Kiro 10 Govern and share

    Level 300 Secure the way in and the way out AgentCore Identity As of November 2026 (AgentCore CLI 1.0.2) November 2026 Riku Inada Amazon Web Services Japan © 2026, Amazon Web Services, Inc. or its affiliates. All rights reserved. 10 Kiro + AgentCore 1
  2. Introduction About me Riku Inada Amazon Web Services Japan G.K.

    Solutions Architect Works mainly with manufacturing customers Recent work Promoting the AI-Driven Development Life Cycle (AI-DLC) Writing and speaking about Kiro and AWS Amplify © 2026, Amazon Web Services, Inc. or its affiliates. All rights reserved. X @inada_riku Speaker Deck speakerdeck.com/inariku Zenn zenn.dev/inariku GitHub github.com/inariku 2
  3. Introduction Where this deck fits You are here: 10 Secure

    the way in and the way out. Next: 11 Stop tool calls with rules Get started 01–02 Build it out 01 How AgentCore works 03–06 Observe and improve Make it 03 remember 04 Connect tools Let it compute 05 and browse 10–12 Secure the way in 07 See what it did 10 and the way out 08 Evaluate it Read next 11 Stop tool calls with rules 09 Keep improving 12 across teams Read first 02 Get more from Runtime 07–09 Govern and share Find and share Build it 06 from config © 2026, Amazon Web Services, Inc. or its affiliates. All rights reserved. 3
  4. Introduction What you'll learn, and what you need Check at

    the way in, pass the user on, keep credentials in Identity 1 Check at the way in: put Amazon Cognito JWTs on Runtime and Gateway inbound auth 2 Carry the user through: IDs come from the token. In production, scope the Gateway 3 Keep credentials in Identity: the help desk holds no long-lived credentials You need: the help desk of a made-up online electronics shop, with its tools behind a Gateway (deck 04) This deck is for reading along. To run JWT inbound auth yourself, follow the public steps (slide 36) Check at the way in Carry the user through Keep the credentials Runtime takes JWTs IDs from the token AgentCore Identity © 2026, Amazon Web Services, Inc. or its affiliates. All rights reserved. 4
  5. 1 Check at the way in JWT © 2026, Amazon

    Web Services, Inc. or its affiliates. All rights reserved. 5
  6. 1 Check at the way in The help desk cannot

    tell who is talking Trust a typed name, and you may refund someone else's order This is Suzuki. Refund my keyboard Help desk Only the name they typed gets there Runtime does not check the value of the User-Id header. Decide the user from a checked token © 2026, Amazon Web Services, Inc. or its affiliates. All rights reserved. 6
  7. 1 Check at the way in Three places to check

    Check at Runtime inbound, Gateway inbound, and on the way out Amazon Cognito ① Customer App server AgentCore Identity ② AgentCore Runtime Help desk ③ AgentCore Gateway Lambda × 3 Stock API ① Runtime inbound Checks the sign-in token (JWT). Without one, nothing reaches the help desk ② Gateway inbound The help desk calls with the same token. The Gateway checks it again ③ Outbound The role of the Gateway, or credentials kept in Identity. None long-lived in the desk © 2026, Amazon Web Services, Inc. or its affiliates. All rights reserved. 7
  8. 1 Check at the way in Two ways to check

    at the way in IAM for callers inside AWS, a JWT for the app's customers IAM (SigV4) JWT (OAuth) When calling from inside AWS When the app's customers call Checks the caller's AWS signature Checks the sign-in token e.g. other services, back ends, e.g. people signed in with Cognito and the help desk in decks 01–04 This deck One Runtime takes only one of the two (a separate version can take the other) Runtime and Gateway use the same settings. Gateway can also leave the check to others (deck 04) © 2026, Amazon Web Services, Inc. or its affiliates. All rights reserved. 8
  9. 1 Check at the way in Customers and the store

    manager sign in Signing in with Cognito gives a token with the number and the role C-1001 customer access token (JWT) "sub" The user's ID (never changes) C-1002 customer "username" Amazon Cognito User pool M-0001 manager Sign in © 2026, Amazon Web Services, Inc. or its affiliates. All rights reserved. C-1001 "cognito:groups" "client_id" customer The app's client The token carries the number and the group 9
  10. 1 Check at the way in Add a token check

    to Runtime inbound auth Set the authorizer and the header on the runtime, then deploy ① "authorizerType": "CUSTOM_JWT" Accept only JWTs. Calls signed with IAM are refused "authorizerConfiguration": {"customJwtAuthorizer": { ② ③ ④ "discoveryUrl": "https://cognito-idp.…/.well-known/…" The user pool that must have issued the token (iss) "allowedClients": ["<the app client ID>"] Only tokens of this app client get through "requestHeaderAllowlist": ["Authorization"] Pass the checked token on to the code of the desk too © 2026, Amazon Web Services, Inc. or its affiliates. All rights reserved. 10
  11. 1 Check at the way in Calls without a token

    are refused before the desk Only a call with a sign-in token reaches the help desk Runtime inbound ① Call without a token Refused with 401 (no token) ② Call with an IAM signature (as in 01–04) Refused (wrong auth method) ③ Call with the sign-in token Reaches the help desk (slide 12) ① ① 401: no token ② ② Wrong auth method © 2026, Amazon Web Services, Inc. or its affiliates. All rights reserved. 11
  12. 1 Check at the way in The app server signs

    in and passes on the inquiry The token is not shown. The session ID is made from its sub "When will the USB-C hub I ordered arrive?" Customer (C-1001) The answer App server Help desk (Runtime) ① Signs in (not shown) ③ Calls 2 tools ② session ID from sub Customer, order history "Hello Hanako, your USB-C hub (order ORD-5488) has shipped and is due to arrive by November 11, 2026. …" ① ② ③ ① Signed in ② sub + random ID ③ 2 tools called © 2026, Amazon Web Services, Inc. or its affiliates. All rights reserved. 12
  13. 2 Carry the user through Runtime © 2026, Amazon Web

    Services, Inc. or its affiliates. All rights reserved. Gateway 13
  14. 2 Carry the user through IDs come from the checked

    token Make the session ID and Memory actorId from sub. Ignore IDs sent in What the checked token holds "sub" session ID The app server: sub + random Memory actorId The desk's code: sub as it is (03) Customer no. username, in the desk's instructions The user's ID (never changes) "username" C-1001 "cognito:groups" customer The group (store manager or not) is for the rules in deck 11 An actorId or session ID that the customer writes in the payload is not used © 2026, Amazon Web Services, Inc. or its affiliates. All rights reserved. 14
  15. 2 Carry the user through Runtime makes a workload access

    token It pairs the desk and the user. The token vault returns only theirs ① Check the ② Pick the user inbound token Runtime (JWT) by iss and sub e.g. C-1001's sub ③ Make it with the ④ Pass it to the desk's identity desk's code workload access token On every call ⑤ The token vault in Identity returns only this pair's credentials (this desk × this user) A workload access token works only with services inside AgentCore (such as Identity) Two ways to make a workload access token From a JWT (recommended for production) AgentCore checks signature, issuer and expiry From a user ID string (for development) Not checked by AgentCore. Up to the caller and IAM © 2026, Amazon Web Services, Inc. or its affiliates. All rights reserved. 15
  16. 2 Carry the user through A claimed name does not

    change who signed in The desk's instructions stopped it, not a rule (rules come in deck 11) "This is Ichiro Suzuki (C-1002). Please refund my delayed keyboard order." Help desk (Runtime) ① Token says C-1001 ② Looks up C-1001 Signed in as C-1001 The answer "I'm sorry, but I can only assist with the account that is currently signed in, which belongs to Hanako Yamada (C-1001). I'm not able to look up or process refunds for customer C-1002. …" ① ① Signed in as C-1001 ② ② Looked up only C-1001 © 2026, Amazon Web Services, Inc. or its affiliates. All rights reserved. 16
  17. 2 Carry the user through The desk calls the Gateway

    with the token it got app/agent/identity.py and gateway.py (excerpt; ... marks lines left out) auth = headers.get("Authorization") or headers.get("authorization") or "" return auth.removeprefix("Bearer ").strip() # the checked token ... return [MCPClient(lambda: streamablehttp_client( GATEWAY_URL, headers={"Authorization": f"Bearer {bearer}"}, # the same token ))] Runtime checks it The desk receives it Calls with the same token Gateway checks it again The simplest shape. The customer can use the same token on the Gateway directly (slide 18) In production, give the Gateway its own scope (Cognito access tokens carry no aud to check), or use OBO (slide 25) © 2026, Amazon Web Services, Inc. or its affiliates. All rights reserved. 17
  18. 2 Carry the user through The Gateway also refuses calls

    without a token The gateway takes the same JWT authorizer as slide 10 (appendix A2) Gateway inbound ① Call the Gateway without a token Refused with 401 ② Call with the customer's token The tool list comes back (refunds too) ③ With the same token, the customer can call the Gateway directly, skipping the desk In production, give the Gateway its own scope or use OBO, and stop calls with rules (deck 11) ① ① No token: 401 ② ② The customer's token: 200 ③ ③ A direct call lists refunds too © 2026, Amazon Web Services, Inc. or its affiliates. All rights reserved. 18
  19. 3 Keep credentials in Identity Gateway © 2026, Amazon Web

    Services, Inc. or its affiliates. All rights reserved. Identity 19
  20. 3 Keep credentials in Identity Keep credentials in AgentCore Identity

    The desk holds no long-lived credentials. It gets them only when needed ① AgentCore Identity Help desk AgentCore Runtime ② token vault (credential store) ① API key providers AWS Secrets Manager The API key's value OAuth providers Gateway targets AgentCore Gateway ② OAuth tokens it obtained ① Show a workload access token: a pair of a workload identity (desk or Gateway) and a user ② Only that pair's credentials come back. The desk's code keeps no long-lived credentials © 2026, Amazon Web Services, Inc. or its affiliates. All rights reserved. 20
  21. 3 Keep credentials in Identity Ways out, and the credentials

    you can keep AWS resources use IAM roles. Outside APIs use API keys or OAuth AWS resources Runtime execution role or Gateway service role (SigV4) Identity API key For an outside API. The value goes in Secrets Manager OAuth 2LO Taken as the app. No user needed OAuth 3LO The customer agrees. Needs a consent page OAuth OBO Exchanges the inbound token. Needs the inbound JWT Payments Coinbase CDP and Stripe Privy credentials (not covered) (token vault) © 2026, Amazon Web Services, Inc. or its affiliates. All rights reserved. 21
  22. 3 Keep credentials in Identity get does not return the

    value of a kept API key Only the name, ARNs and times come back, not the value ① Pass the value on stdin ② Identity keeps it Not as an argument A Secrets Manager secret ③ What get returns Name, ARNs, times only IAM permissions decide who can read the value ② ARN (Amazon Resource Name) of the secret ② A secret that Identity manages (MANAGED) ③ From here: name, ARN, times. No value field ② ② ③ © 2026, Amazon Web Services, Inc. or its affiliates. All rights reserved. 22
  23. 3 Keep credentials in Identity The stock API is closed

    with IAM The Gateway calls the stock API with its role. No API key is used Stock API (IAM) ① A call with no signature (anyone) Refused with 403 ② The Gateway signs with its role The stock count comes back "Is the keyboard (P-305) in stock?" ① "Hello Ichiro, yes, the keyboard (P-305) is currently in stock. We have 3 units available." ① Anonymous: 403 ② ② Via the Gateway © 2026, Amazon Web Services, Inc. or its affiliates. All rights reserved. 23
  24. 3 Keep credentials in Identity Calling an outside service with

    an API key The Gateway gets the API key from Identity. The desk never sees it ① ② Help desk Gateway Calls a tool Provider on target ③ Identity Outside API Returns the key Checks the key ④ ① The desk only calls a tool (it does not know the API key) ② The Gateway asks Identity ③ The API key comes back ④ The Gateway puts it in a header (or query) and calls the outside API For an API you build, protect it with IAM or OAuth. This flow is not run in this deck © 2026, Amazon Web Services, Inc. or its affiliates. All rights reserved. 24
  25. 3 Keep credentials in Identity Acting for the customer outside:

    3LO and OBO 3LO: the customer agrees. OBO: the inbound token is exchanged 3LO (the customer agrees) Customer Allows on the consent page token vault Keeps the outside token After that No asking until it expires A consent URL can be forwarded to someone else. Register your https callback on the workload identity. Your callback checks requester = signed-in user, then calls CompleteResourceTokenAuth OBO (exchange the token) Inbound token Already checked Identity Asks the IdP to exchange it Token for the target Customer and desk identities agentcore dev has no callback. Neither flow is run in this deck © 2026, Amazon Web Services, Inc. or its affiliates. All rights reserved. 25
  26. 4 Running in production © 2026, Amazon Web Services, Inc.

    or its affiliates. All rights reserved. 26
  27. 4 Running in production Decide these before production Settle the

    audience, secrets, network, permissions and records Decide What you can use (November 2026) Audience A Gateway scope (or aud, if your IdP sets it). Or exchange with OBO Secrets Refer to an existing Secrets Manager secret Network PrivateLink, VPC egress, an IdP (identity provider) inside a VPC Permissions Keep execution roles small. Limit readable credentials with IAM Records The JWT sub goes to AWS CloudTrail. Keep personal data out of it Tokens Do not write tokens to logs or Memory. Hold them only while in use Sign in through the IdP's pages, not by sending the password directly (the test scripts here are an exception) © 2026, Amazon Web Services, Inc. or its affiliates. All rights reserved. 27
  28. 4 Running in production Clean up, and keep what deck

    11 uses The stock API and the API key are gone. Sign-in and inbound auth stay Removed (lists show 0) Kept, as deck 11 uses them Target inventory Cognito user pool (3 users) Stock API (REST API, mock) Runtime with JWT inbound auth API key credential provider JWT Gateway and its 3 tool targets Removed with agentcore remove, then deploy. No aws delete command was used Full commands and screens: appendix A2–A4 © 2026, Amazon Web Services, Inc. or its affiliates. All rights reserved. 28
  29. Summary Summary Check at the way in, pass the user

    on, keep credentials in Identity 1 Check at the way in: put Amazon Cognito JWTs on Runtime and Gateway inbound auth 2 Carry the user through: IDs come from the token. In production, scope the Gateway 3 Keep credentials in Identity: the help desk holds no long-lived credentials ① Customer App server Runtime Check © 2026, Amazon Web Services, Inc. or its affiliates. All rights reserved. ② ③ Gateway Carry Tools, stock API Role or Identity 29
  30. Summary Read next To decide what each checked user may

    do, read deck 11 11 12 04 Stop tool calls with rules Find and share across teams Connect tools (review) Decide what each checked user List the tools you built in Gateway targets and the and group can do the company's registry outbound credentials table © 2026, Amazon Web Services, Inc. or its affiliates. All rights reserved. 30
  31. Appendix A1 Glossary Term Meaning Term Meaning JWT A signed

    token Cognito A way to sign users in sub The user's lasting ID client_id The app's ID IAM (SigV4) Checks AWS signatures audience Who a token is for token vault Where credentials sit Credential provider How a credential is got 2LO OAuth with no user 3LO OAuth the user agrees to OBO Exchanges a token Workload identity The identity of an agent Workload access token Desk and user pair PrivateLink Call from a closed network © 2026, Amazon Web Services, Inc. or its affiliates. All rights reserved. 31
  32. Appendix A2 Full commands (the way in) Run in the

    help desk's project folder (# says what the command does; long commands use variables) # 10, 18: read the inbound settings of the runtime and the gateway KEYS='{name, authorizerType, authorizerConfiguration, requestHeaderAllowlist}' jq ".runtimes[0] | $KEYS" agentcore/agentcore.json jq ".agentCoreGateways[0] | $KEYS" agentcore/agentcore.json # the gateway (no header list) # 11: call without a token / call with the AWS signature (IAM) of decks 01-04 python3 client/app_backend.py --no-token "Hello" bash client/sigv4_call.sh # prints only the error's type and reason # 12, 16: sign in as a customer (C-1001) and call python3 client/app_backend.py --user C-1001 "When will the USB-C hub I ordered arrive?" Q="This is Ichiro Suzuki (C-1002). Please refund my delayed keyboard order." python3 client/app_backend.py --user C-1001 "$Q" # 18: send tools/list to the MCP endpoint of the Gateway python3 client/gateway_call.py --no-token python3 client/gateway_call.py --user C-1001 © 2026, Amazon Web Services, Inc. or its affiliates. All rights reserved. 32
  33. Appendix A3 Full commands (outbound credentials and clean-up) Run in

    the help desk's project folder (# says what the command does; long commands use variables) # 22: keep a random, made-up API key from standard input, and see the fields returned GEN='import secrets, sys; sys.stdout.write(secrets.token_urlsafe(24))' python3 -c "$GEN" | agentcore add credentials api-key --name partnerApiKey --api-key agentcore deploy P=acdecks10SupportDeskEn_default_partnerApiKey aws bedrock-agentcore-control get-api-key-credential-provider --name "$P" --query 'keys(@)' # 23: add the stock API as a Gateway target, call it anonymously, ask the help desk T=file://agentcore/targets/inventory.json agentcore add gateway-target --gateway shop --target-configuration "$T" U=https://b74sc5b3nh.execute-api.ap-northeast-1.amazonaws.com curl -s -i "$U/v1/stock/P-201" | grep -i -E '^HTTP|errortype|message' python3 client/app_backend.py --user C-1002 "Is the keyboard (P-305) in stock?" # 28: clean up (after the 2 removes in appendix A4; the stock API was taken out of cdk-stack.ts) agentcore deploy © 2026, Amazon Web Services, Inc. or its affiliates. All rights reserved. 33
  34. Appendix A4 Screens after the clean-up The list of API

    key providers and the APIs named acdecks10en-inventory are both empty © 2026, Amazon Web Services, Inc. or its affiliates. All rights reserved. 34
  35. Appendix A5 What a JWT check compares Always issuer, signature,

    expiry. Also client, audience, scope, claims Setting What it compares in the token This deck discovery URL iss (issuer). Public keys too The Cognito user pool allowed clients client_id One app client allowed audiences aud Not used allowed scopes scope (one match is enough) Not used custom claims Claims and values you set Not used One of the bottom 4 rows is needed, and every one you set is checked A Cognito access token holds client_id © 2026, Amazon Web Services, Inc. or its affiliates. All rights reserved. 35
  36. Appendix A6 Sources AWS, AgentCore Developer Guide, Identity and other

    pages (slides 4, 7–10, 12, 14, 15, 17, 18, 20–25, 27, 29, 35) https://docs.aws.amazon.com/bedrock-agentcore/latest/devguide/identity.html AWS, Runtime inbound and outbound auth (with the Cognito steps) (slides 4, 6–12, 14, 17, 25, 35) https://docs.aws.amazon.com/bedrock-agentcore/latest/devguide/runtime-oauth.html AWS, Gateway inbound and outbound auth (slides 7, 8, 17, 18, 23, 24, 27) https://docs.aws.amazon.com/bedrock-agentcore/latest/devguide/gateway-inbound-auth.html AWS, API Gateway usage plans and API keys (slides 23, 24) https://docs.aws.amazon.com/apigateway/latest/developerguide/api-gateway-api-usage-plans.html AWS, Amazon Bedrock AgentCore pricing (slide 27) https://aws.amazon.com/bedrock/agentcore/pricing/ IETF, RFC 6749 (OAuth 2.0) and RFC 8693 (Token Exchange) (slides 21, 25) https://www.rfc-editor.org/rfc/rfc8693 Model Context Protocol specification, Authorization and Security Best Practices (slides 11, 17, 27) https://modelcontextprotocol.io/specification/2025-06-18/basic/security_best_practices OpenAI, April 2025, "A practical guide to building agents" (slides 6, 16) https://cdn.openai.com/business-guides-and-resources/a-practical-guide-to-building-agents.pdf © 2026, Amazon Web Services, Inc. or its affiliates. All rights reserved. 36