Closed svzaharov closed 7 months ago
In JetStream, consuming messages is actually accessing a consumer that has a filtered subject that would be test.a
, but at the core level if you do not want an account to access that consumer via a pull request you need to restrict access to the consumer itself and the pull request.
$JS.API.CONSUMER.MSG.NEXT.<STREAM>.<CONSUMER>
If you want to restrict what consumers and app can create, restrict this subject..
$JS.API.CONSUMER.CREATE.<STREAM> $JS.API.CONSUMER.DURABLE.CREATE.<STREAM>.>
@svzaharov Expanding on this a bit, when creating a consumer (push or pull), there is the ability to set a filter on the underlying stream, e.g. a consumer by user A with a filter on test.a
and a separate one for user B
with test.b
as a filter. In the case of a pull consumer, given a stream named TEST
and two consumers A
and B
, the permission list for A and B would need $JS.API.CONSUMER.MSG.NEXT.TEST.A
and $JS.API.CONSUMER.MSG.NEXT.TEST.B
, respectively. This would then allow the client applications to send these requests requests.
Note, the _INBOX.>
permission would need to be present as well since a one-off random subject is created for delivery of messages per fetch request. If you need [user-level scoped inboxes, there is a way to define custom inbox prefixes in the client and then you can set a permission like _INBOX_A.>
.
Closing this for now since it is an older issue/question. Feel free to follow-up if you have additional questions.
Hello! We are testing authorization through nkey and have encountered a problem.
User B
has the following subscription privileges:subscribe: ["test.a", "_INBOX.>"]
Config details:Our case:
Streams
defines byadmin
userPull Consumers
- must be created in the applicationIn the following Java code, we create a pull consumer with subject filter (
test.b
) that should not be accessed due authorization configuration. But the consumer successfully creates and messages pulls without any restrictions...