惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

L
LangChain Blog
The GitHub Blog
The GitHub Blog
Recent Announcements
Recent Announcements
MyScale Blog
MyScale Blog
P
Proofpoint News Feed
S
Security @ Cisco Blogs
N
News and Events Feed by Topic
H
Hacker News: Front Page
Attack and Defense Labs
Attack and Defense Labs
S
Secure Thoughts
Microsoft Security Blog
Microsoft Security Blog
N
Netflix TechBlog - Medium
U
Unit 42
Stack Overflow Blog
Stack Overflow Blog
T
Threat Research - Cisco Blogs
Google Online Security Blog
Google Online Security Blog
Spread Privacy
Spread Privacy
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
L
LINUX DO - 热门话题
T
Tenable Blog
博客园 - 叶小钗
D
DataBreaches.Net
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
博客园_首页
人人都是产品经理
人人都是产品经理
aimingoo的专栏
aimingoo的专栏
C
Check Point Blog
博客园 - 三生石上(FineUI控件)
量子位
P
Proofpoint News Feed
H
Help Net Security
Blog — PlanetScale
Blog — PlanetScale
宝玉的分享
宝玉的分享
Recorded Future
Recorded Future
The Register - Security
The Register - Security
F
Fortinet All Blogs
Engineering at Meta
Engineering at Meta
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
Last Week in AI
Last Week in AI
S
Schneier on Security
V
Vulnerabilities – Threatpost
雷峰网
雷峰网
Microsoft Azure Blog
Microsoft Azure Blog
G
GRAHAM CLULEY
G
Google Developers Blog
月光博客
月光博客
V
V2EX
T
Troy Hunt's Blog
A
Arctic Wolf

DEV Community

Authentication Security Deep Dive: From Brute Force to Salted Hashing (With Java Examples) Why AI Systems Don’t Fail — They Drift Spilling beans for how i learn for exam😁"Reinforcement Learning Cheat Sheet" I Replaced Chrome with Safari for AI Browser Automation. Here's What Broke (and What Finally Worked) How Python Borrows Other People's Work The $40 Architecture: Processing 1 Billion API Requests with 99.99% Uptime Vibe Coding: A Workflow Guide (From Zero to SaaS) Most webhook security guides protect the wrong side. The scary part is delivery. Headless CMS for TanStack Start: Build a Blog with Cosmic EU Age Verification App "Hacked in 2 Minutes" — What Actually Happened Comfy Cloud’s delete function does not actually remove files Running AI Models on GPU Cloud Servers: A Beginner Guide Event-driven media intelligence with AWS Step Functions and Bedrock I scored 500 AI prompts across 8 quality dimensions — here's what broke How to Call Google Gemini API from Next.js (Free Tier, No Backend Needed) The Portal Protocol: Reclaiming Human Connection in the Age of AI How to Fix Your Team's Scattered Knowledge Problem With a Self-Hosted Forum Intro to tc Cloud Functors: A Graph-First Mental Model for the Modern Cloud Designing Multi-Tenant Backends With Both Ownership and Team Access I Built a Neumorphic CSS Library with 77+ Components — Here's What I Learned PostgreSQL Performance Optimization: Why Connection Pooling Is Critical at Scale Cómo construí un SaaS multi-rubro para gestionar expensas en Argentina con FastAPI + Vue 3 🚀 I Built an Ethical Hacking Scanner Tool – Open Source Project I Replaced /usage and /context in Claude Code With a Single Statusline A Pythonic Way to Handle Emails (IMAP/SMTP) with Auto-Discovery and AI-Ready Design I Collected 8.9 Million Polymarket Price Points — Here's What I Found About How Markets Really Move EcoTrack AI — Carbon Footprint Tracker & Dashboard Everyone's Using AI. No One Agrees How. 5 self-hosted ebook managers worth trying in 2026 Building Your First AI Agent with LangChain: From Chatbot to Autonomous Assistant Common SOC 2 Failures (Real World) Stop Vibe-Checking Your AI App: A Practical Guide to Evals How to Use SonarQube and SonarScanner Locally to Level Up Your Code Quality Your Next To-Do App Is Dead — I Replaced Mine with an OpenClaw AI Sign a Nostr event in 60 lines of Python using coincurve — no nostr-sdk, no nbxplorer, no rust toolchain ITGC Audit Explained Like You’re in Big 4 Patch Tuesday abril 2026: Microsoft parcha 163 vulnerabilidades y un zero-day en SharePoint Stop scraping everything: a better way to track competitor price changes Listing on MCPize + the Official MCP Registry while routing payments OUTSIDE the marketplace — how I kept 100% of my x402 revenue Building an AI-Powered Risk Intelligence System Using Serverless Architecture Why We Ripped Function Overloading Out of Our AI Toolchain Testing AI-Generated Code: How to Actually Know If It Works SaaS Churn Is Killing Your Business. Here Is What to Do About It (Without a Support Team) The Speed of AI Is No Longer Linear - And Self-Improving Models Are Why How to Implement RBAC for MCP Tools: A Practical Guide for Engineering Teams From Standard Quote to Persuasive Proposal: AI Automation for Arborists I built a CLI that scaffolds complete multi-tenant SaaS apps Axios CVE-2025–62718: The Silent SSRF Bug That Could Be Hiding in Your Node.js App Right Now The dashboard that ended our friendship Data Pipelines Explained Simply (and How to Build Them with Python) The Hidden Cost of AI Systems Nobody Talks About. undefined vs undeclared, and how typeof behaves Switching from file-based jobs to NATS/Kafka in Rust without changing code io_uring Adventures: Rust Servers That Love Syscalls Why Agentic AI is Killing the Traditional Database The POUR principles of web accessibility for developers and designers Quantum Neural Network 3D — A Deep Dive into Interactive WebGL Visualization How To Install Caveman In Codex On macOS And Windows Automation Pipeline Reliability: Why Your Workflow Breaks When Nobody Is Watching I Built an 'Open World' AI Coding Agent — It Works From ANY Folder From Freelancing to Product: A Tech Service Company's SaaS Transformation China's AI Giants: Adding Tencent Hunyuan & ByteDance Doubao to AI University (74 Providers) On the Vibe Coders and Their Lies clerk: Auto-Summarize Your Claude Code Sessions AI Weekly — 2026/04/10–04/17 | The Model Lockdown Is Here, but the Toolchain Is the Real Battleground AI 週報 — 2026/04/10–2026/04/17 模型封鎖潮來了,但工具鏈才是真戰場 Maybe this is how Open-Source apps are born... 🚀 Fine-Tune LLMs with LoRA and QLoRA: 2026 Guide tRPC v11 + Next.js App Router: End-to-End Type Safety Without the Boilerplate ShadCN UI in 2026: Why I Stopped Installing Component Libraries and Started Owning My Components SaaS Billing in React Server Components: Stripe + Supabase Without a Single `useEffect` Join our DEV Weekend Challenge — $1,000 in Prizes Across TEN winners! Submissions Due April 20 at 6:59 AM UTC. Implementing FSRS Spaced Repetition in Flutter + Supabase — Adding Memory Science to an AI Learning App "I Texted My Localhost From the Train — Claude Code Fixed the Bug Before I Got Home" I Built a Sales Prep AI and It Went Deeper Than Expected Design to Code #2: One JSON, Eleven Outputs Solving the 100M-Row Problem: A Summary Table Pattern for High-Volume Push Notification Logs Flutter Web With Wasm: What Actually Changes For Developers I Built 50 Royalty-Free Soundtracks for My Side Project in a Weekend Using AI Music Generation The Vibe Coding Security Checklist: 7 Things to Check Before You Ship Stop Letting Googlebot Guess Fix Your React App's SEO Right Desconstruindo o Streaming do LinkedIn: Como Criar um Engine de Extração de Vídeo de Alta Performance com HLS e FFmpeg (EDA Part-1) EDA (Exploratory Data Analysis) Explained With Real Life — Why Looking at Your Data Is the Most Important Step in Machine Learning Brand Relationship Management at Scale: Our 4-Touch Outreach System for 200+ Brands Why String.fromEnvironment() Might Return an Empty String in Dart JGuardrails 1.0.0 — Hardening Java LLM Apps Against Jailbreaks, Toxicity, and Prompt Injection Plan and Schedule a Full Week of Threads Content From One Claude Conversation Coding Cat Oran Ep3, Five Tables Changed Everything Updated: BFF Pattern I'm done watching freelancers get buried by 200 proposals. So I'm building the alternative. This is my first post BFS Algorithm in Java Step by Step Tutorial with Examples Tracking LLM Pricing Monthly: An Open Dataset for 22 AI Models How We Measure Content ROI on a Comparison Site: Revenue Attribution Without Perfect Data Introducing Nova AI Ops: The AI-Native Operating System for SRE Teams I built a free desktop video downloader for Windows — Grabbit How Talkie OCR Helps Vision-Impaired & Dyslexic Users Read the World Around Them VRCFaceTracking安装和iPhone面捕配置教程,有bug Even CrowdStrike Can't See Your Agents The Automation Gold Rush: What n8n Workflows and Claude Are Opening Up for Developers Right Now
3 Steps to RBAC for AI Agents on Amazon Bedrock AgentCore
Zubeen Sahaj · 2026-05-19 · via DEV Community

The Problem

Building AI agents has become surprisingly easy. You connect tools via MCP servers, APIs, or built-in capabilities, wire up an LLM, and run tests. The agent performs well and pulls the right data. Then comes the part that actually matters: authorization. It doesn't know who's asking or what they're allowed to see.

TL;DR: Build secure multi-tenant AI agents on Amazon Bedrock AgentCore using OAuth scopes, Cedar policies, and Gateway interceptors. Deterministic authorization for non-deterministic agents. Working code examples included.

Full code is on GitHub: awslabs/agentcore-samples/role-based-hr-data-agent

Three steps on Amazon Bedrock AgentCore Runtime and Amazon Bedrock AgentCore Gateway: authentication, scope-based permissions, and gateway enforcement. Let's go.

Step 1: IDP Integration

You start by integrating your identity provider to answer the fundamental question: who is making this request? When users authenticate through your IDP (e.g., Okta, Entra ID, Amazon Cognito), they receive a JWT token. This token proves their identity and includes claims about who they are and what permissions they have.

Every agent invocation needs to validate this JWT token. The token must be:

  • Cryptographically signed by your IDP (signature validation)
  • Not expired (expiration check)
  • Intended for your application (audience validation)

Amazon Bedrock AgentCore Runtime handles this for you. You configure your Runtime with a custom authorizer that handles all JWT validation automatically. Point it to your IDP's discovery URL, and the Runtime fetches the public keys, validates signatures, and rejects invalid tokens.

AgentCore Runtime supports multiple authorizer types: CUSTOM_JWT (for OAuth 2.0 compliant IDPs), AWS_IAM (for AWS IAM principals), and NONE (for development). See the AgentCore Runtime documentation for details.

For this example, we're using Amazon Cognito with CUSTOM_JWT, but you can use any OAuth 2.0 compliant IDP (Okta, Entra ID, Auth0).

Here's how to configure the Runtime with a custom JWT authorizer:

import boto3

client = boto3.client('bedrock-agentcore-control', region_name='us-east-1')

response = client.create_agent_runtime(
    agentRuntimeName='hr-agent-runtime',
    agentRuntimeArtifact={
        'containerConfiguration': {
            'containerUri': '<account>.dkr.ecr.us-east-1.amazonaws.com/hr-agent:latest'
        }
    },
    authorizerConfiguration={
        'customJWTAuthorizer': {
            'discoveryUrl': 'https://cognito-idp.us-east-1.amazonaws.com/us-east-1_XXXXX/.well-known/openid-configuration',
            'allowedClients': ['hr-api-client']
        }
    },
    networkConfiguration={'networkMode': 'PUBLIC'},
    roleArn='arn:aws:iam::<account>:role/AgentRuntimeRole'
)

Enter fullscreen mode Exit fullscreen mode

Now all agent invocations require authenticated JWT tokens. Gated access achieved. The Runtime validates tokens using your IDP's public keys (JWKS) from the discovery URL. Users can't invoke the agent without valid credentials.

Step 2: Scope-Based Permissions

Authentication is done. The user is in the building. But what room can they enter? That's where authorization begins.

You move to authorization by defining OAuth scopes as permission labels. You create scopes that represent different access levels. When users authenticate through your IDP, their JWT tokens include scopes based on their role.

Here's what a JWT token looks like with scopes:

{
  "sub": "user@company.com",
  "iss": "https://your-idp.com",
  "aud": ["your-api-client"],
  "exp": 1715612345,
  "iat": 1715608745,
  "scope": "api/read api/write",
  "groups": ["standard-users"]
}

Enter fullscreen mode Exit fullscreen mode

Key claims:

  • sub: User identifier
  • iss: Who issued the token (your IDP)
  • aud: Intended audience (your application)
  • exp: Expiration timestamp
  • scope: OAuth scopes defining permissions
  • groups: User's role/group assignments

Different roles get different scope combinations:

User Type Example Scopes What They Can Do
Full Access User api/read api/write api/admin All tools and data
Standard User api/read api/write Read and modify, no admin tools
Read-Only User api/read View data only

You've mapped roles to scopes that define who can access which agent and which tools based on the claims in their JWT.

But having scopes in JWT tokens isn't enough. Nothing is checking them yet. The scopes are just claims sitting in a token, ignored unless something enforces them before tools execute.

Amazon Bedrock AgentCore Gateway is that enforcement point.

Step 3: Enforce Scopes with AgentCore Gateway

AgentCore Gateway sits between your agent runtime and your tools. Every tool call flows through it. This gives you a central enforcement point to validate scopes and control access.

First, AgentCore Gateway validates authentication. While Runtime already validated the JWT in Step 1, AgentCore Gateway performs its own independent validation. This is a defense-in-depth pattern where each layer verifies authentication.

Here's how to configure AgentCore Gateway with IDP authentication:

import boto3

client = boto3.client('bedrock-agentcore-control', region_name='us-east-1')

response = client.create_gateway(
    name='hr-agent-gateway',
    protocolType='MCP',
    authorizerType='CUSTOM_JWT',
    authorizerConfiguration={
        'customJWTAuthorizer': {
            'allowedClients': ['hr-api-client'],
            'discoveryUrl': 'https://cognito-idp.us-east-1.amazonaws.com/us-east-1_XXXXX/.well-known/openid-configuration'
        }
    },
    roleArn='arn:aws:iam::<account>:role/GatewayServiceRole'
)

Enter fullscreen mode Exit fullscreen mode

Then, AgentCore Gateway enforces authorization. Your agent is non-deterministic. The LLM decides which tools to call based on natural language prompts, which means you can't trust the agent to consistently enforce authorization rules.

A cleverly worded prompt might trick the agent into calling a tool the user shouldn't access. The agent might hallucinate permissions. The agent doesn't understand security boundaries.

You need deterministic enforcement outside the agent. AgentCore Gateway provides this through Gateway interceptors, Lambda functions that run before and after tool invocations. Fixed, deterministic code. Same input = same output. Every time.

You implement a Request Interceptor, a Lambda function invoked by the Gateway before a tool call reaches its destination:

  1. Extract & evaluate. Parse the request to pull user context (token claims, tenant ID, role, scopes). Use those attributes to determine what this user is authorized to do: scope their access, identify their tenant, resolve their permissions.
  2. Enforce & enrich. Inject tenantId into tool parameters for tenant isolation. Add/strip headers. Transform or restrict parameters based on role. Reject unauthorized requests outright.
  3. Forward. Return the modified (or blocked) request to the Gateway, which routes it to the target (an MCP server or direct tool invocation).

If the scopes are insufficient, the interceptor rejects the request before it ever reaches your tools. Your agent code doesn't change. Your tool code doesn't change. The enforcement logic lives in the interceptor Lambda.

But the interceptor operates at the request level. It sees the raw inbound call. It doesn't evaluate what the agent decided to do. When the agent autonomously selects a tool and constructs parameters, you need to evaluate: Is this principal allowed to perform this action on this resource, with these parameters?

This is where Cedar policies come in. AgentCore Gateway supports Cedar policy evaluation as part of its authorization layer.

Cedar evaluates the authorization request constructed from the JWT claims and the tool call. The interceptor and Cedar operate as complementary but independent layers: the interceptor provides imperative custom logic, while Cedar provides declarative policy evaluation against the original request.

Here's what Cedar evaluates:

  1. Principal - The user making the request (created from the JWT's sub claim)
  2. Action - Which tool they're trying to invoke (extracted from the tool name)
  3. Resource - The Gateway instance (the resource boundary being protected)
  4. Context - The tool arguments and additional attributes (tenant, time, etc.)

Cedar checks these attributes against your policies and returns a decision: ALLOW or DENY.

Example Cedar policy:

// Only users with 'read' scope can search employees
permit(
  principal,
  action == AgentCore::Action::"HRDataTarget___search_employee",
  resource
) when {
  principal.getTag("scope") like "*hr-dlp-gateway/read*"
};

// Only users with 'comp' scope can access compensation
permit(
  principal,
  action == AgentCore::Action::"HRDataTarget___get_employee_compensation",
  resource
) when {
  principal.getTag("scope") like "*hr-dlp-gateway/comp*"
};

Enter fullscreen mode Exit fullscreen mode

The flow becomes:

  1. Gateway validates the JWT signature (CUSTOM_JWT authorizer)
  2. Request Interceptor (if configured) runs custom Lambda logic to enrich, validate, or block the request
  3. Cedar policy evaluation (if configured) independently evaluates the original JWT claims and tool call against declarative policies
  4. If either layer denies → request blocked with 403
  5. If both allow → tool invocation proceeds

You can use interceptors alone, Cedar alone, or both together. They're complementary layers, not a required chain. In this demo, we use both: interceptors for runtime enrichment and Cedar for declarative policy enforcement.

With both layers active, you've achieved three critical controls:

  1. Tenant isolation - Users can only invoke tools for their own tenant (interceptor injects tenantId into tool parameters)
  2. Scope-based enrichment - Request Interceptor extracts scopes from the JWT and injects context for downstream evaluation
  3. Tool-level authorization - Cedar evaluates each tool invocation request against declarative policies and blocks unauthorized calls

At this point, you've secured tool invocation. But there's another gap: tool discovery.

Say your agent connects tools via an MCP server with 5 tools defined. Users ask "what tools are available?" and get the complete list. Cedar prevents unauthorized invocations, but users still see everything.

This is a security risk. Why should users see tools they'll never be authorized to use? You're leaking information about system capabilities.

You need to filter tool discovery based on scopes. Users should only see tools they're authorized to invoke. This requires intercepting the response AFTER the MCP server returns the tool list, but BEFORE it reaches the caller (agent or user).

That's where the Response Interceptor comes in. It filters tool lists based on the user's scopes. It also redacts data fields in tool responses before they reach the caller.

Now let's see these layers in action. Here's how the same query produces different results for three personas.

Define Your Access Control Personas

Let me show you with an HR agent. Consider a simple request: "Show me John Smith's full profile."

Who's asking matters:

  • HR Manager should see the full salary
  • HR Specialist should see job details but NOT compensation
  • Employee should only see public information

Same query. Three different people. Three different results. This is the multi-tenant authorization problem.

The pattern applies to any multi-tenant agent: customer support agents that scope replies to one customer's tickets, or healthcare agents that limit responses to a single patient's records. The HR example just makes it concrete.

Persona 1: HR Manager (Full Access)

OAuth Scopes: read pii address compensation

What they see:

{
  "employee_id": "12345",
  "name": "Jane Doe",
  "job_title": "Senior Engineer",
  "department": "Engineering",
  "manager": "John Smith",
  "ssn": "123-45-6789",
  "date_of_birth": "1990-05-15",
  "home_address": "123 Main St",
  "city": "Seattle",
  "state": "WA",
  "salary": "$150,000",
  "bonus": "$20,000",
  "stock_options": "5000 shares"
}

Enter fullscreen mode Exit fullscreen mode

Use case: HR Managers need full visibility for:

  • Compensation reviews
  • Benefits administration
  • Compliance reporting

HR Manager View

Persona 2: HR Specialist (No Compensation)

OAuth Scopes: read pii

In this system, the pii scope covers identity fields (SSN, date of birth) needed for verification, but not residential data. Address is a separate address scope which HR Specialists don't have.

What they see:

{
  "employee_id": "12345",
  "name": "Jane Doe",
  "job_title": "Senior Engineer",
  "department": "Engineering",
  "manager": "John Smith",
  "ssn": "123-45-6789",
  "date_of_birth": "1990-05-15",
  "home_address": "[REDACTED]",
  "city": "[REDACTED]",
  "state": "[REDACTED]",
  "salary": "[REDACTED]",
  "bonus": "[REDACTED]",
  "stock_options": "[REDACTED]"
}

Enter fullscreen mode Exit fullscreen mode

Use case: HR Specialists need PII access for:

  • Onboarding new employees
  • Offboarding processes
  • Employee record updates
  • Identity verification

What they DON'T see: Compensation and home addresses

Persona 3: Employee (Self-Service Only)

OAuth Scopes: read

What they see (when querying their own record):

{
  "employee_id": "12345",
  "name": "Jane Doe",
  "job_title": "Senior Engineer",
  "department": "Engineering",
  "manager": "John Smith",
  "ssn": "[REDACTED]",
  "date_of_birth": "[REDACTED]",
  "home_address": "[REDACTED]",
  "city": "[REDACTED]",
  "state": "[REDACTED]",
  "salary": "[REDACTED]",
  "bonus": "[REDACTED]",
  "stock_options": "[REDACTED]"
}

Enter fullscreen mode Exit fullscreen mode

Additional Cedar rule: Employees can only view their own record. If Jane tries to query another employee, the request is blocked entirely.

Use case: Employees can self-serve:

  • Look up their manager
  • Check department info
  • View job title

What they DON'T see: Any sensitive data (PII, compensation, addresses)

Employee View

Key Takeaways

Here's what we built and why it matters:

1. Authentication ≠ Authorization

  • Authentication = WHO the user is (Your IDP)
  • Authorization = WHAT they can access (Cedar + Gateway interceptors)
  • You need both layers

2. Deterministic Security for Non-Deterministic Agents

  • AI agents generate unpredictable responses
  • Your security layer must enforce predictable rules
  • OAuth scopes + Cedar policies = deterministic authorization
  • Independent of the LLM

3. Defense in Depth

We enforce authorization at multiple points:

  • Request Interceptor - Validates scopes and injects tenant context
  • Cedar policies - Evaluates tool-level authorization (can this user invoke this tool?)
  • Response Interceptor - Redacts fields based on scopes (which fields can this user see?)
  • Each layer protects against different attack vectors

4. Field-Level Redaction Without Agent Changes

  • Write one query for all roles
  • Redact fields based on user's scopes
  • The agent doesn't know about authorization
  • The interceptor handles it

5. OAuth Scopes are Standardized

Using OAuth 2.0 scopes means:

  • Works with standard identity providers (Okta, Entra ID, Cognito, Auth0)
  • Industry-standard permission labels
  • Portable across different agent platforms

6. Cedar Policies are Auditable

Cedar benefits:

  • Human-readable policy language
  • Version-controlled in Git
  • Audit who has access by reading policy files
  • No complex SQL grants or IAM policies to untangle

Conclusion

Building secure multi-tenant AI agents requires one discipline: don't trust the agent to enforce its own boundaries. The agent is non-deterministic. Your security layer must be deterministic.

By using OAuth scopes for field-level permissions, Cedar policies for resource-level authorization, and Gateway interceptors for enforcement, you create a security architecture that works regardless of how the agent behaves. Same user, same request, same authorization decision. Every time.

Clone the repo, deploy it, and test it with the three personas. You'll see exactly how deterministic authorization protects non-deterministic agents.

How do you handle authorization in your AI agents? Have you run into cases where the agent bypassed security rules? Drop a comment and let's discuss!


Opinions are my own.