Yordis Prieto
08/22/2023, 7:12 PMperfect
scenario, should somebody optimize for CQRS patterns and have a "centralized" (to some extent) service that has that extra data?vroldanbet
08/22/2023, 7:53 PMCaveats
, which allows you providing that request-specific context as input that guides the authorization decision. Keeping state around of such information wouldn't help, as it's specific to a request being performed.
In an Event Sourcing / CQRS architecture, the events with all information needed would be available to various consumers. Consumers listen to those events, and emit other events based out of those, and if needed denormalize that in a way that meets their application access patterns. SpiceDB would be another denormalized form of those Events, and someone needs to build an event processing pipeline that feeds all necessary data into SpiceDB that drives authorization decisions.
So in a Event Sourcing / CQRS architecture, the reason data relevant for authorization decisions is not available at request time is different to contextual information like HTTP request headers: it's because the application has decided that data wasn't relevant for their access patterns and did not denormalize it into their own database.
It's a tradeoff, but everything that can be stored on the SpiceDB side should be stored there if possible as it's how the "Zanzibar magic" can really happen and unleash its scale.
So your point, I don't think the "perfect" scenario is to have an intermediary service that provides data to SpiceDB: I think you make SpiceDB another consumer of Events in your architecture by building an Event processor that transform the relevant data into SpiceDB relationships.Yordis Prieto
08/22/2023, 8:03 PMdata
directive (I think it is) or SpiceDB, where you do-do save the relationship, you need a system that understands such data or can "querying" such data to decouple the authorization from the service entirely.
Right?vroldanbet
08/22/2023, 8:29 PMYordis Prieto
08/22/2023, 8:37 PMYordis Prieto
08/22/2023, 8:38 PMvroldanbet
08/22/2023, 8:40 PMYordis Prieto
08/22/2023, 8:41 PMvroldanbet
08/22/2023, 8:42 PMYordis Prieto
08/22/2023, 8:42 PMYordis Prieto
08/22/2023, 8:43 PMYordis Prieto
08/22/2023, 8:44 PMvroldanbet
08/22/2023, 8:44 PMCaveats
, but there could be other state that has been already provided to SpiceDB offbandYordis Prieto
08/22/2023, 8:44 PMYordis Prieto
08/22/2023, 8:47 PMIn the above example, a relationship can be written for the viewer relation to a user without a caveat OR with the ip_allowlist caveat.
Here is where I am worry, do I have to load at the App level that ip_allowlist
or do I push it using CQRS into the SpiceDB database?vroldanbet
08/22/2023, 8:47 PMYordis Prieto
08/22/2023, 8:48 PMvroldanbet
08/22/2023, 8:48 PMYordis Prieto
08/22/2023, 8:49 PMvroldanbet
08/22/2023, 8:50 PMvroldanbet
08/22/2023, 8:51 PMYordis Prieto
08/22/2023, 8:51 PMWhen(IpAllowed as e) -> SpiceDB.Write("ip_allowlist, e.ip)
vroldanbet
08/22/2023, 8:51 PMYordis Prieto
08/22/2023, 8:53 PMvroldanbet
08/22/2023, 8:55 PMWriteRelationships( resource: my_organization, relation: allowlist, subject: user:*, caveat "ip_allowlist", caveat_context(ip = e.ip)
vroldanbet
08/22/2023, 8:55 PMvroldanbet
08/22/2023, 8:56 PMYordis Prieto
08/22/2023, 8:58 PMvroldanbet
08/22/2023, 8:59 PMYordis Prieto
08/22/2023, 9:00 PMvroldanbet
08/22/2023, 9:01 PMYordis Prieto
08/22/2023, 9:02 PMYordis Prieto
08/22/2023, 9:02 PMYordis Prieto
08/22/2023, 9:03 PMYordis Prieto
08/22/2023, 9:03 PMhttps://cdn.discordapp.com/attachments/1143623814048141353/1143651666466455603/diataxis.pngβΎ
vroldanbet
08/22/2023, 9:03 PMYordis Prieto
08/22/2023, 9:04 PMYordis Prieto
08/22/2023, 9:04 PMYordis Prieto
08/22/2023, 9:05 PMvroldanbet
08/22/2023, 9:05 PMYordis Prieto
08/22/2023, 9:06 PMYordis Prieto
08/22/2023, 9:07 PMyordis
) and tag me on it, I allocate time for OSS work daily, and I can contribute a bit. At the very least sharing my experience as the end-user πYordis Prieto
08/22/2023, 9:07 PMvroldanbet
08/22/2023, 9:08 PM