Live data from Hacker News

Open Policy Agent

openpolicyagent.org

21–30 of 46 posts

Re: Open Policy Agent

#21

Earlier quoted context omitted.

I detailed a comparison of OPA and Cedar with verified permissions here: https://www.styra.com/knowledge-center/opa-vs-cedar-aws-veri...

Seems pretty damning. Why would someone choose Cedar? Is there some upside that isn’t captured here?

AWS uses it and the policy language is similar, and if you are all in on AWS, then it makes sense to keep it for consistency?

Re: Open Policy Agent

#22
post #18

I have found OPA to be a fairly reliable and performant system in production. We were able to build a scalable RBAC solution that used OPA as evaluators. We had around 40k OPA instances serving around 350K qps with p99.9 hovering around 6ms. You can find our talk here https://www.styra.com/resources/videos/snap-inc--snaps-journ...

~9qps per instance doesn't sound all that impressive unless there's more context to it?

The policy bundle were sharded and cached on the client side, so the QPS itself was not much of an impressive data point on the OPA front. On the cache side we were seeing a lot more traffic, ~2B qpm (queries per minute) on daily peaks and p99.9 around 20 us.

Re: Open Policy Agent

#23
We're currently evaluating OPA for adding RBAC to our open-source application [0]. We plan on using the Go API [1] and doing the policy eval directly in our app since our app is also written in Go.

The thinking is we'll have some basic built-in policies (like admins can do X, editors can do Y, etc) but also allow users to configure their own policies if they want by writing rego and loading their policy rules at startup time (via config). We'd document the inputs that we pass to the evaluation call such as request headers, IP, role, etc.

I'm curious if anyone has ever tried something like this or similar?

[0] https://github.com/flipt-io/flipt

[1] https://www.openpolicyagent.org/docs/latest/integration/#int...

Re: Open Policy Agent

#24
If you are looking for TLDR:

1. Define policies using declarative language Rego

2. Deploy OPA alongside your service as a sidecar in Kubernets

3. Make your service queries OPA when it needs to make policy decisions, passing the current state/context as input.

4. OPA evaluates the policies written in Rego against the input and returns a decision (allow or deny) back to your service.

Found it's hard to convince everyone around to use OPA/Rego and wrap into a managed service. The main objection - wrapping another DSL (domain-specific language) is hard.

However it was relatively simple to convince my team to use featured complete Go library Ladon https://github.com/ory/ladon

Ladon is inspired by AWS IAM Policies.

{

  "description": "One policy to rule them all.",

  "subjects": ["users:", "users:maria", "groups:admins"],

  "actions" : ["delete", ""],

  "effect": "allow",

  "resources": [
    "resources:articles:",
    "resources:printer"
  ],

  "conditions": {

    "remoteIP": {

        "type": "CIDRCondition",

        "options": {

            "cidr": "192.168.0.1/16"

        }

    }

  }
}

All policies are loaded on the app start, stored in memory (not DB) and checked with the help of small middleware which triggered the following function.

func (l *Ladon) DoPoliciesAllow(r *Request, policies []Policy) (err error)

https://github.com/ory/ladon/blob/972387f17e29c529ad3ff42a84...

Very negligible perfomance hit. Code is very simple, hackable, and can be subject for further optimisations.

Ladon is very fast. It's possible to run all user groups against all CRUD routes, and get the basic permission matrix or build some simple UI forms to test condition for better control.

P.s. Feel free to ping me in private @reactima (github, telegram) if you want to discuss the edge cases for the above.

Re: Open Policy Agent

#25
post #7

Curious what folks think about this versus cedar ( https://www.cedarpolicy.com/ ), the open source policy engine behind aws verified permissions.

I work in a highly regulated environment and evaluated using Cedar or OPA. The biggest advantage to OPA was the flexibility. This enabled not just an authorization decision, but the why behind it. No more questions of why did this person/system gain (or was denied) access, combing through dozens of rules to find the matching statements. Just pull up the log and read the results… This is incredibly useful during audit…

Is that issue with Cedar related to their design or just the current way it's exposed by AWS?

Re: Open Policy Agent

#26
post #2

My team is using OPA in a re-build of an application that we support. One of the main goals of the rebuild is to ensure we don't end up in a situation where every little rule change (including UAM changes) requires a full rebuild/deploy cycle of the app. OPA replaces a complex hard-coded, and largely inscrutable UAM model with a (still complex), but flexibly defined, independently testable, and easily inspectable sin…

Curious if you have any lessons learned worth sharing. Our journey was like

1: Yeah, we can use OPA to get rid of all this legacy spaghetti code!

2: Wow this PoC really proves out the idea!

3: Whoa we have three use cases now running in production!

4: Wait, these remaining 20 use cases are way more complex. To our surprise, all this legacy spaghetti code _exists for a reason_.

5: We now have 5 use cases in production but the Rego is now quite convoluted and our application logic has actually increased in complexity.

6: Red button: okay this is going horribly wrong. Back out this whole thing.

7: Recognition: the reason this has gone horribly wrong is because the spaghetti code combines pure logic and side effects in a way that did not map well with OPA.

8: Regroup: first step is to refactor all the legacy code and separate policy logic from side effects in a meaningful way.

9: Refactor: implement the above redesign. The policy classes all now map naturally to Rego for all 23 use cases! Let's do it!

10: Reality: we don't want to. Our codebase is well-structured now and we like it. Adding OPA now feels like an unnecessary layer, an additional potential for network timeouts etc to creep in, an extra thing to maintain, an extra special case to handle in our safe deployment pipeline, an extra language to train developers on. Now _maybe_ if we ever wanted other teams to write up and maintain their own Rego policies, then _maybe_ we'd consider going with it in the future, but for now the reality is our team would end up doing that work for them anyway, and it doesn't seem worth the tradeoff.

Anyway, lesson learned: don't expect it to magically clean up all the garbage in your existing code. You'll do it wrong and things will be worse than when you started. Clean that up first, and _then_ decide whether and how you want to adopt OPA for your remaining needs.

Re: Open Policy Agent

#27

We're currently evaluating OPA for adding RBAC to our open-source application [0]. We plan on using the Go API [1] and doing the policy eval directly in our app since our app is also written in Go. The thinking is we'll have some basic built-in policies (like admins can do X, editors can do Y, etc) but also allow users to configure their own policies if they want by writing rego and loading their policy rules at star…

That's all pretty easily doable. Just make your app take in a bundle with package defined in the manifest. Document your call points, as you've said.

Re: Open Policy Agent

#28
post #12

OPA is a great tool for implementing a policy-as-code system. But if you're trying to use it for application authorization (e.g. fine-grained authz for B2B SaaS or a set of internal applications), you may find that its policy story is strong, but it doesn't really have a "data plane": you either store data in a data.json file and rebuild the policy any time that data changes, or make an http.send call out of the poli…

This feels very much like OpenFGA[0]. I've been evaluating authorization tool for one of my side projects and honestly most tools feels like creating relationships in a graph-like database and querying to see if there is/isn't relationship between two entities. Is there more to this (besides the implementation details) or am I missing something from these tools?

[0] https://openfga.dev/

Re: Open Policy Agent

#29
post #28
post #12

OPA is a great tool for implementing a policy-as-code system. But if you're trying to use it for application authorization (e.g. fine-grained authz for B2B SaaS or a set of internal applications), you may find that its policy story is strong, but it doesn't really have a "data plane": you either store data in a data.json file and rebuild the policy any time that data changes, or make an http.send call out of the poli…

This feels very much like OpenFGA[0]. I've been evaluating authorization tool for one of my side projects and honestly most tools feels like creating relationships in a graph-like database and querying to see if there is/isn't relationship between two entities. Is there more to this (besides the implementation details) or am I missing something from these tools? [0] https://openfga.dev/

You're describing ReBAC, which is the paradigm popularized by Google's Zanzibar. There are alternatives like RBAC, and ABAC.

Re: Open Policy Agent

#30
post #28
post #12

OPA is a great tool for implementing a policy-as-code system. But if you're trying to use it for application authorization (e.g. fine-grained authz for B2B SaaS or a set of internal applications), you may find that its policy story is strong, but it doesn't really have a "data plane": you either store data in a data.json file and rebuild the policy any time that data changes, or make an http.send call out of the poli…

This feels very much like OpenFGA[0]. I've been evaluating authorization tool for one of my side projects and honestly most tools feels like creating relationships in a graph-like database and querying to see if there is/isn't relationship between two entities. Is there more to this (besides the implementation details) or am I missing something from these tools? [0] https://openfga.dev/

On the first point, OPA is much older than OpenFGA. To really illustrate the point, OPA became a graduated project about a year before OpenFGA had their first code drop in the public GitHub repo. The OpenFGA people are aware of OPA and I'm sure they learned from the tradeoffs OPA made.

To the main point, what you described reflects the current trends of authorization. Define a data model, define data that adheres to that model, write declarative rules that consume that model, make a decision based on those rules.

Where things really start to differ is the kind of data that they bind against and how do you write rules. E.g. OPA is often used for either ABAC (Attribute) or RBAC (Roles) while OpenFGA is looking at ReBAC (Relationships). Each has their complexity tradeoffs, depending on the system being implemented. How easy or difficult a system makes these kinds of checks has a significant impact on how you write policies.

Hope this helps!

Post reply on HN