Skip to content

Cedar Policy Language Support

This page describes how the application supports the Cedar policy language for defining and managing authorization rules.

Cedar is a policy language developed by AWS designed for fine-grained access control. It provides a declarative way to express authorization rules using principals (who), actions (what), and resources (on what).

The application uses Cedar as its underlying policy language, allowing you to:

  • Define authorization rules using familiar concepts (subjects, actions, resources)
  • Write conditions using Cedar expression syntax
  • Export policies in Cedar format for use with compatible engines (e.g., Amazon Verified Permissions)
  • Visualize your authorization schema as a Cedar schema diagram
Application ConceptCedar ConceptDescription
Entity (User, Admin, etc.)Principal TypeWho can perform actions
Entity (Document, Order, etc.)Resource TypeWhat can be accessed
Entity PropertiesAttributesData used in conditions
Actions (read, write, delete)ActionsOperations that can be performed
RulesPoliciesAuthorization decisions

Every rule in the application maps to a Cedar policy with the following structure:

permit|forbid (
principal is PrincipalType,
action in [Action::"actionCode"],
resource is ResourceType
)
when {
// conditions that must be true
}
unless {
// exceptions that block the rule
};

The application provides an intelligent expression builder for writing when and unless conditions. The builder offers:

  • Autocomplete suggestions based on your schema
  • Syntax validation in real-time
  • Color-coded highlighting for better readability

When writing expressions, you can reference:

ReferenceDescriptionExample
subjectThe principal requesting accesssubject.department
resourceThe resource being accessedresource.owner
contextRuntime context informationcontext.ip
actionThe action being performedaction

Comparison Operators:

  • == - Equal to
  • != - Not equal to
  • <, >, <=, >= - Numeric comparisons
  • in - Membership in a set
  • like - Pattern matching (wildcards)
  • has - Check if attribute exists

Logical Operators:

  • && - Logical AND
  • || - Logical OR
  • ! - Logical NOT

Arithmetic Operators:

  • + - Addition
  • - - Subtraction
  • * - Multiplication

Note: Cedar does not support division by design, to ensure policies remain analyzable and avoid division-by-zero issues.

Set Operations:

  • contains(element) - Check if set contains element
  • containsAll([elements]) - Check if set contains all elements
  • containsAny([elements]) - Check if set contains any element

Date/Time Functions:

  • duration("2h") - Create a duration value
  • durationSince(datetime) - Time elapsed since a date
  • toDate(value) - Convert to date
  • toTime(value) - Convert to time
  • toDateTime(value) - Convert to datetime

Simple attribute comparison:

subject.department == "Finance"

Multiple conditions:

subject.role == "manager" && resource.status == "pending"

Set membership:

subject.clearanceLevel in ["secret", "top-secret"]

Set contains check:

subject.roles.contains("admin")

Pattern matching:

resource.name like "report-*"

Time-based condition:

context.requestTime.durationSince(resource.createdAt) < duration("24h")

Complex expression:

subject.role == "risk manager" && resource.amount > context.dailyLimit && context.newOverrideAmount <= context.standardLimit * 2

Access the Cedar schema from the Entities page:

  1. Navigate to Schema > Entities
  2. Click the Cedar Schema button
  3. The schema displays in JSON format

The schema viewer allows you to:

  • View the complete Cedar schema definition
  • Copy the schema to clipboard
  • Download as a JSON file

The Cedar schema defines:

{
"Namespace": {
"entityTypes": {
"User": {
"shape": {
"type": "Record",
"attributes": {
"email": { "type": "String" },
"department": { "type": "String" },
"roles": { "type": "Set", "element": { "type": "String" } }
}
}
}
},
"actions": {
"read": {
"appliesTo": {
"principalTypes": ["User"],
"resourceTypes": ["Document"]
}
}
}
}
}

The Cedar Schema Diagram provides a visual representation of your authorization model:

  1. Navigate to Schema > Entities
  2. Click the Cedar Schema button
  3. Select the Diagram tab

The diagram shows:

  • Principal entities (blue) - Who can perform actions
  • Resource entities (orange) - What can be accessed
  • Relationships - Arrows showing which actions connect principals to resources
  • Attributes - Entity properties with their types

Each rule can be exported as a Cedar policy:

  1. Open a rule from the Rules list
  2. Click the Cedar button in the toolbar
  3. The policy displays in Cedar syntax

The exported policy follows the Cedar specification:

permit(
principal is User,
action in [Action::"approve"],
resource is PurchaseOrder
)
when {
subject.department == resource.department &&
resource.amount <= subject.approvalLimit
}
unless {
resource.status == "closed"
};

The generated Cedar policies are compatible with Amazon Verified Permissions (AVP). To use your policies:

  1. Export your Cedar schema
  2. Export your rules as Cedar policies
  3. Import both into your AVP policy store
  4. Configure the AVP connector in your application

The expression builder provides intelligent autocomplete:

  • After typing subject. - Shows available subject attributes
  • After typing resource. - Shows available resource attributes
  • After typing context. - Shows context attributes (ip, time, location, device, authenticated)
  • After comparison operators - Suggests values and references
  • After in - Suggests set syntax [...]
  • After boolean expressions - Suggests logical operators (&&, ||)
  • Up/Down arrows - Navigate suggestions
  • Enter or Tab - Select suggestion
  • Escape - Close suggestions
  • Type to filter - Suggestions filter as you type

Expressions are validated in real-time:

  • Syntax errors appear below the input field
  • Valid expressions show a success indicator
  • Server-side validation confirms the expression can be parsed
  1. Keep conditions simple - Break complex rules into multiple simpler rules
  2. Use meaningful attribute names - Makes policies self-documenting
  3. Prefer explicit comparisons - Use == true instead of relying on truthiness
  4. Test edge cases - Verify rules handle null/missing attributes
  1. Define clear entity types - Separate principals from resources
  2. Use consistent naming - Follow a naming convention for attributes
  3. Set primary keys - Every entity should have a primary key defined
  4. Document with descriptions - Add descriptions to entities and properties
  1. Start with deny-by-default - Only permit what’s explicitly allowed
  2. Use groups for role-based access - Simplifies rule management
  3. Keep unless conditions focused - Use for specific exceptions only
  4. Review generated Cedar policies - Verify they match your intent
FeatureStatusNotes
Permit/Forbid policiesSupportedMaps to rule effect
Principal constraintsSupportedVia subject entity type
Resource constraintsSupportedVia resource entity type
Action constraintsSupportedVia permissions/actions
When clausesSupportedExpression builder
Unless clausesSupportedExpression builder
Attribute accessSupportedDot notation
Set operationsSupportedcontains, containsAll, containsAny
ComparisonsSupportedAll comparison operators
Logical operatorsSupportedAND, OR, NOT
Pattern matchingSupportedlike operator
Duration functionsSupportedduration, durationSince
If-then-elseSupportedConditional expressions
Entity referencesSupportedVia entity type properties

“Unexpected token”

  • Check for missing operators between expressions
  • Verify string literals use double quotes

“Unknown attribute”

  • Ensure the attribute exists on the entity
  • Check spelling and case sensitivity

“Type mismatch”

  • Verify you’re comparing compatible types
  • Use appropriate functions for type conversion

“No primary key defined”

  • Add a primary key to the entity before using it in rules
  • Primary keys are required for Cedar entity references

“Entity not available as reference”

  • Ensure the target entity has a primary key
  • Check that the entity type property is correctly configured