mirror of
https://github.com/taigrr/nats.docs
synced 2025-01-18 04:03:23 -08:00
updating docs
This commit is contained in:
@@ -69,7 +69,7 @@
|
||||
<link rel="next" href="../nats_top/" />
|
||||
|
||||
|
||||
<link rel="prev" href="inspecting_jwts.html" />
|
||||
<link rel="prev" href="dir_store.html" />
|
||||
|
||||
|
||||
<link rel="stylesheet" href="https://cdn.materialdesignicons.com/3.6.95/css/materialdesignicons.min.css">
|
||||
@@ -127,12 +127,12 @@
|
||||
|
||||
</li>
|
||||
|
||||
<li class="chapter " data-level="1.3" >
|
||||
<li class="chapter " data-level="1.3" data-path="../../faq.html">
|
||||
|
||||
<a target="_blank" href="https://nats.io">
|
||||
<a href="../../faq.html">
|
||||
|
||||
|
||||
NATS.IO
|
||||
FAQ
|
||||
|
||||
</a>
|
||||
|
||||
@@ -1538,7 +1538,20 @@
|
||||
|
||||
</li>
|
||||
|
||||
<li class="chapter active" data-level="5.4.3" data-path="mem_resolver.html">
|
||||
<li class="chapter " data-level="5.4.3" data-path="dir_store.html">
|
||||
|
||||
<a href="dir_store.html">
|
||||
|
||||
|
||||
Directory Store
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
</li>
|
||||
|
||||
<li class="chapter active" data-level="5.4.4" data-path="mem_resolver.html">
|
||||
|
||||
<a href="mem_resolver.html">
|
||||
|
||||
@@ -2315,7 +2328,7 @@
|
||||
<section class="normal markdown-section">
|
||||
|
||||
<h2 id="memory-resolver"><a name="memory-resolver" class="plugin-anchor" href="#memory-resolver"><i class="fa fa-link" aria-hidden="true"></i></a>Memory Resolver</h2>
|
||||
<p>The <code>MEMORY</code> resolver is a built-in resolver for JWTs. It is mostly used by test setups but can be used to test the simplest of environments where there is one or very few accounts, and the account JWTs don’t change often.</p>
|
||||
<p>The <code>MEMORY</code> resolver is a built-in resolver for JWTs. It is mostly used by test setups but can be used to test the simplest of environments where there is one or very few accounts, and the account JWTs don't change often.</p>
|
||||
<p>The basic configuration for the server requires:</p>
|
||||
<ul>
|
||||
<li>The operator JWT</li>
|
||||
@@ -2323,13 +2336,13 @@
|
||||
<li><code>resolver_preload</code> set to an object where account public keys are mapped to account JWTs.</li>
|
||||
</ul>
|
||||
<h3 id="create-required-entities"><a name="create-required-entities" class="plugin-anchor" href="#create-required-entities"><i class="fa fa-link" aria-hidden="true"></i></a>Create Required Entities</h3>
|
||||
<p>Let’s create the setup:</p>
|
||||
<p>Let's create the setup:</p>
|
||||
<pre class="language-"><code class="lang-text">> nsc add operator -n memory
|
||||
Generated operator key - private key stored "/Users/synadia/.nkeys/memory/memory.nk"
|
||||
Generated operator key - private key stored "~/.nkeys/memory/memory.nk"
|
||||
Success! - added operator "memory"
|
||||
|
||||
> nsc add account --name A
|
||||
Generated account key - private key stored "/Users/synadia/.nkeys/memory/accounts/A/A.nk"
|
||||
Generated account key - private key stored "~/.nkeys/memory/accounts/A/A.nk"
|
||||
Success! - added account "A"
|
||||
|
||||
> nsc describe account -W
|
||||
@@ -2355,16 +2368,44 @@ Success! - added account "A"
|
||||
│ Exports │ None │
|
||||
╰───────────────────────────┴──────────────────────────────────────────────────────────╯
|
||||
|
||||
> cat /Users/synadia/.nsc/nats/memory/accounts/A/A.jwt
|
||||
eyJ0eXAiOiJqd3QiLCJhbGciOiJlZDI1NTE5In0.eyJqdGkiOiJPRFhJSVI2Wlg1Q1AzMlFJTFczWFBENEtTSDYzUFNNSEZHUkpaT05DR1RLVVBISlRLQ0JBIiwiaWF0IjoxNTU2NjU1Njk0LCJpc3MiOiJPRFdaSjJLQVBGNzZXT1dNUENKRjZCWTRRSVBMVFVJWTRKSUJMVTRLM1lERzNHSElXQlZXQkhVWiIsIm5hbWUiOiJBIiwic3ViIjoiQUNTVTNRNkxUTEJWTEdBUVVPTkFHWEpIVk5XR1NLS0FVQTdJWTVUQjRaN1BMRUtTUjVPNkpUR1IiLCJ0eXBlIjoiYWNjb3VudCIsIm5hdHMiOnsibGltaXRzIjp7InN1YnMiOi0xLCJjb25uIjotMSwibGVhZiI6LTEsImltcG9ydHMiOi0xLCJleHBvcnRzIjotMSwiZGF0YSI6LTEsInBheWxvYWQiOi0xLCJ3aWxkY2FyZHMiOnRydWV9fX0._WW5C1triCh8a4jhyBxEZZP8RJ17pINS8qLzz-01o6zbz1uZfTOJGvwSTS6Yv2_849B9iUXSd-8kp1iMXHdoBA
|
||||
|
||||
> nsc add user --name TA
|
||||
Generated user key - private key stored “/Users/synadia/.nkeys/memory/accounts/A/users/TA.nk"
|
||||
Generated user creds file “/Users/synadia/.nkeys/memory/accounts/A/users/TA.creds"
|
||||
Generated user key - private key stored "~/.nkeys/memory/accounts/A/users/TA.nk"
|
||||
Generated user creds file "~/.nkeys/memory/accounts/A/users/TA.creds"
|
||||
Success! - added user "TA" to "A"
|
||||
</code></pre>
|
||||
<h3 id="create-the-server-config"><a name="create-the-server-config" class="plugin-anchor" href="#create-the-server-config"><i class="fa fa-link" aria-hidden="true"></i></a>Create the Server Config</h3>
|
||||
<p>With the above entries, we can reference the operator JWT and the account JWT in a server configuration. Remember that your configuration will be in <code>$NSC_HOME/nats/<span class="token tag"><span class="token tag"><span class="token punctuation"><</span>operator_name</span><span class="token punctuation">></span></span>/<span class="token tag"><span class="token tag"><span class="token punctuation"><</span>operator_name</span><span class="token punctuation">></span></span>.jwt</code> for the operator. The account JWT will be in <code>$NSC_HOME/nats/<span class="token tag"><span class="token tag"><span class="token punctuation"><</span>operator_name</span><span class="token punctuation">></span></span>/accounts/<span class="token tag"><span class="token tag"><span class="token punctuation"><</span>account_name</span><span class="token punctuation">></span></span>/<span class="token tag"><span class="token tag"><span class="token punctuation"><</span>account_name</span><span class="token punctuation">></span></span>.jwt</code></p>
|
||||
<p>The <code>nsc</code> tool can generate a configuration file automatically. You provide a path to the server configuration and operator jwt. The <code>nsc</code> tool will copy the operator JWT to the file specified, and generate the server config for you:</p>
|
||||
<p>`"</p>
|
||||
<blockquote>
|
||||
<p>nsc generate config --mem-resolver --config-file /tmp/server.conf --operator-jwt /tmp/memory.jwt
|
||||
Success!! - generated "/tmp/server.conf"
|
||||
generated "/tmp/memory.jwt"
|
||||
```</p>
|
||||
</blockquote>
|
||||
<p>If you require additional settings, you may want to consider using <a href="../../nats_server/configuration.html#include-directive"><code>include</code></a> in your main configuration, to reference the generated files. Otherwise, you can start a server and reference the generated configuration:</p>
|
||||
<p>`"</p>
|
||||
<blockquote>
|
||||
<p>nats-server -c /tmp/server.conf
|
||||
`"</p>
|
||||
</blockquote>
|
||||
<p>You can then <a href="#testing-the-configuration">test it</a>.</p>
|
||||
<h3 id="manual-server-config"><a name="manual-server-config" class="plugin-anchor" href="#manual-server-config"><i class="fa fa-link" aria-hidden="true"></i></a>Manual Server Config</h3>
|
||||
<p>While generating a configuration file is easy, you may want to craft one by hand to know the details. With the entities created, and a standard location for the <code>.nsc</code> directory. You can reference the operator JWT and the account JWT in a server configuration. Remember that your configuration will be in <code>$NSC_HOME/nats/<span class="token tag"><span class="token tag"><span class="token punctuation"><</span>operator_name</span><span class="token punctuation">></span></span>/<span class="token tag"><span class="token tag"><span class="token punctuation"><</span>operator_name</span><span class="token punctuation">></span></span>.jwt</code> for the operator. The account JWT will be in <code>$NSC_HOME/nats/<span class="token tag"><span class="token tag"><span class="token punctuation"><</span>operator_name</span><span class="token punctuation">></span></span>/accounts/<span class="token tag"><span class="token tag"><span class="token punctuation"><</span>account_name</span><span class="token punctuation">></span></span>/<span class="token tag"><span class="token tag"><span class="token punctuation"><</span>account_name</span><span class="token punctuation">></span></span>.jwt</code></p>
|
||||
<p>For the configuration you'll need:</p>
|
||||
<ul>
|
||||
<li>The path to the operator JWT</li>
|
||||
<li>A copy of the contents of the account JWT file</li>
|
||||
</ul>
|
||||
<p>The format of the file is:</p>
|
||||
<p>`"
|
||||
operator: <path to="" the="" operator="" jwt=""></path>
|
||||
resolver: MEMORY
|
||||
resolver_preload: {
|
||||
<public key="" for="" an="" account="">: <contents of="" the="" account="" jwt=""></contents></public></p>
|
||||
<pre class="language-"><code>### add as many accounts as you want
|
||||
...
|
||||
</code></pre><p>}</p>
|
||||
<p>In this example this translates to:</p>
|
||||
<pre class="language-"><code class="lang-text">operator: /Users/synadia/.nsc/nats/memory/memory.jwt
|
||||
resolver: MEMORY
|
||||
resolver_preload: {
|
||||
@@ -2373,10 +2414,17 @@ ACSU3Q6LTLBVLGAQUONAGXJHVNWGSKKAUA7IY5TB4Z7PLEKSR5O6JTGR: eyJ0eXAiOiJqd3QiLCJhbG
|
||||
</code></pre>
|
||||
<p>Save the config at server.conf and start the server:</p>
|
||||
<pre class="language-"><code class="lang-text">> nats-server -c server.conf
|
||||
</code></pre>
|
||||
<p>Start a subscriber:</p>
|
||||
<pre class="language-"><code class="lang-text">> nats-sub -creds /Users/synadia/.nkeys/memory/accounts/A/users/TA.creds ">"
|
||||
Listening on [>]
|
||||
`"
|
||||
|
||||
You can then [test it](#testing-the-configuration).
|
||||
|
||||
### Testing the Configuration
|
||||
|
||||
To test the configuration, simply use one of the standard tools:
|
||||
|
||||
```text
|
||||
> nats-pub -creds ~/.nkeys/memory/accounts/A/users/TA.creds hello world
|
||||
Published [hello] : 'world'
|
||||
</code></pre>
|
||||
|
||||
|
||||
@@ -2405,7 +2453,7 @@ Listening on [>]
|
||||
|
||||
|
||||
|
||||
<a href="inspecting_jwts.html" class="navigation navigation-prev " aria-label="Previous page: Inspecting JWTs">
|
||||
<a href="dir_store.html" class="navigation navigation-prev " aria-label="Previous page: Directory Store">
|
||||
<i class="fa fa-angle-left"></i>
|
||||
</a>
|
||||
|
||||
@@ -2421,7 +2469,7 @@ Listening on [>]
|
||||
<script>
|
||||
var gitbook = gitbook || [];
|
||||
gitbook.push(function() {
|
||||
gitbook.page.hasChanged({"page":{"title":"Memory Resolver","level":"5.4.3","depth":2,"next":{"title":"nats-top","level":"5.5","depth":1,"path":"nats_tools/nats_top/README.md","ref":"nats_tools/nats_top/README.md","articles":[{"title":"Tutorial","level":"5.5.1","depth":2,"path":"nats_tools/nats_top/tutorial.md","ref":"nats_tools/nats_top/tutorial.md","articles":[]}]},"previous":{"title":"Inspecting JWTs","level":"5.4.2","depth":2,"path":"nats_tools/nas/inspecting_jwts.md","ref":"nats_tools/nas/inspecting_jwts.md","articles":[]},"dir":"ltr"},"config":{"plugins":["prism","-sharing","-highlight","include-html","toggle-chapters","anchors"],"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"pluginsConfig":{"prism":{"lang":{"ascii":"markup","text":"markup"}},"include-html":{},"toggle-chapters":{},"anchors":{},"search":{},"lunr":{"maxIndexSize":1000000,"ignoreSpecialCharacters":false},"fontsettings":{"theme":"white","family":"sans","size":2},"theme-default":{"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"showLevel":false}},"theme":"default","author":"The NATS Maintainers","pdf":{"pageNumbers":true,"fontSize":12,"fontFamily":"Arial","paperSize":"a4","chapterMark":"pagebreak","pageBreaksBefore":"/","margin":{"right":62,"left":62,"top":56,"bottom":56}},"structure":{"langs":"LANGS.md","readme":"README.md","glossary":"GLOSSARY.md","summary":"SUMMARY.md"},"variables":{},"title":"NATS","gitbook":"*","description":"Administrative, developer and conceptual documentation for the NATS messaging system."},"file":{"path":"nats_tools/nas/mem_resolver.md","mtime":"2019-05-30T21:51:29.887Z","type":"markdown"},"gitbook":{"version":"3.2.3","time":"2019-05-30T23:55:39.589Z"},"basePath":"../..","book":{"language":""}});
|
||||
gitbook.page.hasChanged({"page":{"title":"Memory Resolver","level":"5.4.4","depth":2,"next":{"title":"nats-top","level":"5.5","depth":1,"path":"nats_tools/nats_top/README.md","ref":"nats_tools/nats_top/README.md","articles":[{"title":"Tutorial","level":"5.5.1","depth":2,"path":"nats_tools/nats_top/tutorial.md","ref":"nats_tools/nats_top/tutorial.md","articles":[]}]},"previous":{"title":"Directory Store","level":"5.4.3","depth":2,"path":"nats_tools/nas/dir_store.md","ref":"nats_tools/nas/dir_store.md","articles":[]},"dir":"ltr"},"config":{"plugins":["prism","-sharing","-highlight","include-html","toggle-chapters","anchors"],"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"pluginsConfig":{"prism":{"lang":{"ascii":"markup","text":"markup"}},"include-html":{},"toggle-chapters":{},"anchors":{},"search":{},"lunr":{"maxIndexSize":1000000,"ignoreSpecialCharacters":false},"fontsettings":{"theme":"white","family":"sans","size":2},"theme-default":{"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"showLevel":false}},"theme":"default","author":"The NATS Maintainers","pdf":{"pageNumbers":true,"fontSize":12,"fontFamily":"Arial","paperSize":"a4","chapterMark":"pagebreak","pageBreaksBefore":"/","margin":{"right":62,"left":62,"top":56,"bottom":56}},"structure":{"langs":"LANGS.md","readme":"README.md","glossary":"GLOSSARY.md","summary":"SUMMARY.md"},"variables":{},"title":"NATS","gitbook":"*","description":"Administrative, developer and conceptual documentation for the NATS messaging system."},"file":{"path":"nats_tools/nas/mem_resolver.md","mtime":"2019-05-31T18:29:15.575Z","type":"markdown"},"gitbook":{"version":"3.2.3","time":"2019-05-31T18:29:35.398Z"},"basePath":"../..","book":{"language":""}});
|
||||
});
|
||||
</script>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user