Overview
Tag-based access control (ABAC) uses tags on subjects and resources to make dynamic authorization decisions. Instead of static role assignments, access is determined by matching attributes. Example: “Users can read documents tagged with their department.”How It Works
- Tag subjects with attributes (department, clearance, skills)
- Tag resources with attributes (department, sensitivity, category)
- Create permissions with JSON Logic conditions that compare tags
- Evaluation checks if the subject’s tags match the resource’s tags
Basic Tag Matching
Department Match
Users can only access documents in their department:Evaluation
JSON Logic Patterns
Any Tag Matches
Subject has at least one tag that matches the resource:All Tags Required
Subject must have ALL tags the resource has:Specific Tag Required
Resource must have a specific tag:Clearance Level
Subject’s clearance must meet or exceed resource’s requirement:Combined Conditions
Multiple conditions with AND/OR:Common Patterns
Pattern 1: Department-Based Access
Pattern 2: Sensitivity Levels
Pattern 3: Labor Class Matching (Construction)
Pattern 4: Project Team Access
Pattern 5: Geographic Restrictions
Context Variables
In tag-based conditions, you have access to:| Variable | Description |
|---|---|
subject.id | Subject’s Bedrock ID |
subject.type | Subject type (user, agent, etc.) |
subject.meta.* | Subject metadata fields |
subject.tags.* | Subject’s tags by group key |
resource.id | Resource’s Bedrock ID |
resource.type | Resource type key |
resource.meta.* | Resource metadata |
resource.tags.* | Resource’s tags by group key |
context.* | Custom context passed in evaluation |
Debugging Tag Conditions
The evaluation response includes context for debugging:Best Practices
Keep conditions simple
Keep conditions simple
Complex nested conditions are hard to debug. Break them into multiple permissions if needed.
Use meaningful tag group keys
Use meaningful tag group keys
The key appears in conditions (
resource.tags.departments), so make it readable.Test with edge cases
Test with edge cases
Test with subjects/resources that have no tags, multiple tags, and mismatched tags.
Document your conditions
Document your conditions
Use the permission’s
description field to explain what the condition does.Combine with role-based access
Combine with role-based access
Tag-based conditions work alongside roles. A subject still needs the permission via a role.