Giter Club home page Giter Club logo

just-nats-things's Introduction

NATS Server Set Up Using Decentralised JWT

We will cover the following in this document:

  • Operator managed deployment of nats-server

  • NATS based resolver configuration

  • Using nsc to create, push and pull accounts to and from the server

  • Creating dynamic accounts and users using go client

Prerequisites

Set-up operator and system account

Create an operator "op" (with a SYS account) that will be the root of trust for our nats-server:

nsc add operator --sys -n op

Generate server config using nsc

We will use above created operator to generate server config:

nsc generate config --nats-resolver --sys-account SYS > server.conf

The above command will write the config to server.conf. --nats-resolver flag enables NATS based resolver for account lookup.

Start the nats-server

nats-server can be started using above generated config:

nats-server -c server.conf

Create an account and an user for pub/sub

If you try to do pub/sub at this point, you will get "Authorization Violation" error from the nats-server. Let's create an account and an user to do pub/sub.

  • Edit operator to add nats-server URL (Default context will be the recently created operator):

    nsc edit operator --account-jwt-server-url nats://0.0.0.0:4222
  • Create account:

    nsc add account --name a
  • Push account to the nats-server:

    nsc push -a a
  • Create an user for account "a":

    nsc add user --name u1 --account a

Pub/Sub

When a user is created using nsc, it will print out the path for the creds file. We'll use those creds to publish a message.

  • Publish a message

    nats pub sub.test hello --creds <path/to/creds/file>

just-nats-things's People

Stargazers

 avatar  avatar

Watchers

 avatar

just-nats-things's Issues

Lame duck upgrades

Nats can be upgraded with no downtime if you run 3

Would be good to add this

because nats is the connective system it’s good to show how to do it so that there is zero down time.

the docs etc are really great btw.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.