Skip to content



Cedar Logo

Build and Test golangci-lint Nightly Corpus Test

This repository contains source code of the Go implementation of the Cedar policy language.

Cedar is a language for writing and enforcing authorization policies in your applications. Using Cedar, you can write policies that specify your applications' fine-grained permissions. Your applications then authorize access requests by calling Cedar's authorization engine. Because Cedar policies are separate from application code, they can be independently authored, updated, analyzed, and audited. You can use Cedar's validator to check that Cedar policies are consistent with a declared schema which defines your application's authorization model.

Cedar is:


Cedar is a simple yet expressive language that is purpose-built to support authorization use cases for common authorization models such as RBAC and ABAC.


Cedar is fast and scalable. The policy structure is designed to be indexed for quick retrieval and to support fast and scalable real-time evaluation, with bounded latency.


Cedar is designed for analysis using Automated Reasoning. This enables analyzer tools capable of optimizing your policies and proving that your security model is what you believe it is.

Using Cedar

Cedar can be used in your application by importing the package.

Comparison to the Rust implementation

The Go implementation includes:

  • the core authorizer
  • JSON marshalling and unmarshalling
  • all core and extended types
  • integration test suite

The Go implementation does not yet include:

  • examples and CLI applications
  • schema support and the validator
  • the formatter
  • partial evaluation

Quick Start

Here's a simple example of using Cedar in Go:

package main

import (


const policyCedar = `permit (
	principal == User::"alice",
	action == Action::"view",
	resource in Album::"jane_vacation"

const entitiesJSON = `[
    "uid": { "type": "User", "id": "alice" },
    "attrs": { "age": 18 },
    "parents": []
    "uid": { "type": "Photo", "id": "VacationPhoto94.jpg" },
    "attrs": {},
    "parents": [{ "type": "Album", "id": "jane_vacation" }]

func main() {
	ps, err := cedar.NewPolicySet("policy.cedar", []byte(policyCedar))
	if err != nil {
	var entities cedar.Entities
	if err := json.Unmarshal([]byte(entitiesJSON), &entities); err != nil {
	req := cedar.Request{
		Principal: cedar.EntityUID{Type: "User", ID: "alice"},
		Action:    cedar.EntityUID{Type: "Action", ID: "view"},
		Resource:  cedar.EntityUID{Type: "Photo", ID: "VacationPhoto94.jpg"},
		Context:   cedar.Record{},
	ok, _ := ps.IsAuthorized(entities, req)

CLI output:


This request is allowed because VacationPhoto94.jpg belongs to Album::"jane_vacation", and alice can view photos in Album::"jane_vacation".

If you'd like to see more details on what can be expressed as Cedar policies, see the documentation.


General documentation for Cedar is available at, with source code in the cedar-policy/cedar-docs repository.

Generated documentation for the latest version of the Go implementation can be accessed here.

If you're looking to integrate Cedar into a production system, please be sure the read the security best practices

Backward Compatibility Considerations

x/exp - code in this subrepository is not subject to the Go 1 compatibility promise.


See CONTRIBUTING for more information.


We welcome contributions from the community. Please either file an issue, or see CONTRIBUTING


This project is licensed under the Apache-2.0 License.


No description, website, or topics provided.



Code of conduct

Security policy





No releases published


No packages published