Project

cerbos

0.0
The project is in a healthy, maintained state
Perform authorization in Ruby applications by interacting with the Cerbos policy decision point.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Runtime

~> 1.46
 Project Readme

Cerbos Ruby SDK

GemDocumentation

Cerbos helps you super-charge your authorization implementation by writing context-aware access control policies for your application resources. Author access rules using an intuitive YAML configuration language, use your Git-ops infrastructure to test and deploy them, and make simple API requests to the Cerbos policy decision point (PDP) server to evaluate the policies and make dynamic access decisions.

The Cerbos Ruby SDK makes it easy to interact with the Cerbos PDP from your Ruby applications.

Prerequisites

  • Cerbos 0.16+
  • Ruby 3.0+

Installation

Install the gem and add it to your application's Gemfile by running

$ bundle add cerbos

If you're not using Bundler to manage dependencies, install the gem by running

$ gem install cerbos

Example usage

client = Cerbos::Client.new("localhost:3593", tls: false)

decision = client.check_resource(
  principal: {
    id: "user@example.com",
    roles: ["USER"],
  },
  resource: {
    kind: "document",
    id: "1",
    attributes: {
      owner: "author@example.com"
    }
  },
  actions: ["view", "edit"]
)

decision.allow?("view") # => true
decision.allow?("edit") # => false

For more details, see the Client documentation.

Further reading

Get help