Code Monkey home page Code Monkey logo

oso's Introduction

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.

oso's People

Contributors

alexhafner avatar anirishduck avatar anniepoo avatar arusahni avatar dependabot[bot] avatar devmonkey22 avatar dhatch avatar fconil avatar finnrg avatar gj avatar gkaemmer avatar gneray avatar guara92 avatar hobofan avatar joshrotenberg avatar laxjesse avatar leina05 avatar litonico avatar mfashby avatar omusil24 avatar patrickod avatar plotnick avatar samraper avatar samscott89 avatar saolsen avatar snstanton avatar ssglaser avatar uncommoncense avatar veverkap avatar xfbs avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

oso's Issues

RBAC with domain

Alice is member at organization-A
Alice is accountant at organization-B

ie Alice have multiple roles in multiple domains

How do I write policy such that Alice can perform account Action in organization-B but not in organization-A.

Roadmap to 1.0?

Thanks for putting such a compelling library out into the world! As something like this would quickly become part of an application's core infrastructure, the "developer preview" state is slightly concerning as subsequent releases on the way to 1.0 could result in headaches for those using the library.

I was wondering if you could share:

  1. What do you perceive as being the roadmap to 1.0?
  2. How drastic do you predict potential API changes to be?
  3. Do you have a general timeline for a stable release?

I understand that answers to the above are conjecture, and aren't commitments to a feature-set or timeline. Thanks!

Security warnings for oso 0.9.0 dependencies reported by `cargo audit`

$ cargo audit
    Fetching advisory database from `https://github.com/RustSec/advisory-db.git`
      Loaded 175 security advisories (from /home/ximon/.cargo/advisory-db)
    Updating crates.io index
    Scanning Cargo.lock for vulnerabilities (306 crate dependencies)
...
Crate:         dirs
Version:       1.0.5
Warning:       unmaintained
Title:         dirs is unmaintained, use dirs-next instead
Date:          2020-10-16
ID:            RUSTSEC-2020-0053
URL:           https://rustsec.org/advisories/RUSTSEC-2020-0053
Dependency tree: 
dirs 1.0.5
└── term 0.5.2
    ├── lalrpop 0.19.1
    │   ├── polar-core 0.9.0
    │   │   └── oso 0.9.0

...

Crate:         term
Version:       0.5.2
Warning:       unmaintained
Title:         term is looking for a new maintainer
Date:          2018-11-19
ID:            RUSTSEC-2018-0015
URL:           https://rustsec.org/advisories/RUSTSEC-2018-0015
Dependency tree: 
term 0.5.2
├── lalrpop 0.19.1
│   ├── polar-core 0.9.0
│   │   └── oso 0.9.0

Auditing

This is an external tracking issue to:

  1. Gauge interest from the community for this feature
  2. Learn about what you'd want to see out of it if we worked on it.

So please:

  1. Upvote the issue if it's important to you, and
  2. Comment with any relevant info on your requirements use cases, etc.

Thanks!

PS We do all our internal engineering issue tracking separately in Notion, so you won't necessarily see regular updates to the project status here even once we begin work.

Is this ABAC?

Hi there

Is OSO a way of handling ABAC (attribute based access control)?

Typescript support

Hello there,

I appreciate very much this awesome tool that fits very well with the project I am working on.
I am wondering if there somewhere is planned a integration with font-end (Angular/Typescript) side to validate policies.

Can be very powerful to restrict component access based on roles for example.

Thanks a lot for a such awesome tool and keep going!

Express integration

This is an external tracking issue to:

  1. Gauge interest from the community for this feature
  2. Learn about what you'd want to see out of it if we worked on it.

So please:

  1. Upvote the issue if it's important to you, and
  2. Comment with any relevant info on your requirements use cases, etc.

Thanks!

PS We do all our internal engineering issue tracking separately in Notion, so you won't necessarily see regular updates to the project status here even once we begin work.

End-user configurable Polar policies/rules

Summary

We want to expose a safe (i.e., sandboxed) way for end users to write custom, dynamic Polar policies.


This is an external tracking issue to:

  1. Gauge interest from the community for this feature
  2. Learn about what you'd want to see out of it if we worked on it.

So please:

  1. Upvote the issue if it's important to you, and
  2. Comment with any relevant info on your requirements use cases, etc.

Thanks!

PS We do all our internal engineering issue tracking separately in Notion, so you won't necessarily see regular updates to the project status here even once we begin work.

ruby: JSON trace nesting hinders successful evaluation

Hi there! It's been fun to play with oso so far. 😃

One observation: the ruby library (probably the other languages as well?) uses JSON to communicate, and running a toy example, I've triggered a case where the trace is responsible for an evaluation that otherwise was successful.

My toy code is fib:

fib(0, 1) if cut;
fib(1, 1) if cut;
fib(n, a+b) if fib(n-1, a) and fib(n-2, b);

running this with oso fib.polar, and querying fib(12, x), I get:

Traceback (most recent call last):
        15: from b/oso:29:in `<main>'
        14: from b/oso:29:in `load'
        13: from /Users/stephan/Misc/oso/languages/ruby/bin/oso:7:in `<top (required)>'
        12: from /Users/stephan/Misc/oso/languages/ruby/lib/oso/polar/polar.rb:96:in `repl'
        11: from /Users/stephan/Misc/oso/languages/ruby/lib/oso/polar/polar.rb:96:in `loop'
        10: from /Users/stephan/Misc/oso/languages/ruby/lib/oso/polar/polar.rb:112:in `block in repl'
         9: from /Users/stephan/Misc/oso/languages/ruby/lib/oso/polar/polar.rb:112:in `to_a'
         8: from /Users/stephan/Misc/oso/languages/ruby/lib/oso/polar/polar.rb:112:in `each'
         7: from /Users/stephan/Misc/oso/languages/ruby/lib/oso/polar/polar.rb:112:in `each'
         6: from /Users/stephan/Misc/oso/languages/ruby/lib/oso/polar/polar.rb:112:in `each'
         5: from /Users/stephan/Misc/oso/languages/ruby/lib/oso/polar/query.rb:115:in `block in start'
         4: from /Users/stephan/Misc/oso/languages/ruby/lib/oso/polar/query.rb:115:in `loop'
         3: from /Users/stephan/Misc/oso/languages/ruby/lib/oso/polar/query.rb:116:in `block (2 levels) in start'
         2: from /Users/stephan/Misc/oso/languages/ruby/lib/oso/polar/ffi/query.rb:60:in `next_event'
         1: from /Users/stephan/.rbenv/versions/2.5.3/lib/ruby/2.5.0/json/common.rb:156:in `parse'
/Users/stephan/.rbenv/versions/2.5.3/lib/ruby/2.5.0/json/common.rb:156:in `parse': nesting of 101 is too deep (JSON::NestingError)

I've added a puts event.to_s in lib/oso/polar/ffi/query.rb, and it looks like it's the trace that's too deeply nested. (The Result bindings are there, so the query was evaluated successfully.)

Skimming the ruby code, I'm not certain that the trace is actually used; however, I've found no way to have JSON.parse ignore a certain key.

Related question: have you considered using different formats for this? (Anything well-supported enough across languages, flatbuffers, protobuf, ...) I'd suspect that there's performance wins here... 🤔

Error "inline query result was false", but which one?

When using ?= ... inline queries to verify that a Polar policy behaves as expected, in the event that a query fails the error message output by Oso doesn't indicate the query that failed but only says "inline query result was false". I encountered this with Oso 0.8.1 for Rust but looking at the code in the main branch it seems to be the same:

    fn check_inline_queries(&mut self) -> crate::Result<()> {
        while let Some(q) = self.inner.next_inline_query(false) {
            let query = Query::new(q, self.host.clone());
            match query.collect::<crate::Result<Vec<_>>>() {
                Ok(v) if !v.is_empty() => continue,
                Ok(_) => return lazy_error!("inline query result was false"),
                Err(e) => return lazy_error!("error in inline query: {}", e),
            }
        }
        check_messages!(self.inner);
        Ok(())
    }

Setting environment variable POLAR_LOG=1 helps a bit as you can work out the last query that was being executed, but it's not that easy as you have to look at the log statement indentation to try and work out where the start of the query execution was and thus what the root query being executed was.

Parsing error when trying to assign list variable

When trying to assign a variable in a rule where one list item references an object property, I am running into a syntax parsing error "did not expect to find the token ']' at line X"

resource_scope(actor: Person, "read", "Person", filters) if
    filters = ["id", "=", actor.id];

The same rule works fine if assigning a dictionary instead of list:

resource_scope(actor: Person, "read", "Person", filters) if
    filters = { id: actor.id };

As a workaround, the following will parse correctly:

resource_scope(actor: Person, "read", "Person", filters) if
    field = actor.id and
    filters = ["id", "=", field];

cut wasn't a good name in the 1970s

Cut is pretty meaningless. It's hard for beginning Prolog students to understand. Let's name cut something
more meaningful

I suggest commit - "commit to this rule"

Alternatives are found, use_rule, only.

The cut-fail pattern is something we can encourage by providing !, fail as a primitive.
I suggest impossible. Alternatives give_up, abort, no.

Improvements to debugger

This is an external tracking issue to:

  1. Gauge interest from the community for this feature
  2. Learn about what you'd want to see out of it if we worked on it.

So please:

  1. Upvote the issue if it's important to you, and
  2. Comment with any relevant info on your requirements use cases, etc.

Thanks!

PS We do all our internal engineering issue tracking separately in Notion, so you won't necessarily see regular updates to the project status here even once we begin work.

Support for end-user configurable roles ("custom roles")

Summary

Support for exposing custom roles to end users.

Today

It's currently possible to set up a custom role system and dynamically check a user's role(s) in an oso policy.

We've sketched out an example of the above in a Django sample app.

Future

Similar to the built-in roles work available today in the SQLAlchemy integration, we want to provide an out-of-the-box solution for custom roles in all of our language and framework integrations. It will be an extension of the existing roles work in the SQLAlchemy library — likely with a new custom role API for dynamically creating and managing custom roles.


This is an external tracking issue to:

  1. Gauge interest from the community for this feature
  2. Learn about what you'd want to see out of it if we worked on it.

So please:

  1. Upvote the issue if it's important to you, and
  2. Comment with any relevant info on your requirements use cases, etc.

Thanks!

PS We do all our internal engineering issue tracking separately in Notion, so you won't necessarily see regular updates to the project status here even once we begin work.

Haskell library

It can be interesting to have it in Haskell.
For example, to integrate it with an API wrote using Yesod framework.

Rails integration

This is an external tracking issue to:

  1. Gauge interest from the community for this feature
  2. Learn about what you'd want to see out of it if we worked on it.

So please:

  1. Upvote the issue if it's important to you, and
  2. Comment with any relevant info on your requirements use cases, etc.

Thanks!

PS We do all our internal engineering issue tracking separately in Notion, so you won't necessarily see regular updates to the project status here even once we begin work.

Can we have dotnet core support?

I really like how this is well structured. But the backend is written in dotnet core. Are they any examples to add support for c# dotnet core?

Route-level authorization & multiple enforcement points

This is an external tracking issue to:

  1. Gauge interest from the community for this feature
  2. Learn about what you'd want to see out of it if we worked on it.

So please:

  1. Upvote the issue if it's important to you, and
  2. Comment with any relevant info on your requirements use cases, etc.

Thanks!

PS We do all our internal engineering issue tracking separately in Notion, so you won't necessarily see regular updates to the project status here even once we begin work.

oso across multiple services

This is an external tracking issue to:

  1. Gauge interest from the community for this feature
  2. Learn about what you'd want to see out of it if we worked on it.

So please:

  1. Upvote the issue if it's important to you, and
  2. Comment with any relevant info on your requirements use cases, etc.

Thanks!

PS We do all our internal engineering issue tracking separately in Notion, so you won't necessarily see regular updates to the project status here even once we begin work.

spurious singleton warning when using register_constant

With r.rb as

require 'oso'

$polar=<<POLAR
test(b) if
  b = input.foo;
POLAR

input = {"foo" => "baz"}

o = Oso.new
o.load_str($polar)
o.register_constant('input', value: input)

x = Oso::Polar::Variable.new('x')
puts o.query_rule('test', x).force

I get the following output when running the script:

$ bundle exec ruby ../osoq/r.rb
Singleton variable input is unused or undefined, see <https://docs.oso.dev/using/polar-syntax.html#variables>
002:   b = input.foo;
           ^
{"x"=>"baz"}

It seems to work alright, but the warning is wrong?

Spring Integration

This is an external tracking issue to:

  1. Gauge interest from the community for this feature
  2. Learn about what you'd want to see out of it if we worked on it.

So please:

  1. Upvote the issue if it's important to you, and
  2. Comment with any relevant info on your requirements use cases, etc.

Thanks!

PS We do all our internal engineering issue tracking separately in Notion, so you won't necessarily see regular updates to the project status here even once we begin work.

Tail call optimization

This is an external tracking issue to:

Gauge interest from the community for this feature
Learn about what you'd want to see out of it if we worked on it.
So please:

Upvote the issue if it's important to you, and
Comment with any relevant info on your requirements use cases, etc.
Thanks!

PS We do all our internal engineering issue tracking separately in Notion, so you won't necessarily see regular updates to the project status here even once we begin work.

pypi oso 32-bit ?

Is there any particular reason why pypi is missing a 32 bit version for windows? I see the 64bit is there and 32 seems to be for all other OS's

Authorization-Dependent UI Elements (from backend)

This is an external tracking issue to:

  1. Gauge interest from the community for this feature
  2. Learn about what you'd want to see out of it if we worked on it.

So please:

  1. Upvote the issue if it's important to you, and
  2. Comment with any relevant info on your requirements use cases, etc.

Thanks!

PS We do all our internal engineering issue tracking separately in Notion, so you won't necessarily see regular updates to the project status here even once we begin work.

.NET Support

This looks like a great library and I think adding .NET support would be really useful.

ORM model, record, field access control enforcement & policy

This is an external tracking issue to:

  1. Gauge interest from the community for this feature
  2. Learn about what you'd want to see out of it if we worked on it.

So please:

  1. Upvote the issue if it's important to you, and
  2. Comment with any relevant info on your requirements use cases, etc.

Thanks!

PS We do all our internal engineering issue tracking separately in Notion, so you won't necessarily see regular updates to the project status here even once we begin work.

Tree-sitter Parser for Polar

Tree-sitter is a parser generator tool and an incremental parsing library. It can build a concrete syntax tree for a source file and efficiently update the syntax tree as the source file is edited.

Tree-sitter is currently used by Atom and Neovim (in 0.5).

See https://tree-sitter.github.io/tree-sitter/ for more details

Starlette/FastAPI integration

This is an external tracking issue to:

  1. Gauge interest from the community for this feature
  2. Learn about what you'd want to see out of it if we worked on it.

So please:

  1. Upvote the issue if it's important to you, and
  2. Comment with any relevant info on your requirements use cases, etc.

Thanks!

PS We do all our internal engineering issue tracking separately in Notion, so you won't necessarily see regular updates to the project status here even once we begin work.

Built-in support for assigning roles to user groups

Include a user group model in the definition of a role, so that roles can be assigned to user groups as well. Build in features for writing role-based policies over groups and relating roles from groups to the users in the group.

Support for Rust

I known that is written in Rust... but the support for Rust is missing? Reading the documentation I can see any Rust type.

Polar standard library

This is an external tracking issue to:

Gauge interest from the community for this feature
Learn about what you'd want to see out of it if we worked on it.
So please:

Upvote the issue if it's important to you, and
Comment with any relevant info on your requirements use cases, etc.
Thanks!

PS We do all our internal engineering issue tracking separately in Notion, so you won't necessarily see regular updates to the project status here even once we begin work.

sqlalchemy-oso: get_resource_users_by_role fails when used with a resource not named "repository"

Hi there,

thank your for an interesting library, it's very much appreciated.
I played around with sqlalchemy-oso today and encountered the following bug:

When you create a ResourceRoleModel between a generic "user" model and a resource that is not named "repository" then trying to get all the users for a specific role on a specific resource fails (e.g. oso_roles.get_resource_users_by_role(
db_session, organization, "ADMIN"
)):

sqlalchemy.exc.InvalidRequestError: Entity '<class 'app.models.organization_role.OrganizationRole'>' has no property 'repository'

In this case my resource was named "organization". The expectations was that a list of all users with the role "ADMIN" or an empty list was returned, but an exception was raised.

This is due to the fact that in the function "get_resource_users_by_role" the users query has a "filter_by" with a hardcoded "repository" property.

.filter_by(repository=resource, name=role_name)

I can provide a pull request if this is welcome. I verified locally that you can just get the resources name and use that in the filter instead of a hardcoded value.

Let me know what you think.

All the best.

Question: large no of policies and load changes in policies.

How can I implement watcher to detect and update policy without restarting server.
load_str(polar, "role(user, role_name) if user.role = role_name;", "somefile.policy") does not saves to file.

I have background workers updating policies, assigning role to user in a organization on user creation.
I need to check newly created users policy.

Policy validation/testing/linting

This is an external tracking issue to:

  1. Gauge interest from the community for this feature
  2. Learn about what you'd want to see out of it if we worked on it.

So please:

  1. Upvote the issue if it's important to you, and
  2. Comment with any relevant info on your requirements use cases, etc.

Thanks!

PS We do all our internal engineering issue tracking separately in Notion, so you won't necessarily see regular updates to the project status here even once we begin work.

TypeORM integration

A TypeORM integration would include support for:


This is an external tracking issue to:

  1. Gauge interest from the community for this feature
  2. Learn about what you'd want to see out of it if we worked on it.

So please:

  1. Upvote the issue if it's important to you, and
  2. Comment with any relevant info on your requirements use cases, etc.

Thanks!

PS We do all our internal engineering issue tracking separately in Notion, so you won't necessarily see regular updates to the project status here even once we begin work.

IDE plugins

This is an external tracking issue to:

  1. Gauge interest from the community for this feature
  2. Learn about what you'd want to see out of it if we worked on it.

So please:

  1. Upvote the issue if it's important to you, and
  2. Comment with any relevant info on your requirements use cases, etc.

Thanks!

PS We do all our internal engineering issue tracking separately in Notion, so you won't necessarily see regular updates to the project status here even once we begin work.

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.