Permissions Violation for Publish does not throw an exception
See original GitHub issueSteps to repro:
- Create a user that has these permissions: CLIENT = { publish = { allow: [“sub.>”]} subscribe = “sub.>” }
users = [ {user: client, password: ccc, permissions: $CLIENT} ]
Run the following xUnit test and observe no exception is thrown
[Theory]
[InlineData("client", "ccc", "BAD!", true)]
public void PublishPermission(string userName, string password, string subject, bool pass)
{
ConnectionFactory cf = new ConnectionFactory();
var options = ConnectionFactory.GetDefaultOptions();
options.User = userName;
options.Password = password;
using (var connection = cf.CreateConnection(options))
{
connection.Publish(subject, Encoding.UTF8.GetBytes("Hello"));
var error = connection.LastError;
}
}
Issue Analytics
- State:
- Created 2 years ago
- Comments:8 (3 by maintainers)
Top Results From Across the Web
NATS ErrAuthorization error hidden by STAN ErrTimeout
Start up a NATS Streaming server with nats configuration with a user that doesn't have permission to publish to a channel.
Read more >NATS-How to set the subscribe and publish permission ...
A publish to a stream only requires permission to the actual subject of the message, in this case test . What appears to...
Read more >How to set the subscribe and publish permission when ...
Hi! I would set auth permission, but it seems different when using request-reply mode. Here is my setting: values.yaml. users: -user: test
Read more >Exception Throwing - Framework Design Guidelines
✔️ DO document all exceptions thrown by publicly callable members because of a violation of the member contract (rather than a system failure) ......
Read more >Troubleshoot permission and security issues - ASP.NET
This article describes how to troubleshoot common permissions and security-related issues in ASP.NET.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
This is a race condition between processing the error and closing the connection and Publish is non-blocking w/r/t publish errors. If the client detects the closed connection first, it’ll handle things as if the the connection was closed. If the client processes the error first, you’ll get an async error notification if an async error handler is set and LastError would be set.
For this test, if you put a sleep or Flush() after the publish to allow the test time to process the error message, you should see LastEx set.
I don’t believe the server will close the connection on a publish error, I suspect the connection is being closed by dispose when falling out of the using block.
I am evaluating how nats client handles permission / publish errors.