oso
Oso is a batteries-included framework for building authorization in your application.
Top Related Projects
Open Source, Google Zanzibar-inspired permissions database to enable fine-grained authorization for customer applications
An authorization library that supports access control models like ACL, RBAC, ABAC in Golang: https://discord.gg/S5UjpzGZjN
Open Policy Agent (OPA) is an open source, general-purpose policy engine.
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.
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.
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
- 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.
- 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.
- 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
-
Install Oso:
pip install oso
-
Create a policy file (e.g.,
policy.polar
):allow(actor, action, resource) if has_permission(actor, action, resource);
-
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
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.
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.
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.
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.
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" } } }
]
}
}
}
}
}
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 designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual CopilotREADME
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
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
- To get up and running with Oso, try the Getting Started guide.
- Full documentation is available at docs.osohq.com.
- Check out Use Cases to learn more about how teams are using Oso in production.
- To learn about authorization best practices (not specific to Oso), read the Authorization Academy guides.
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:
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.
Top Related Projects
Open Source, Google Zanzibar-inspired permissions database to enable fine-grained authorization for customer applications
An authorization library that supports access control models like ACL, RBAC, ABAC in Golang: https://discord.gg/S5UjpzGZjN
Open Policy Agent (OPA) is an open source, general-purpose policy engine.
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.
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.
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.
Convert designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual Copilot