You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Set up NATS operators, accounts, and JWT-based authentication using nsc.
Generate resolver configurations and publish accounts to a running NATS server.
Inspect keys, account claims, and signing seeds.
Usage
1. Set the issuer account credentials as environment variables
export NATS_ACCOUNT_KEY="..."# issuer public keyexport NATS_ACCOUNT_SECRET="..."# issuer seed
2. Update the NATS server WebSocket URL in example-client.ts if needed
constservers="ws://localhost:9222";// adjust host/port as necessary
3. Run the client example
ts-node example-client.ts
4. Observe the behavior
Subscriptions to allowed subjects succeed.
Subscriptions to prohibited subjects throw a permissions violation.
This README is designed for educational purposes and assumes the reader may refer to AUTHENTICATION.md for a full walkthrough of NATS JWT authentication setup.
This document explains how to set up JWT-based authentication for NATS using
nsc. It is intentionally deployment-agnostic and focuses purely on
concepts, commands, and verification.
[ OK ] generated and stored operator key "OBBMNDXWHOYLA5CMH47QKAKLEIHKGIZBXIH63WSPHPDHDSAQI7SBGITC"
[ OK ] added operator "my_operator"
[ OK ] When running your own nats-server, make sure they run at least version 2.2.0
[ OK ] created operator signing key: OADCCYB6VSDLBRWHFAITYPCCLXYSCVAEJG546B7UBLHZTJXYW3IUWDGJ
[ OK ] created system_account: name:SYS id:ADPWZT7BFKFGQNCLBGPGS5JYEL63E5E2U3R2NXB2Q37VFEDVU7BXB75X
[ OK ] created system account user: name:sys id:UBUKIFZBXVJQDITR4JBWJORJSDAYU32UFTZGUSILNYWHIIPEU6ISVJJ7
[ OK ] system account user creds file stored in `/nsc/nkeys/creds/my_operator/SYS/sys.creds`
Enforce signing-key usage and configure the account JWT resolver URL:
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters