Giter Site home page Giter Site logo

example-cerbos-policy-repository's Introduction

Getting started with basic CRUD policies

What's in this repository?

Policies

Resource policies define rules for actions that can be performed on a given resource.

basicResource.yaml defines a resource policy for basicResources, with create, read, update and delete actions. This policy expects a principal to have either the ADMIN or USER role.

A basicResource is expected to have two attributes, ownerId and isPublished, which are used in the policy to make decisions about which actions should be permitted.

Attribute schemas

Attribute schemas are optional JSON schemas that are used by the Cerbos PDP at request time to validate the incoming request having all the required data to make a correct authorization decision. The server configuration can be set to either give a warning or reject the request if the input doesn't conform to these schemas.

_schemas/principal.json defines a schema for the principals, while _schemas/basicResource.json defines a schema for the basicResources.

Tests

basicResource_test.yaml defines a test suite and related test data that checks that the permissions are implemented as expected.

Cerbos Policy Decision Point (PDP) configuration

.cerbos.yaml is used to configure a Cerbos PDP server container to load the policies from disk.

Cerbos Hub configuration

.cerbos-hub.yaml is used to configure a Cerbos Hub workspace to compile policy bundles from commits matching the configured labels, to be deployed to connected Cerbos PDP instances.

Running locally

The simplest way to run Cerbos is using the container, which is shown below. See the documentation for other ways to install and run Cerbos locally.

Compile and test

Verify that the policies are correct by running

docker run --rm -it \
  -v $(pwd):/basic-crud \
  ghcr.io/cerbos/cerbos:latest \
  compile --verbose /basic-crud

PDP server

Launch a PDP server by running

docker run --rm --name cerbos \
 -v $(pwd):/basic-crud \
 -p 3592:3592 \
 -p 3593:3593 \
 ghcr.io/cerbos/cerbos:latest \
 server --config=/basic-crud/.cerbos.yaml

The API documentation can then be found at http://localhost:3592.

example-cerbos-policy-repository's People

Contributors

alexolivier avatar haines avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.