Convert Figma logo to code with AI

osohq logooso

Oso is a batteries-included framework for building authorization in your application.

3,467
174
3,467
114

Top Related Projects

4,924

Open Source, Google Zanzibar-inspired permissions database to enable fine-grained authorization for customer applications

17,484

An authorization library that supports access control models like ACL, RBAC, ABAC in Golang: https://discord.gg/S5UjpzGZjN

9,617

Open Policy Agent (OPA) is an open source, general-purpose policy engine.

1,112

Warrant is a highly scalable, centralized authorization service based on Google Zanzibar. Use it to define, enforce, query, and audit application authorization and access control.

4,433

An open-source authorization as a service inspired by Google Zanzibar, designed to build and manage fine-grained and scalable authorization systems for any application.

4,774

Open Source (Go) implementation of "Zanzibar: Google's Consistent, Global Authorization System". Ships gRPC, REST APIs, newSQL, and an easy and granular permission language. Supports ACL, RBAC, and other access models.

Quick Overview

Oso is an open-source policy engine for authorization that's embedded in your application. It provides a declarative language for writing authorization rules and a library for enforcing those rules in your application. Oso aims to make it easy to implement and maintain complex authorization logic across different programming languages and frameworks.

Pros

  • Declarative policy language (Polar) for expressing complex authorization rules
  • Supports multiple programming languages (Python, Ruby, Java, Node.js, Go, Rust)
  • Provides a unified approach to authorization across different parts of an application
  • Offers good performance and scalability for large applications

Cons

  • Learning curve for the Polar language and Oso's concepts
  • May be overkill for simple authorization needs
  • Limited ecosystem compared to some other authorization solutions
  • Requires integration work to fit into existing applications

Code Examples

  1. Defining a simple policy in Polar:
allow(user, "read", document) if
    user.role = "admin" or
    document.public = true;

This policy allows a user to read a document if they are an admin or if the document is public.

  1. Checking authorization in Python:
from oso import Oso

oso = Oso()
oso.load_file("policy.polar")

user = {"role": "user"}
document = {"public": True}

if oso.is_allowed(user, "read", document):
    print("Access granted")
else:
    print("Access denied")

This code loads a policy file and checks if a user is allowed to read a document.

  1. Using resource blocks in Polar:
resource Document {
    permissions = ["read", "write", "delete"];
    roles = ["viewer", "editor", "owner"];

    "read" if "viewer";
    "write" if "editor";
    "delete" if "owner";
}

has_role(user, role, document) if
    role in user.roles and
    document.owner = user.id;

This example defines a resource block for documents, specifying permissions and roles, and a rule for assigning roles.

Getting Started

  1. Install Oso:

    pip install oso
    
  2. Create a policy file (e.g., policy.polar):

    allow(actor, action, resource) if
        has_permission(actor, action, resource);
    
  3. Use Oso in your application:

    from oso import Oso
    
    oso = Oso()
    oso.load_file("policy.polar")
    
    # Check authorization
    if oso.is_allowed(user, "read", document):
        # Allow access
    else:
        # Deny access
    

Competitor Comparisons

4,924

Open Source, Google Zanzibar-inspired permissions database to enable fine-grained authorization for customer applications

Pros of SpiceDB

  • Designed for high-performance, scalable authorization
  • Supports multi-tenant environments out of the box
  • Provides a gRPC API for easy integration with various languages and platforms

Cons of SpiceDB

  • Steeper learning curve due to its more complex architecture
  • Requires separate deployment and management of the SpiceDB service
  • Less flexible for embedding directly into applications

Code Comparison

SpiceDB (using zed language):

definition user {}

definition document {
    relation viewer: user
    relation editor: user
    permission view = viewer + editor
    permission edit = editor
}

Oso (using Polar language):

allow(user, "view", document) if
    has_role(user, "viewer", document) or
    has_role(user, "editor", document);

allow(user, "edit", document) if
    has_role(user, "editor", document);

Both projects offer powerful authorization solutions, but they cater to different use cases. SpiceDB is better suited for large-scale, distributed systems requiring high performance and scalability. Oso, on the other hand, provides a more flexible, embeddable solution that can be easily integrated into existing applications with less overhead. The choice between the two depends on the specific requirements of your project, such as scale, performance needs, and integration preferences.

17,484

An authorization library that supports access control models like ACL, RBAC, ABAC in Golang: https://discord.gg/S5UjpzGZjN

Pros of Casbin

  • Supports multiple programming languages and frameworks
  • Offers more built-in model types (e.g., RBAC, ABAC, ACL)
  • Has a larger community and more extensive documentation

Cons of Casbin

  • Steeper learning curve due to its flexibility and complexity
  • Requires more configuration and setup compared to Oso
  • Less focus on developer experience and ease of use

Code Comparison

Casbin policy definition:

[request_definition]
r = sub, obj, act

[policy_definition]
p = sub, obj, act

[policy_effect]
e = some(where (p.eft == allow))

[matchers]
m = r.sub == p.sub && r.obj == p.obj && r.act == p.act

Oso policy definition:

allow(user: User, "read", document: Document) if
    user.role == "admin" or
    document.owner == user;

Casbin offers more flexibility in defining complex policies but requires more verbose configuration. Oso provides a more intuitive and concise syntax for defining policies, making it easier for developers to understand and maintain.

Both libraries aim to simplify authorization in applications, but they take different approaches. Casbin focuses on versatility and supporting multiple languages, while Oso prioritizes developer experience and integration with existing codebases.

9,617

Open Policy Agent (OPA) is an open source, general-purpose policy engine.

Pros of OPA

  • More mature and widely adopted in enterprise environments
  • Supports multiple policy languages (Rego, JSON, YAML)
  • Extensive integration options with various cloud-native technologies

Cons of OPA

  • Steeper learning curve, especially for Rego language
  • Can be more complex to set up and configure for smaller projects
  • May introduce performance overhead for large-scale policy evaluations

Code Comparison

Oso (Polar language):

allow(user, "read", resource) if
    user.role = "admin" or
    resource.public = true;

OPA (Rego language):

allow {
    input.user.role == "admin"
}
allow {
    input.resource.public == true
}

Summary

OPA is a more established and feature-rich policy engine, suitable for complex enterprise environments. It offers greater flexibility but may require more effort to learn and implement. Oso, on the other hand, provides a simpler, more developer-friendly approach, making it easier to integrate into smaller projects or for teams new to policy-as-code. The choice between the two depends on the specific requirements, scale, and complexity of the project at hand.

1,112

Warrant is a highly scalable, centralized authorization service based on Google Zanzibar. Use it to define, enforce, query, and audit application authorization and access control.

Pros of Warrant

  • Offers a more comprehensive authorization solution with built-in user management and audit logging
  • Provides a user-friendly dashboard for managing permissions and roles
  • Supports multi-tenancy out of the box, making it suitable for SaaS applications

Cons of Warrant

  • Less flexible policy language compared to Oso's Polar
  • Smaller community and ecosystem, with fewer integrations available
  • More opinionated approach, which may not suit all use cases

Code Comparison

Oso (using Polar language):

allow(user, "read", post) if
    user.role = "admin" or
    user.id = post.author_id;

Warrant (using JSON):

{
  "objectType": "post",
  "relation": "reader",
  "subject": {
    "objectType": "user",
    "objectId": "{userId}"
  }
}

Both Oso and Warrant are authorization libraries, but they take different approaches. Oso focuses on flexibility and expressiveness with its Polar language, while Warrant provides a more structured, JSON-based approach with additional features like user management and audit logging. Oso may be better suited for complex, custom authorization logic, while Warrant offers a more complete solution for typical SaaS applications with multi-tenancy requirements.

4,433

An open-source authorization as a service inspired by Google Zanzibar, designed to build and manage fine-grained and scalable authorization systems for any application.

Pros of Permify

  • Designed specifically for large-scale, complex authorization scenarios
  • Offers a graph-based permission model for more flexible and granular control
  • Provides built-in support for caching and performance optimization

Cons of Permify

  • Steeper learning curve due to its more complex architecture
  • Less extensive documentation and community support compared to Oso
  • May be overkill for simpler authorization needs

Code Comparison

Oso (Polar language):

allow(user, "read", post) if
    user.role = "admin" or
    post.author = user;

Permify (JSON-based schema):

{
  "schema": {
    "user": {
      "relations": {
        "admin": { "this": {} },
        "author": { "post": {} }
      }
    },
    "post": {
      "relations": {
        "reader": { "user": {} }
      },
      "permissions": {
        "read": {
          "union": [
            { "computedUserset": { "relation": "reader" } },
            { "tupleToUserset": { "tupleset": { "relation": "author" }, "computedUserset": { "relation": "admin" } } }
          ]
        }
      }
    }
  }
}
4,774

Open Source (Go) implementation of "Zanzibar: Google's Consistent, Global Authorization System". Ships gRPC, REST APIs, newSQL, and an easy and granular permission language. Supports ACL, RBAC, and other access models.

Pros of Keto

  • More mature project with a larger community and ecosystem
  • Supports multiple storage backends (SQL, Redis, in-memory)
  • Offers a REST API for integration with various languages and platforms

Cons of Keto

  • Steeper learning curve due to more complex architecture
  • Requires separate deployment and management of the Keto service
  • Less flexible policy language compared to Oso's Polar

Code Comparison

Keto (using REST API):

POST /relation-tuples
Content-Type: application/json

{
  "namespace": "files",
  "object": "file:1",
  "relation": "owner",
  "subject": "user:john"
}

Oso (using Polar language):

allow(user: User, "read", file: File) if
    file.owner = user;

Both Oso and Keto are authorization frameworks, but they take different approaches. Oso focuses on embedding authorization directly into applications using a custom policy language, while Keto provides a standalone service for managing relationships and permissions. Oso's approach may be simpler for smaller projects, while Keto's architecture is better suited for larger, distributed systems with complex authorization needs.

Convert Figma logo designs to code with AI

Visual Copilot

Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.

Try Visual Copilot

README

Deprecated

We have deprecated the legacy Oso open source library. We have plans for the next open source release and we’re looking forward to getting feedback from the community leading up to that point (please reach out to us in the Slack #help channel). In the meantime, if you’re happy using the Oso open source library now, nothing needs to change – i.e., we are not end-of-lifing (EOL) the library and we’ll continue to provide support and critical bug fixes. More context: here.

Oso

Development GitHub release (latest SemVer) Go version Maven version NPM version PyPI version RubyGems version Crates.io version Slack

What is Oso?

Oso is a batteries-included framework for building authorization in your application.

With Oso, you can:

  • Model: Set up common permissions patterns like role-based access control (RBAC) and relationships using Oso’s built-in primitives. Extend them however you need with Oso’s declarative policy language, Polar.
  • Filter: Go beyond yes/no authorization questions. Implement authorization over collections too - e.g., “Show me only the records that Juno can see.”
  • Test: Write unit tests over your authorization logic now that you have a single interface for it. Use the Oso debugger or REPL to track down unexpected behavior.

Oso offers libraries for Node.js, Python, Go, Rust, Ruby, and Java.

Our latest creation Oso Cloud makes authorization across services as easy as oso.authorize(user, action, resource). Learn about it.

Documentation

Community & Support

If you have any questions on Oso or authorization more generally, you can join our engineering team & hundreds of other developers using Oso in our community Slack:

Button

Share your story

We'd love to hear about your use case and experience with Oso. Share your story in our Success Stories issue.

Development

Core

Oso's Rust core is developed against Rust's latest stable release.

Language libraries

Oso's language libraries can be developed without touching the Rust core, but you will still need the Rust stable toolchain installed in order to build the core.

To build the WebAssembly core for the Node.js library, you will need to have wasm-pack installed and available on your system PATH.

Language requirements

To work on a language library, you will need to meet the following version requirements:

  • Java: 11+
    • Maven: 3.6+
  • Node.js: 12.20.0+
    • Yarn 1.22+
  • Python: 3.7+
  • Ruby: 2.4+
    • Bundler 2.1.4+
  • Rust: 1.46+
  • Go: 1.14+

Contributing & Jobs

See: CONTRIBUTING.md.

If you want to work on the Oso codebase full-time, visit our jobs page.

License

See: LICENSE.