Better HN
topnewbestaskshowjobs
Log inSign up

samjs

253 karma · joined Jul 6, 2017 (9y ago) · 86 submissions

Website: https://www.samjs.io GitHub: samscott89 - github.com/samscott89/
Submissions

comment 4y ago · link · parent

Well this was fun to see! I'm the CTO of Oso, where we're building Polar (the second of the links mentioned https://docs.osohq.com/).

I have a few really minor nitpicks, so will try and make up for it by adding to the discussion :)

First of all, it doesn't really make sense to talk about Datalog as a good language for authorization, because much like with Prolog there doesn't really exist a single implementation of it. OPA's language Rego is a datalog variant, and Polar started out as a Prolog variant (although it's not really recognisable as one any more).

And that's an important point because otherwise it would be pretty reasonable to decide that: logic programming is good for authorization => you should go find the most battle-tested language out there and use that. For example, there's SWI Prolog [1] and Scryer Prolog [2] as two of my favourites.

To me, the thing that is mind-blowing about logic programming, is (a) how powerful the paradigm is, and (b) how concisely you can implement a logic programming language. Take miniKanren [3] which is a full-blown logic language in a few hundred lines of code.

In my mind, the original article makes a decent case that logic programming is a good fit for authorization. And just generally I love anyone bringing attention to that :)

But in my opinion the reason logic programming is such a solid foundation for authorization logic is the pieces you can build on top of it. For Polar, we've added:

- Types! So you can write authorization logic over your data types and help structure your logic. We've implemented this by simply adding an additional operator into the language that can check types

- Authorization primitives like roles and relationships (RBAC and ReBAC). These are all backed by the logical rules, so can be easily extended with custom logic

- And last but not least... the ability to convert authorization logic into SQL [4]. Which is done by having the language return constraints over any unbound (free) variables.

To me this is what makes logic programming exciting for authorization. It gives you this small kernel of declarative programming, and gives you a ton of freedom to build on top.

[1] https://www.swi-prolog.org/

[2] https://github.com/mthom/scryer-prolog

[3] http://minikanren.org/

[4] https://www.osohq.com/post/authorization-logic-into-sql

comment 4y ago · link · parent

Thank you! We're looking forward to sharing more about Oso cloud too :)

comment 4y ago · link · parent

Indeed ;) https://news.ycombinator.com/item?id=28559608

comment 4y ago · link · parent

It's actually a pretty great question!

As others have mentioned, authorization often requires both a single method to authorize "can the user perform this action on this resource" as well as more flexible versions like "what are all the resources this user can perform this action on". That's one part of why authorization is hard, I wrote an article on this a little while ago [1]. At Oso (disclaimer: I'm the CTO), we solve this by turning authorization logic into SQL [2].

Supporting those APIs in a generic service definitely turns up the difficulty level -- you no longer have a single database to query.

The thing is, if you have multiple services, you might already be in that situation. If I need to query another service to ,e.g., find what projects a user belongs to, and then need to go combine that with data in my database, I'm going to need to start worrying about how to do that efficiently. In those situations starting to centralize that data + logic starts making sense -- we talk about this in [3]. So now there's a bunch of companies with different takes on how to best solve this, including Oso.

---

I feel bad about self-promoting so many links here... but we're passionate about this subject so we've been writing a lot about it!

[1]: https://www.osohq.com/post/why-authorization-is-hard

[2]: https://www.osohq.com/post/authorization-logic-into-sql

[3]: https://www.osohq.com/post/microservices-authorization-patte...

35.

Building a runtime reflection system for Rust(osohq.com ↗)

9 points · by samjs · 5y ago · discuss

comment 5y ago · link · parent

If you're interested in resource-based rbac [1] with list endpoints [2], Oso supports both! You're right, it's a tough problem, we've invested a ton of time to make this work well without needing to rearchitect your app.

(I'm cofounder/CTO at Oso).

[1]: https://docs.osohq.com/guides/rbac.html

[2]: https://docs.osohq.com/guides/data_filtering.html

comment 5y ago · link · parent

Oh, and if you’d be up for sharing any more info on how authorization _is_ done at fb, I’d love to chat. Email is in my profile :)

comment 5y ago · link · parent

Hey!

Thanks for the correction. I’ll get on updating that.

comment 5y ago · link · parent

Hey! Yep, you can totally use a policy engine like XACML or OPA with Zanzibar. We talk about that a little further down in the post.

The "public" example was meant to be a simple example of attribute-based access control but you could replace that with other similar ABAC examples for why you might need to bring in an additional policy engine.

comment 5y ago · link · parent

Thank you! You might also enjoy the series we've been writing, Authorization Academy: https://www.osohq.com/developers/authorization-academy

It builds up a bit more gently and introduces a lot more concepts than I could fit into one (already long) blog post.

comment 5y ago · link · parent

Thanks! I'll pass it on to the team :D

I've got to say, the folks at Intercom made it particularly fun. They were sending us traces and graphs from their internal systems when we trying to figure out some issues with them (e.g. we ran into this datadog context problem: https://github.com/DataDog/dd-trace-rb/issues/1389)

42.

Why Authorization Is Hard(osohq.com ↗)

303 points · by samjs · 5y ago · 49 comments

comment 5y ago · link · parent

Thank you! Pundit is awesome, they did such a great job with it and we drew a lot of inspiration from it.

We're heavily focusing on adoption of the open source product right now for helping developers with application authorization. We do currently charge for things like support + consulting, but in the future we're planning on providing additional functionality through a service that would be more on the operational/security side.

comment 5y ago · link · parent

Yeah, to be clear I think the Zanzibar authorization model is great! Super helpful to think about authorization logic in terms of relationships.

To give a simple example of an attribute-based control that is tough with the service model: if you want to express "anybody can read a document if it's public", then you need to push that "public" field into the service. Every attribute that you want to use for authorization becomes something that you need to either move or synchronise into the service. Or you leave that logic in the application.

comment 5y ago · link · parent

As a founder of a startup building an authorization product, I can definitely say it's super appealing to build this as a service! It makes for a an easier story around monetising it.

When we were building Oso [1], we were optimising for the best thing for developers, and reached the same conclusion as you... (a) It doesn't make sense to rearchitect your app to move all the data to a separate service, and (b) it's way less complex to build it in the application. That's why we're building Oso as an open source library instead. You get to leave your application data in the application, and don't need to worry about adding an external service to the critical path.

[1]: https://www.osohq.com/

comment 5y ago · link · parent

(Full transparency: I'm CTO/cofounder of Oso, a series A startup building an open source framework for authorization)

Super interesting how many companies are building authorization systems based on Zanzibar suddenly! This is a bit of a shameless plug, but I just wrote a blog post earlier today talking through how to build Zanzibar from scratch in ~150 lines of code: https://news.ycombinator.com/item?id=28076549

Not many people talk about how Zanzibar requires you re-architect your application around authorization when you really don't need to do that at all. Any sufficiently powerful authorization framework can handle the same flexibility. If not more, since most Zanzibar implementations can't handle simple attribute-based controls (e.g. anyone can read a document if its public). Which means you'll end up implementing a bunch of authorization logic in your app anyway.

---

Edit to add: I realise in hindsight I got a bit too absorbed in thinking about the Zanzibar part to say congrats on the launch! It's awesome to see the space heating up, and love to see more focus on the developer experience :)

47.

Building Google Zanzibar from Scratch(osohq.com ↗)

10 points · by samjs · 5y ago · discuss

comment 5y ago · link · parent

> It's crazy this still is part of the stack where there are no great solutions.

Seems like a few others have come to the same conclusion :)

We're working on this at Oso (https://osohq.com) - I'm the CTO. Oso is an open source framework for authorization. Policies can reference application directly, so any authorization decisions can be made dynamically based on the data. And your data doesn't need to leave your application.

> Often the issue is the inability to easily push down filters into the database or search index.

We actually support pushing down filters into the database directly through a feature we call... data filtering. We support Django and SQLAlchemy today (https://docs.osohq.com/python/guides/data_access.html) but will be making this available for non-ORM/non-Python users in the next few months.

comment 5y ago · link · parent

> What aspect of this makes it "highly scalable"?

The idea is to put all data in one place, and then aggressively optimise for answering queries about that data. For authorization you're pretty much always asking specific reachability questions. That's where the design of the index comes into it.

> Also, I was wondering: Are ALL permissions stored as an Object::relation pair? i.e. do you need to register permissions for all new entities relationships, or do you have some way of storing more dynamic permissions?

In Zanzibar, there is a configuration format for computing relationships dynamically. E.g. "anyone who is an editor of a document is a viewer of a document". I'm not sure if they implemented something like that.

If you're interested, I wrote a guide on relationship-based access control that includes a section on how Zanzibar(-like) systems fit in: https://www.osohq.com/academy/authorization-academy-chapter-...

comment 5y ago · link · parent

<3 Thank you!

comment 5y ago · link · parent

I've been writing about application authorization here: https://www.osohq.com/academy/chapter-2-architecture (I'm CTO at Oso, but these guides are not Oso specific). It covers this in the later part of the guide.

Depending on your requirements, yes that's kind of what happens if you want to centralise. It can make sense for Google-scale problems where you really do need to handle the complex graph of relationships between all users and resources, and doing that in any one service is non-trivial.

In practice though, a lot of service-oriented architectures can get the same benefits by having a central user management service, and keeping most of the authorization in each service. That central service can provide information like what organizations/teams/roles etc. the user belongs to, and then the individual services can make decisions based on that data.

This is the approach I covered with the hybrid approach. With this you can still implement most complex authorization models.

comment 5y ago · link · parent

Thank you for the kind words!

I'm pretty sure I know who you are in the slack, so I'll follow up with you there about the blog post :)

comment 5y ago · link · parent

Hi HN! I'm one of the founders of Oso, an open source library for authorization (someone posted us here a little while ago: https://news.ycombinator.com/item?id=25440741).

Over time, we've gotten a lot of questions from developers on authorization basics – like how to model roles, where to add authorization checks, or how to integrate permissions in the UI.

It turns out that there's not much information available on these topics that's technical, concrete and user-friendly. So, we started writing a series of guides on these topics to capture everything we've learnt, heard, and experienced ourselves.

The series is called Authorization Academy (https://www.osohq.com/developers/authorization-academy). The first few chapters cover architecture and modeling roles. Next we'll cover relationship-based access control, enforcement, and integrating permissions data into UIs. We have a lot of topics we'd like to write about, and they take a fair bit of time, but let us know if there's anything in particular you'd like to read about!

The guides cover authorization generically and are not specific to Oso, so they should be useful for anyone who is building authorization into their app or otherwise wants to learn about the area. Of course, if you'd like to learn more about Oso you can visit our site (https://www.osohq.com) or come talk with us in Slack (https://join-slack.osohq.com).

54.

Show HN: Authorization Academy – guides for building application authorization(osohq.com ↗)

15 points · by samjs · 5y ago · 3 comments

comment 5y ago · link · parent

> But authorization is rather tightly coupled to your service, and outsourcing that part would be much more of a challenge -- keeping authorization rules up-to-date with external systems is a difficult dependency management problem.

Strong agree. We're trying to strike the right balance with this problem with oso [1] (I'm a cofounder). By letting you separate the authorization logic from your code, and doing a lot of the thinking for you (how to design + implement roles etc), but ultimately the data *stays in the application*. There's such a blurry line between authZ and business logic that it doesn't make sense to fully outsource it.

[1]: https://www.osohq.com/

comment 5y ago · link · parent

My colleague pointed out that we do actually already include the dynamic libs as part of the release artifacts: https://github.com/osohq/oso/releases/tag/v0.9.0

However, without the header file right now.

We need to think through whether the C ABI is stable. It hasn't really changed in a while, but we haven't thought through the implications yet.

comment 5y ago · link · parent

Hey Rongxin! Thanks :) It's been a fun ride. I'm going to drop you a message, it's been far too long...

comment 5y ago · link · parent

> It would be great if that was provided and had a stable ABI + .so for the rust code that I could install through a .deb or .rpm instead of building through cargo.

This would be a great option. That's effectively how our build pipeline works anyway - we compile the polar-c-api [1] crate to a dynamic lib and embed in each language. If we made this available through package managers, we could also provide an alternative installation for, e.g. Python that didn't even need to use the precompiled wheel.

> It would be great if `serde` was opt-in through cargo features,

We rely on this for the FFI, since we pass events/messages back and forth as JSON. We _could_ make it opt-in for people using it in Rust projects though. Would that work for your use case?

Running our test suite [2] takes about 9 minutes. 4 of which is running (a) the pure Rust tests, (b) compiling the C library and running Python, Ruby, and Java tests, (c) building the WASM library and running Nodejs tests.

That's why I'm a little surprised by the time. You're right though, I didn't factor in the slowdown for the macos builds.

> Not trying to be overly critical, just trying to give a view! Compiling on other people's machines is expensive, a good way for me to buy into something like this instead of doing it myself (which is how I'm doing it right now!) is to reduce the dependency tree and make building stupid fast/easy.

Thank you! I appreciate the feedback. We did go out of our way to make it as easy as possible to install from whatever language package manager (e.g. pip install oso will take seconds). We weren't anticipating people would want to compile it themselves from scratch, so it's a helpful perspective to get.

[1]: https://github.com/osohq/oso/tree/main/polar-c-api

[2]: https://github.com/osohq/oso/runs/1540314680?check_suite_foc...

comment 5y ago · link · parent

No problem! These are fantastic questions.

Agreed! And I strongly recommend to anyone thinking about doing so to join our slack [1] and come chat with us :) We'll be happy to share our thoughts on this.

All these questions are also tempting me to go and put together a demo for this too...

[1]: https://join-slack.osohq.com/

123