User authentication via JWT token in NATS WebSocket

46 views
Skip to first unread message

Vitali Kotov

unread,
Mar 20, 2024, 11:39:14 AMMar 20
to nats

I have authorization service that giving JWT tokens with HS256 encryption (by hmac secret key). I want to configure NATS WebSocket for authenticate users via this tokens.

I have tried NATS resolver with URL but it only tried to get accounts in my case and doesn't anything else.

How to configure users authentication via external JWT tokens in NATS WebSocket?
And I have doubts: is it a normal practice to use NATS as WebSocket gateway for frontend?

Alberto Ricart

unread,
Mar 21, 2024, 3:40:00 PMMar 21
to nat...@googlegroups.com
The NATS server only supports ed25519-nkey signatures for JWT. If you are intending to pass a JWT that is not generated by one of the NATS libraries, it will not be recognized. 

You can however use a callout service that can authenticate your user however you would like - as a result, you would have to generate a NATS JWT so the NATS server allows the user to connect.

See:





--
You received this message because you are subscribed to the Google Groups "nats" group.
To unsubscribe from this group and stop receiving emails from it, send an email to natsio+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/natsio/a3d7f2f7-853f-4cb3-8221-5f7193f8f2adn%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages