Authentication using JWT #731
-
Hello guys, I'm seeking help where i want the client to connect to nats server using JWT, the requirement is that, only the client with valid jwt will be able to publish to the specific topic. On this setup, the server will still accept the connection even if the token is not valid ? On server, how to correct generate the user KEY and enforce that only valid token able to call spefiic topc ? The code i have is not working:
|
Beta Was this translation helpful? Give feedback.
Replies: 4 comments 4 replies
-
You need to use the var opts = new NatsOpts
{
AuthOpts = new NatsAuthOpts
{
Jwt = userJwt,
Seed = userKey,
},
}; Also consider using |
Beta Was this translation helpful? Give feedback.
-
Would be good if nats has documentation about cross platform integration between c# and go, using jwt based authentication. |
Beta Was this translation helpful? Give feedback.
-
@ghostidentity it should work. can you create a minimal example repo with what you have? I can try it on my side as well. |
Beta Was this translation helpful? Give feedback.
-
sample.zip |
Beta Was this translation helpful? Give feedback.
@ghostidentity I'm not a Go expert or running embedded server expert but there seems to be an issue loading the config for the server (e.g. make the config invalid or change the port for example, server still runs with defaults.) So the only way I got the config read was by adding this right before server new: