nats-io / nats-architecture-and-design

Architecture and Design Docs
Apache License 2.0
178 stars 20 forks source link

ADR-32: Logical permissions #145

Open bruth opened 1 year ago

MauriceVanVeen commented 1 year ago

Looks really cool! Decouples the configuration from the concrete subjects.

What I'm wondering, how would this work for consuming a stream/watching a KV?

I'm thinking that would be a combination of several permissions, for example:

js-create-ephemeral-consumer
js-consumer-next-msg
js-consumer-ack-reply
etc.

However, that would still require you to know the relationship between multiple permissions, as those need to be combined in order to: create an ephemeral consumer, start consuming from it, and maybe at some point delete the consumer, etc.

I like the syntax of @wallyqs as well, albeit a bit more verbose, it might be more concise with the addition of watching a stream for example:

    permissions = {
      jetstream: {
        streams { EVENTS = { allow: [ watch-ephemeral ] }}
      }
    }

With a short-hand like watch-ephemeral it might combine the ability to both create and delete an ephemeral consumer, as well as receive messages from it, handle heart beats/flow control, etc. This could make a leaf node scenario quite easy as well, just add a watch-ephemeral add a sourced stream on the leaf node and you're off.