• Stars
    star
    2,247
  • Rank 19,597 (Top 0.4 %)
  • Language
    Go
  • License
    Apache License 2.0
  • Created about 3 years ago
  • Updated 3 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Cerbos is the open core, language-agnostic, scalable authorization solution that makes user permissions and authorization simple to implement and manage by writing context-aware access control policies for your application resources.

GitHub release (latest SemVer) Snapshots Go Reference Go Report Card codecov Contributor Covenant

Cerbos

What is Cerbos?

Cerbos is an authorization layer that evolves with your product. It enables you to define powerful, context-aware access control rules for your application resources in simple, intuitive YAML policies; managed and deployed via your Git-ops infrastructure. It provides highly available APIs to make simple requests to evaluate policies and make dynamic access decisions for your application.

Key concepts, at a glance πŸ‘€

PRINCIPAL: oftentimes just the "user", but can also represent: other applications, services, bots or anything you can think of. The "thing" that's trying to carry out an... ↙️

ACTION: a specific task. Whether it be to create, view, update, delete, acknowledge, approve... anything at all. The principal might have permission to do all actions, or maybe just one or two. The actions are carried out on a... ↙️

RESOURCE: the thing you're controlling access to. Could be anything, e.g. in an expense management system; reports, receipts, card details, payment records, etc. You define resources in Cerbos by writing... ↙️

POLICIES: YAML files where you define the access rules for each resource, following a simple, structured format. Stored either: on disk, in cloud object stores, git repos, or dynamically in supported databases. These are continually monitored by the... ↙️

CERBOS PDP: the Policy Decision Point: the stateless service where policies are executed and decisions are made. This runs as a separate process, in kube (as a service or a sidecar), directly as a systemd service or as an AWS Lambda function. Once deployed, the PDP provides two primary APIs...

  • CheckResources: "Can this principal access this resource?"
  • PlanResources: "Which of resource kind=X can this principal access?"

These APIs can be called via cURL, or in production via one of our many... ↙️

SDKs: you can see the list here. There are also a growing number of query plan adapters, to convert the SDK PlanResources responses to a convenient query instance.

RBAC -> ABAC: If simple RBAC doesn't cut it, you can extend the decision-making by implementing attribute based rules. Implement conditions in your resource policies which are evaluated dynamically at runtime using contextual data, for much more granular control. Add conditions in derived roles to dynamically extend the RBAC roles. Or use principal policies for more particular overrides for a specific user.

Cerbos

Learn more

Used by

Cerbos is popular among large and small organizations:

Cerbos

Using Cerbos? Let us know by emailing [email protected].

Installation

Examples

Resource policy

Write access rules for a resource.

---
apiVersion: api.cerbos.dev/v1
resourcePolicy:
  importDerivedRoles:
    - common_roles
  resource: "album:object"
  version: "default"
  rules:
    - actions: ['*']
      effect: EFFECT_ALLOW
      derivedRoles:
        - owner

    - actions: ['view', 'flag']
      effect: EFFECT_ALLOW
      roles:
        - user
      condition:
        match:
          expr: request.resource.attr.public == true

    - actions: ['view', 'delete']
      effect: EFFECT_ALLOW
      derivedRoles:
        - abuse_moderator

Derived roles

Dynamically assign new roles to users based on contextual data.

---
apiVersion: "api.cerbos.dev/v1"
derivedRoles:
  name: common_roles
  definitions:
    - name: owner
      parentRoles: ["user"]
      condition:
        match:
          expr: request.resource.attr.owner == request.principal.id

    - name: abuse_moderator
      parentRoles: ["moderator"]
      condition:
        match:
          expr: request.resource.attr.flagged == true

API request

cat <<EOF | curl --silent "http://localhost:3592/api/check/resources?pretty" -d @-
{
  "requestId": "test01",
  "includeMeta": true,
  "principal": {
    "id": "alicia",
    "roles": [
      "user"
    ]
  },
  "resources": [
    {
      "actions": [
        "view"
      ],
      "resource": {
        "id": "XX125",
        "kind": "album:object",
        "attr": {
          "owner": "alicia",
          "public": false,
          "flagged": false
        }
      }
    }
  ]
}
EOF

API response

{
  "requestId": "test01",
  "results": [
    {
      "resource": {
        "id": "XX125",
        "kind": "album:object",
        "policyVersion": "default"
      },
      "actions": {
        "view": "EFFECT_ALLOW"
      },
      "meta": {
        "actions": {
          "view": {
            "matchedPolicy": "resource.album_object.vdefault"
          }
        },
        "effectiveDerivedRoles": [
          "owner"
        ]
      }
    }
  ]
}

Client SDKs

Query plan adapters

Telemetry

We collect anonymous usage data to help us improve the product. You can opt out by setting the CERBOS_NO_TELEMETRY=1 environment variable. For more information about what data we collect and other ways to opt out, see the telemetry documentation.

Join the community πŸ’¬

Join Slack πŸ‘‡

Subscribe to our Newsletter

Contributing ⌨️

Check out how to contribute.

Stargazers ⭐

Stargazers repo roster for cerbos/cerbos

More Repositories

1

cerbos-sdk-javascript

JavaScript SDK for authorization via Cerbos
TypeScript
65
star
2

cerbos-sdk-net

.NET SDK for interacting with the Cerbos PDP
C#
13
star
3

cerbos-aws-lambda

Gateway service implements AWS Lambda runtime and invokes Cerbos server API hosted in the same AWS Lambda instance.
Go
13
star
4

query-plan-adapters

Repo of adapters converting a Cerbos Query Plan to a data fetching layer
TypeScript
12
star
5

demo-graphql

A Typescript GraphQL demo of integrating Cerbos with GQL
TypeScript
12
star
6

sveltekit-clerk-cerbos

Svelte
12
star
7

cerbos-sdk-python

Cerbos Python SDK
Python
11
star
8

demo-rest

Demo of using Cerbos to secure a Go REST API.
Go
11
star
9

reimage

Go
8
star
10

demo-admin-api

Go
8
star
11

nextjs-prisma-cerbos

TypeScript
8
star
12

nextjs-clerk-cerbos

JavaScript
7
star
13

cerbos-sdk-ruby

Ruby SDK for authorization via Cerbos
Ruby
6
star
14

cerbos-compile-action

Compile and test Cerbos policies
TypeScript
6
star
15

demo-multitenant-saas

Demonstrating Cerbos's scoped policies to model a multitenant SaaS platform
Makefile
5
star
16

cerbos-setup-action

A GitHub action to setup Cerbos binaries
TypeScript
5
star
17

demo-python

Demo of using Cerbos with Python to check access to a holiday request system.
Python
4
star
18

remix-clerk-cerbos

Example project to showcase Cerbos integration with remix
TypeScript
4
star
19

express-jwt-cerbos

An example application of integrating Cerbos with an Express server using JSON Web Tokens - via express-jwt - for authentication.
JavaScript
3
star
20

cerbos-sdk-java

Java SDK for interacting with the Cerbos PDP.
Java
3
star
21

python-cognito-cerbos

Python
3
star
22

nuxtjs3-cerbos-iron-session

Showcase of Cerbos using NuxtJs 3
Vue
3
star
23

cerbos-sdk-php

PHP SDK for interacting with the Cerbos PDP
PHP
2
star
24

express-fusionauth-cerbos

JavaScript
2
star
25

express-prisma-cerbos

An example application of integrating Cerbos with an Express server using Prisma as the ORM.
TypeScript
2
star
26

demo-laravel

Demo of using cerbos with php laravel
PHP
2
star
27

python-sqlalchemy-cerbos

An example application of integrating Cerbos with a FastAPI server using SQLAlchemy as the ORM.
Python
1
star
28

cerbos-sdk-laravel

Cerbos PHP Laravel SDK for interacting with the Cerbos PDP
PHP
1
star
29

express-auth0-cerbos

An example application of integrating Cerbos with an Express server using Auth0 for authentication.
JavaScript
1
star
30

cerbos-queryplan-helpers

This project contains Go modules showing how to use the Query Planner API to filter data using various ORMs and toolkits.
Go
1
star