Skip to content

Cedar support

The policies and the schema of Authorization are Cedar, as the Cedar project defines it. hamur server reads, checks and runs them with code written in the framework. It has no dependency, and it does not call Cedar's own engine or its WebAssembly build. This page is for the reader who already knows Cedar: what is covered, what is not, and how to use the outside Cedar tools on the same files.

The version is Cedar 4.15.0, language version 4.7.

What is supported

PartSupported
Policiespermit and forbid, annotations (@id("…") names a policy), the principal, action and resource scopes with ==, in, is and is … in, action in [ … ], when and unless, templates with ?principal and ?resource
Expressions||, &&, !, unary -, ==, !=, <, <=, >, >=, in, has with a name, a string or a path (e has a.b), like, is, +, -, *, if then else, .attr, ["attr"], sets, records, entity literals
Methodscontains, containsAll, containsAny, isEmpty, getTag, hasTag
Extension typesdecimal, ipaddr (ip), datetime, duration with their constructors and methods (lessThan and kin, isIpv4, isIpv6, isLoopback, isMulticast, isInRange with one range or more, offset, durationSince, toDate, toTime, toMilliseconds to toDays)
ValuesBool, Long (64 bit; an overflow is an error), String, Set, Record, entity
Schemanamespaces, entity types with attributes (optional with ?), in one parent type or a list, tags, enumerated entity types, external entity types and actions, common types, actions with appliesTo and a context, action groups, annotations
Decisiondefault deny, a satisfied forbid wins, order never matters, and a policy that errs counts as not satisfied and is reported
Validationevery policy is type-checked against the schema, in Cedar's strict mode, once for each request environment its scope matches

The file formats are Cedar's human-readable ones: .cedar for policies and .cedarschema for the schema. A policy file may hold any number of policies and templates. A schema may be split over files; a type declared in two files is an error.

What is not supported, and what differs

Each of these is a decision, not an oversight.

  • Cedar's JSON formats. The JSON policy format and the JSON schema format are not read. Use the human-readable format. (Entities in tests use Cedar's JSON entity shape; see Test the policies.)
  • Policies loaded at run time. The build reads every policy and compiles the set into the server. A policy store that changes while the app runs would leave the build unable to know the set. Data-driven rules, such as sharing, use template links.
  • Symbolic analysis. The framework never runs a solver. The outside tool cedar-policy-symcc does (see below).
  • Cedar's type-aware partial evaluation (tpe). It is experimental in Cedar 4.14 and is not followed. The list queries of authorizedWhere use a residual of the framework's own, which is limited to what becomes SQL.
  • Permissive validation. Validation is strict only.
  • Named policy ids of a linked template. In Cedar a linked policy has an id of its own. A link here has none, so a decision, an explanation and the log name the template, once for several of its links.
  • No policy is evaluated for a signed-out visitor. A request with no principal is answered 401 before the policies run, so a policy never has an anonymous principal.
  • context is yours. A policy sees a context only when the authorize key or a check passes one, and the schema of the action declares its shape. With none given, it is empty, so an action with a required context attribute fails the check instead of silencing a forbid.
  • A shared decision cache. Nothing is cached across requests, so a revoked role takes effect at the next request.

What is different from Cedar's own engine

Cedar's engine is written in Rust and its validator is proved correct for Cedar's model. The framework's engine and validator are a reimplementation, and the proof does not carry over. What stands in for it is a test: the framework's own test suite runs Cedar's published integration corpus and 10 000 generated policy sets, entity stores and requests through both engines, and requires the same decision, the same deciding policy ids, the same failing policy ids and the same validation verdict. A difference fails the test and prints the seed and the smallest case.

Two limits are on purpose. A request, context or entity that breaks the schema is refused by Cedar's engine, while the evaluator here takes the store as given; the code that loads entities refuses them first, with a 500 that names the entity and the attribute. A cycle in the parents of an entity is not an error here, as Cedar's in is a set.

Differences in authorizedWhere

authorizedWhere accepts a part of the language, since a condition must become SQL that gives exactly Cedar's answer. A policy may compare an attribute of the resource with a known value (==, !=, <, <=, >, >= on a Long), test a Bool attribute, has, like with a column, test a set attribute that lives in a join table with contains, containsAny, isEmpty and value in resource.set, and test the resource itself with ==, in and is, with &&, ||, ! and if. Arithmetic on a resource attribute, an extension type on one, containsAll, record attributes, tags (getTag, hasTag) of the resource and like on anything but a column have no SQL form. All of them still work in can and canEach; only the list query refuses them, and the build tells you when it can see the call.

Use the outside Cedar tools

The files are standard Cedar, and the framework adds nothing to them: the @id annotation is an ordinary Cedar annotation, and a template is an ordinary template. So the tools of the Cedar project read the same files that the build reads, with no export step. Install them from the Cedar project and follow its documentation for the command lines.

  • cedar validate checks the policies against the schema with Cedar's own validator. Run it in your CI beside the build; it is a second opinion from the reference implementation. The build already reports every error of the framework's validator with the file, the line and the column.
  • cedar format formats the files.
  • cedar-policy-symcc compiles policies for an SMT solver, so you can ask whether two versions of your policies decide differently for any request, or whether anyone could ever do a certain thing. The framework does not ship it; run it as a separate step, on a change to server/policies/.

Amazon Verified Permissions and any other engine that reads Cedar can read the same files.

The reasons for writing Cedar and not a function in TypeScript are the same reasons that make these tools work: a policy is data. The build can read it without running it, turn it into SQL, tell which policy decided, and check it against a schema.