How to set the subscribe and publish permission when using request-reply in python?

168 views
Skip to first unread message

Wun

unread,
Aug 15, 2022, 4:12:03 AM8/15/22
to nats

Hi! I would set auth permission, but it seems different when using request-reply mode. Here is my setting:

values.yaml

users: 
    -user: test
     password: testtest
     permissions:
          subcribe: ["test"]
          pulbish: ["test"]

python code

nc = await nats.connect("nats://test:testtest@jetstream-nats:4222") 
js = nc.jetstream()
await js.add_stream(name="test", subjects=["test"]

Error message:

nats.errors.Error: nats: permissions violation for subscription to "_inbox.xxxxxxxxxxxx.*"
nats.errors.Error: nats: permissions violation for publish to "$js.api.stream.create.test"

If I change value.yaml to this, it would not show any error.

users: 
    -user: test
     password: testtest
     permissions:
          subcribe:  ["_INBOX.>"]
          pulbish:  ["$JS.API.STREAM.CREATE.>"]

But if I change value.yaml to this, it would occur the same error message

users: 
    -user: test
     password: testtest
     permissions:
          subcribe:  ["_INBOX.>"]
          pulbish:  ["$JS.API.STREAM.CREATE.test.>"]

===================================================================
nats.errors.Error: nats: permissions violation for subscription to "_inbox.xxxxxxxxxxxx.*"
nats.errors.Error: nats: permissions violation for publish to "$js.api.stream.create.test"

My question is HOW TO set the subscribe and publish permission when using request-reply?

If i want to set user "testuser" only can publish to stream "test" and subscribe "test", how to set my yaml file?

Here is my question post on stackoverflow, maybe it's more clear.
https://stackoverflow.com/questions/73357175/nats-how-to-set-the-subscribe-and-publish-permission-when-using-request-reply-in

Regards,
Wun
Reply all
Reply to author
Forward
0 new messages