diff --git a/_examples/connect_creds.html b/_examples/connect_creds.html index 8f8725d..c803ecc 100644 --- a/_examples/connect_creds.html +++ b/_examples/connect_creds.html @@ -2,12 +2,29 @@
- + + + + + + +
+
nc, err := nats.Connect("localhost", nats.UserCredentials("path_to_creds_file"))
+if err != nil {
+	log.Fatal(err)
+}
+defer nc.Close()
+
+// Do something with the connection
+
+
+
+
Options options = new Options.Builder().
             server("nats://localhost:4222").
diff --git a/_examples/connect_nkey.html b/_examples/connect_nkey.html
index 23ed26d..e6781e1 100644
--- a/_examples/connect_nkey.html
+++ b/_examples/connect_nkey.html
@@ -2,12 +2,33 @@
 
- + + + + + + +
+
opt, err := nats.NkeyOptionFromSeed("seed.txt")
+if err != nil {
+	log.Fatal(err)
+}
+nc, err := nats.Connect("localhost", opt)
+if err != nil {
+	log.Fatal(err)
+}
+defer nc.Close()
+
+// Do something with the connection
+
+
+
+
NKey theNKey = NKey.createUser(null); // really should load from somewhere
 Options options = new Options.Builder().
diff --git a/developer/security/creds.md b/developer/security/creds.md
index b1ad637..aa46b88 100644
--- a/developer/security/creds.md
+++ b/developer/security/creds.md
@@ -1,5 +1,23 @@
-# Authenticating with an NKey
+# Authenticating with User Credentials File
 
-The 2.0 version of NATS server introduced the idea of JWT-based authentication. Clients interact with this new scheme using a user JWT and the private key from an NKey pair. To help make connecting with a JWT easier, the client libraries support the concept of a credentials file. This file contains both the private key and the JWT and can be generated with the `nsc` tool. Given a creds file, a client can authenticate as a specific user belonging to a specific account:
+The 2.0 version of NATS server introduced the idea of JWT-based authentication. Clients interact with this new scheme using a user JWT and the private key from an NKey pair. To help make connecting with a JWT easier, the client libraries support the concept of a credentials file. This file contains both the private key and the JWT and can be generated with the `nsc` tool. The contents will look like the following and should be protected because it contains a private key. This creds file is unused and only for example purposes.
+
+```ascii
+-----BEGIN NATS USER JWT-----
+eyJ0eXAiOiJqd3QiLCJhbGciOiJlZDI1NTE5In0.eyJqdGkiOiJUVlNNTEtTWkJBN01VWDNYQUxNUVQzTjRISUw1UkZGQU9YNUtaUFhEU0oyWlAzNkVMNVJBIiwiaWF0IjoxNTU4MDQ1NTYyLCJpc3MiOiJBQlZTQk0zVTQ1REdZRVVFQ0tYUVM3QkVOSFdHN0tGUVVEUlRFSEFKQVNPUlBWV0JaNEhPSUtDSCIsIm5hbWUiOiJvbWVnYSIsInN1YiI6IlVEWEIyVk1MWFBBU0FKN1pEVEtZTlE3UU9DRldTR0I0Rk9NWVFRMjVIUVdTQUY3WlFKRUJTUVNXIiwidHlwZSI6InVzZXIiLCJuYXRzIjp7InB1YiI6e30sInN1YiI6e319fQ.6TQ2ilCDb6m2ZDiJuj_D_OePGXFyN3Ap2DEm3ipcU5AhrWrNvneJryWrpgi_yuVWKo1UoD5s8bxlmwypWVGFAA
+------END NATS USER JWT------
+
+************************* IMPORTANT *************************
+NKEY Seed printed below can be used to sign and prove identity.
+NKEYs are sensitive and should be treated as secrets.
+
+-----BEGIN USER NKEY SEED-----
+SUAOY5JZ2WJKVR4UO2KJ2P3SW6FZFNWEOIMAXF4WZEUNVQXXUOKGM55CYE
+------END USER NKEY SEED------
+
+*************************************************************
+```
+
+Given a creds file, a client can authenticate as a specific user belonging to a specific account:
 
 !INCLUDE "../../_examples/connect_creds.html"
\ No newline at end of file