Git Product home page Git Product logo

nsc's Introduction

NSC

License Apache 2 ReportCard Build Status GoDoc Coverage Status

A tool for creating NATS account and user access configurations

Install

With Python:

curl -L https://raw.githubusercontent.com/nats-io/nsc/main/install.py | python

Without Python and with a more cautious mindset:

curl -LO https://raw.githubusercontent.com/nats-io/nsc/main/install.sh
less install.sh
sh ./install.sh

With Homebrew:

brew tap nats-io/nats-tools
brew install nats-io/nats-tools/nsc

# to uninstall:
brew uninstall nats-io/nats-tools/nsc
brew untap nats-io/nats-tools

Direct Download:

Download your platform binary from here.

Updates are easy

nsc update will download and install the latest version. If you installed using Homebrew, brew update will update.

Documentation

Documentation is here.

Building

NSC uses go modules. If your project source is in $GOPATH, you must define set the environment variable GO111MODULE to on.

Running with Docker

The NATS team maintains a lightweight Docker image with many of the NATS utilities called nats-box where nsc is included. You can mount a local volume to get nsc accounts, nkeys, and other config back on the host using Docker as follows:

docker run --rm -it -v $(pwd)/nsc:/nsc natsio/nats-box:latest

# In case NSC not initialized already:
nats-box:~# nsc init
nats-box:~# chown -R 1000:1000 /nsc
$ tree -L 2 nsc/
nsc/
 ├── accounts
 │   ├── nats
 │   └── nsc.json
 └── nkeys
    ├── creds
    └── keys

5 directories, 1 file

nsc's People

Contributors

aricart avatar boris-ilijic avatar brianmcgee avatar bruth avatar codegangsta avatar danielcibrao-form3 avatar dependabot[bot] avatar derekcollison avatar dixon1e avatar drakorgaur avatar egodigitus avatar gcolliso avatar jarema avatar jonaslagoni avatar julienvdg avatar kmpm avatar kozlovic avatar matthiashanel avatar natw avatar nsurfer avatar philpennock avatar rafalgoslawski avatar samuelattwood avatar sasbury avatar scottf avatar sdenovan avatar sethjback avatar shantanubansal avatar variadico avatar wallyqs avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

nsc's Issues

nsc env -o does not report errors

If the store directory is not set correctly, nsc env -o <operators> silently fails. An error like "No operator found in directory <dir> would be helpful.

edit user and specifying signing key

fails with message "account with public key is not in the store"
User must be added with the account key first, and then edited with the signing key for the error to happen.

Panic listing operators

This may have been fixed in more recent version. For tracking purposes.

IvanMBP:ngs ivan$ ngs --version
ngs version 0.2.3

Signed up with free account, then:

IvanMBP:ngs ivan$ ngs list operators
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x130bc25]

goroutine 1 [running]:
github.com/nats-io/jwt.(*GenericClaims).Claims(0x0, 0xc0001a2080)
    /home/travis/gopath/pkg/mod/github.com/nats-io/[email protected]/genericlaims.go:33 +0x5
github.com/nats-io/nsc/cmd.listEntities(0x169e4b0, 0x9, 0xc00009a778, 0x1, 0x1, 0xc000098fd6, 0x7, 0x1, 0xc0001a2000)
    /home/travis/gopath/pkg/mod/github.com/nats-io/[email protected]/cmd/listoperators.go:177 +0x529
github.com/nats-io/nsc/cmd.createListOperatorsCmd.func1(0xc00017e280, 0x1bb6400, 0x0, 0x0, 0x0, 0x0)
    /home/travis/gopath/pkg/mod/github.com/nats-io/[email protected]/cmd/listoperators.go:69 +0x2ae
github.com/spf13/cobra.(*Command).execute(0xc00017e280, 0x1bb6400, 0x0, 0x0, 0xc00017e280, 0x1bb6400)
    /home/travis/gopath/pkg/mod/github.com/spf13/[email protected]/command.go:762 +0x473
github.com/spf13/cobra.(*Command).ExecuteC(0x1b8e9e0, 0xc00009a010, 0x1743340, 0xc00009a010)
    /home/travis/gopath/pkg/mod/github.com/spf13/[email protected]/command.go:852 +0x2fd
github.com/spf13/cobra.(*Command).Execute(0x1b8e9e0, 0x1743340, 0xc00009a010)
    /home/travis/gopath/pkg/mod/github.com/spf13/[email protected]/command.go:800 +0x2b
main.main()
    /home/travis/gopath/src/github.com/ConnectEverything/ngs/ngs/main.go:55 +0x276

Tool should decorate jwts w/ comments

-----BEGIN SYNADIA OPERATOR JWT-----
eyJ0eXAiOiJqd3QiLCJhbGciOiJlZDI1NTE5In0.eyJhdWQiOiJOR1MiLCJleHAiOjE1NzUyOTQ2NzMsImp0aSI6IkNGRkFBSFNJR0dHUjNSRFVRUjNRVDI2QjRRV002S0JNTElFUFRUM1pGSE9PR0Y3REM0S0EiLCJpYXQiOjE1NDM3NTg2NzMsImlzcyI6Ik9ETEMyMk5JUVE1VTRKNlpEVFZPRktURVg0Rjc3RTdUVk0yUkhXU0c3TjI2NllPVktUUkk0RVdYIiwibmFtZSI6IlN5bmFkaWEgQ29tbXVuaWNhdGlvbnMgSW5jLiIsIm5iZiI6MTU0Mzc1ODY3Mywic3ViIjoiT0RMQzIyTklRUTVVNEo2WkRUVk9GS1RFWDRGNzdFN1RWTTJSSFdTRzdOMjY2WU9WS1RSSTRFV1giLCJ0eXBlIjoib3BlcmF0b3IiLCJuYXRzIjp7InNpZ25pbmdfa2V5cyI6WyJPRFNLQVlVNUpSTVhMRlhGSlU3WTczUE5OMjJaVFhDVlRWQTI2VlZMVkgyQ05NNlFWMlZCSk1JTyIsIk9EU0tCTkRJVDNMVFpXRlNSQVdPQlhTQlo3VlpDRFFWVTZUQkpYM1RRR1lYVVdSVTQ2QU5KSlM0IiwiT0RTS0NOSTVNTFNXTlBTNEdJQ0pHMktISk9DTEhaV1BPQlROVUIyNDVBTkNPQlg3VklRNk1BWkQiXX19.D7vumb116GzwFmTpiTlTVogYxnbfTWhW-luLF6Zjame-Tk86JK9HhXutqzdbmOEkQG3SUqzKJBH840r3GIBmBA
------END SYNADIA OPERATOR JWT------

flags for users differ

I find some commands want -n for name and some want -u for user, but both mean same thing. Be good to be consistent.

ngs generate config not honoring the account

? select account alberto1
synadia malaga:~ [5075]% ngs generate config -i -o ~/Desktop/import_test/alberto2.chain
? select account alberto2
Error: user "alberto1" not found```

typo in error if load store is bad

func LoadStore(dir string) (*Store, error) {
sf := filepath.Join(dir, NSCFile)
if _, err := os.Stat(sf); os.IsNotExist(err) {
return nil, fmt.Errorf("%q is not a valid configuration directory", sf)
}

should be dir instead of sf in the error

Edit user should allow me to add/remove permissions/limits

? select account system
? select user ping_user
? valid from (0 is always) 0
? valid until (0 is always) 0
Success! - edited user "ping_user" in account "system"
-----BEGIN NATS ACCOUNT JWT-----
eyJ0eXAiOiJqd3QiLCJhbGciOiJlZDI1NTE5In0.eyJqdGkiOiJSSUY1UElUSDRZQ0xOWlA1TUdNQUVXSUM0WTQ1NlJUV042TEZGWExUTjc0TEpYT0tBSUZRIiwiaWF0IjoxNTQ0Mjg1NjYxLCJpc3MiOiJBQVNZU1FMSTVRNUNDWUZJUlNYR0ZYU1VMUzJQSUdVU0pOV1NERTVUU1JMUDRTQkxIREdGSDJGRSIsIm5hbWUiOiJwaW5nX3VzZXIiLCJzdWIiOiJVQVpXT1lONU8zWURZQ05IM0JaNElCUUZYTTZGWjM1S0tGRkJSN09ISlJOWEhWVzVZVEc2NkI1NyIsInR5cGUiOiJ1c2VyIiwibmF0cyI6eyJwdWIiOnt9LCJzdWIiOnt9fX0.vrUzxnssvYyOI7JmwvQ1lBnCcyTh-mm_AWPs_zgwccQUPDCfel7IiP-oCKzF5QpvmO57z8smDD5QU1yKvqXwBw
------END NATS ACCOUNT JWT------

Pick signing key for accounts

If an operator has signing keys, and the tool can find all the seeds for the master and the signing keys, allow the user to select which key to use to sign the account jwt.

List users from account

This should work IMO

> nsc list users -a demo
Error: unknown shorthand flag: 'a' in -a
Usage:
  nsc list users [flags]

Flags:
  -h, --help   help for users

Global Flags:
  -i, --interactive          ask questions for various settings
  -W, --long-ids             display long ids
  -K, --private-key string   private key

Activation tokens

When generating one it prints it out by default, but when adding one does not give an option to add it directly as input, only takes file or url. Should be able to avoid writing to a file for import and take the value of encoded JWT directly.

describe operators

nsc describe -f <operator.jwt> seems to work.

But simple nsc describe operator fails
Error: error reading root: illegal base64 data at input byte 22

add logging to ansible

logging: {
Time: true
Debug: true
Trace: true
Colors: true
PID: true
}

this goes in the service config at the same level as the operator key

Generating activation token ignore subject

tool just copies export subject which is incorrect. Needs to take subject from command line or interactive mode and make sure its a strict subset or direct literal match.

This is blocking me.

Add user with default account set in interactive mode

It asks for account even though default set.
At least could select default one

~/.nkeys/synadia/accounts/system> nsc env --account system
╭──────────────────────────────────────────╮
│             NSC Environment              │
├──────────────────┬─────┬─────────────────┤
│ Setting          │ Set │ Effective Value │
├──────────────────┼─────┼─────────────────┤
│ $NKEYS_PATH      │ No  │ ~/.nkeys        │
│ $NSC_HOME        │ No  │ ~/.nsc          │
│ Config           │     │ ~/.nsc/nsc.json │
├──────────────────┼─────┼─────────────────┤
│ Stores Dir       │     │ ~/.nsc/nats     │
│ Default Operator │     │ synadia         │
│ Default Account  │     │ system          │
│ Default Cluster  │     │                 │
╰──────────────────┴─────┴─────────────────╯

~/.nkeys/synadia/accounts/system> nsc list users
╭────────────────────────────────────────────────────────────────────────╮
│                                 Users                                  │
├─────────────┬──────────────────────────────────────────────────────────┤
│ Name        │ Public Key                                               │
├─────────────┼──────────────────────────────────────────────────────────┤
│ ngs_server  │ UCJX2PK7F3DXAYSBMGOCECSRZFIV7EVN6VCEG7KYP4FLVTRVGLCMXSKF │
│ test_system │ UBW3GQ3AGWDSYSTFQT4PYJPZF2JVQRXSSPWPMO2AZ23Z2WU2CH3SUY6I │
╰─────────────┴──────────────────────────────────────────────────────────╯

~/.nkeys/synadia/accounts/system> nsc add user -i
? user name ping_user
? generate an user nkey Yes
? select account  [Use arrows to move, type to filter]
> demos
  synadia
  system```

env account change isn't taking effect for me

nsc env --account synadia_account [0]
╭───────────────────────────────────────────────────╮
│ NSC Environment │
├──────────────────┬─────┬──────────────────────────┤
│ Setting │ Set │ Effective Value │
├──────────────────┼─────┼──────────────────────────┤
│ $NKEYS_PATH │ No │ /Users/sasbury/.nkeys │
│ $NSC_HOME │ No │ /Users/sasbury/.nsc │
├──────────────────┼─────┼──────────────────────────┤
│ Stores Dir │ │ /Users/sasbury/.nsc/nats │
│ Default Operator │ │ synadia_operator │
│ Default Account │ │ test_account │
│ Default Cluster │ │ │
╰──────────────────┴─────┴──────────────────────────╯

describe account imports confusing with swap

now that to means local for stream and remote for service the describe account table is confusing.

We should print local/remote in the header and flip the content for services.

nsc edit account

Used -i version and wanted to update max connections but could not.

Adding an activation issues

Interactive mode panics

full flags has asymmetry with source account being a single friendly name and the target account needing to be a path to the nkey. Should be just simple name too.

-K flag ignored

Recent builds ignore the -K flag and ask you to enter path to the keyfile.

Command line flags should override.

On entering through the prompt, the input does not properly expand ~ and concats to CWD.

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.