Overview
AWS Verified Permissions (AVP) is the authorization engine at the heart of this demo. The application implements externalized authorization - authorization logic lives in Cedar policies, not application code.The IsAuthorized API
Purpose
Theis_authorized API is the single point of integration between the application and AVP. It answers the question: “Can this principal perform this action on this resource?”
API Structure
Every authorization request requires four components:Request Components
Policy Store ID
The Policy Store is a container for Cedar policies, schema, and configuration:You can have multiple policy stores for different applications or environments (dev, staging, prod).
Principal
Identifies who is making the request:- entityType: Namespace and entity type from your schema
- entityId: Unique identifier for this specific user
Action
Defines what the principal wants to do:Read: View a documentEdit: Modify a documentDelete: Remove a document
Resource
Specifies what the principal wants to access:Entity Lists
Why Entity Lists?
Entity lists provide the context AVP needs to evaluate ABAC (Attribute-Based Access Control) policies. They contain:- Attributes: Properties of users and resources (department, clearance level, etc.)
- Relationships: Hierarchies and group memberships (user belongs to role)
Entity Structure
Thebuild_entity_list function (app.py:58) creates entities for the user and resource:
User Entities
Attributes:department: Which business unit the user belongs to (“Finance”, “HR”, “Sales”)clearance_level: Numeric security clearance (1-3)
- Users belong to Roles (“Analyst”, “Admin”, “Auditor”)
- This enables RBAC policies like “All Admins can Edit”
The
parents array creates an entity hierarchy. AVP can evaluate policies against both the user and their parent roles.Resource Entities
Attributes:department: Which department owns this documentclassification: Security level (“internal”, “confidential”, “restricted”)
- Resources in this demo have no parents
- In production, you might have folder hierarchies or organizational units
Attribute Types
AVP supports multiple attribute types:string for text attributes and long for numeric attributes.
Cedar Policy Evaluation
How AVP Evaluates Requests
When you callis_authorized, AVP:
- Loads Policies: Retrieves all policies from the Policy Store
- Validates Schema: Ensures the request matches your schema definition
- Evaluates Policies: Tests each policy against the request + entities
- Combines Results: Applies policy combination logic (default deny)
- Returns Decision: ALLOW or DENY with determining policies
Policy Examples
Here are example Cedar policies that could govern this demo:RBAC Policy: Admins Can Edit
ABAC Policy: Department Matching
ABAC Policy: Clearance Level
Cedar policies are human-readable and can be validated independently of your application code.
AVP Response
Response Structure
Theis_authorized call returns a response object:
Decision Values
- ALLOW: At least one policy permits the request and no policy forbids it
- DENY: Either no policy permits the request, or a forbid policy applies
AVP follows a default deny model. If no policy explicitly allows an action, it’s denied.
Determining Policies
This array contains the IDs of policies that contributed to the decision:- Debugging: Understanding why access was granted/denied
- Auditing: Recording which policies authorized actions
- UI Feedback: Showing users why they can/cannot access something
Error Handling
The response may include errors if policy evaluation failed:- Missing entities in the entity list
- Schema violations
- Malformed entity attributes
Integration Patterns
Pattern 1: Check Access
The primary pattern used in this demo:- Before performing any action
- At API gateway/middleware layer
- When rendering UI elements (show/hide buttons)
Pattern 2: Batch Authorization
For checking multiple permissions at once:AVP also offers a
batch_is_authorized API for more efficient bulk checks.Pattern 3: Pre-flight Checks
Check permissions before expensive operations:Agent Integration
The AI agent function (agent.py:41) uses the same AVP integration through a tool:- Check multiple permissions in one conversation
- Explain why access was granted or denied
- Compare permissions across different users
Performance Considerations
Latency
Typical AVPis_authorized call latency:
- P50: 20-50ms
- P99: 100-200ms
Caching
Consider caching for read-heavy workloads:Cost Optimization
AVP pricing:- $3.00 per 1M requests
- First 30M requests per month are free
- Use batch APIs for bulk checks
- Cache where appropriate
- Avoid unnecessary authorization checks
Debugging AVP Integration
Enable Detailed Logging
Log Authorization Requests
Check CloudWatch Logs
All Lambda function logs are in CloudWatch:Test Policies in AVP Console
The AVP console has a policy simulator:- Navigate to your Policy Store
- Click “Run a test”
- Enter principal, action, resource, and entities
- See which policies match and why
Security Best Practices
1. Validate Entity Attributes
Ensure entity attributes come from trusted sources:2. Use Schema Validation
Define a schema in AVP to catch errors early:3. Principle of Least Privilege
Lambda functions only needverifiedpermissions:IsAuthorized:
4. Audit Authorization Decisions
Log all authorization decisions for security auditing:Next Steps
AI Agent
Learn how the AI agent uses AVP integration
Lambda Functions
Return to Lambda function documentation