Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Subscription Violation not returned as Subcribe error #1284

Open
bella-WI opened this issue Jul 4, 2024 · 2 comments
Open

Subscription Violation not returned as Subcribe error #1284

bella-WI opened this issue Jul 4, 2024 · 2 comments
Labels
proposal Enhancement idea or proposal

Comments

@bella-WI
Copy link

bella-WI commented Jul 4, 2024

Observed behavior

Im expirementing with the auth callout and setting permissions for clients connecting to my nats-server.
The following setup is happening:

  1. Im creating a client and connecting to the server with the following nats claims:
User claims nats: UserClaimsNats { publish: NatsSubjectPermissions { allow: ["_INBOX.>"], deny: [] }, subscribe: NatsSubjectPermissions { allow: ["allowed_subject"], deny: [] }, jwt_type: "user", version: 2 }
  1. The nats connections is created without 'Authorization Violation Errors'
  2. Im subscribing to a subject that is not allowed:
let _testsubscribe = nats_client
        .subscribe("this.is.not.allowed")
        .await
        .unwrap();
  1. Nats logs returning:
[1] 2024/07/04 09:56:26.024888 [TRC] 172.20.0.6:37146 - cid:619 - <<- [SUB this.is.not.allowed 1]
[1] 2024/07/04 09:56:26.024914 [TRC] 172.20.0.6:37146 - cid:619 - ->> [-ERR Permissions Violation for Subscription to "this.is.not.allowed"]
[1] 2024/07/04 09:56:26.024936 [ERR] 172.20.0.6:37146 - cid:619 - Subscription Violation - User "system_account_test_client", Subject "this.is.not.allowed", SID 1
[1] 2024/07/04 09:56:26.026861 [DBG] 172.20.0.6:37146 - cid:619 - Client connection closed: Client Closed
  1. unwarp() call on subcribe is not triggering a panic and the code continues.

Expected behavior

I would expect the subscribe to return an error in this case an the unwrap to trigger a warning.

Server and client version

nats-server: v2.10.16

Host environment

No response

Steps to reproduce

No response

@bella-WI bella-WI added the defect Suspected defect such as a bug or regression label Jul 4, 2024
@Jarema
Copy link
Member

Jarema commented Jul 4, 2024

Subscription violations are not send as a response to a subscribe, but as an asynchronous message sent to the client.
You can catch it with event callback

We're discussing options across the clients if that can be improved.

@Jarema Jarema added proposal Enhancement idea or proposal and removed defect Suspected defect such as a bug or regression labels Jul 4, 2024
@bella-WI
Copy link
Author

Any news on this topic?

@bella-WI bella-WI reopened this Aug 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
proposal Enhancement idea or proposal
Projects
None yet
Development

No branches or pull requests

2 participants