Basic configuration revolves around 4 settings:
For complete information, please refer to the project's Github.
You can start a server using a plain directory. In this case you'll be responsible for adding any JWT that you want resolved.
The server looks for account JWTs by using the public key of the account as the file name followed by the extension
.jwt. The server will not introspect the JWTs, so if you don't name the files correctly, it will fail to find them or serve a JWT that doesn't match the requested account.
Configuration for the NATS server is the same as in the previous example:
A step by step tutorial using directory configuration can be found here.
While the -dir store flag is sufficient for some very simple developer setups, any production or non-read-only server will require a configuration file.
Let's take a look at the configuration options:
| Option | Description |
|---|---|
http |
An http configuration block specifying HTTP options. |
logging |
A logging configuration block specifying server logging options. |
nats |
A nats configuration block specifying NATS connection information for the account server to push JWT changes to a NATS server. |
operatorjwtpath |
The path to an operator JWT. Required for non-read-only servers. Only JWTs signed by the operator (or one of it's signing keys) are accepted. |
store |
A store configuration block specifying store options. |
systemaccountjwtpath |
Path to an Account JWT that should be returned as the system account. |
primary |
URL for the primary, protocol://host:port. |
replicationtimeout |
Timeout, in milliseconds, used by the replica when talking to the primary, defaults to 5000. |
store Configuration| Option | Description |
|---|---|
dir |
Configures a directory as a store. |
readonly |
If true, the store will not accept POST requests. Note that to receive requests, the store must also have operatorjwtpath specified as a root option. |
shard |
If true, JWTs will be stored in multiple sub directories of the store directory. |
logging Options| Option | Description |
|---|---|
time |
If true, a timestamp is added to log messages. |
debug |
If true, debug messages are logged. |
trace |
If true, trace messages are logged. |
colors |
If true, messages are logged using ANSI color escape sequences. |
pid |
If true, the process id for the server is added to log messages. |
http Options| Option | Description |
|---|---|
host |
Interface to listen for requests on. |
port |
Port to listen for requests on. |
readtimeout |
Max amount of time in milliseconds to wait for a http read operation to complete. |
writetimeout |
Max amount of time in milliseconds to wait for a http write operation to complete. |
nats Options| Option | Description |
|---|---|
servers |
List of NATS servers for the account server to use when connecting to a NATS server to publish updates. |
connecttimeout |
Max amount of time in milliseconds to wait for a NATS connection. |
reconnecttimewait |
Amount of time in milliseconds to between NATS server reconnect attempts. |
tls |
A tls configuration block. |
usercredentials |
A credentials creds file for connecting to the NATS server. Account must be a member of a system account. |
tls Options| Option | Description |
|---|---|
root |
filepath to the CA certificate. |
cert |
filepath to the certificate. |
cert |
filepath to the certificate key. |
Provided a setup with 4 accounts, one of them a system account, this example shows how to set up the account server by:
nats-server to make use of the account serverSet environment variables
Run setup script that creates a few sample accounts and a system account
List all accounts
Add the endpoint for the account server to which accounts can be published
Generate account server config that references the operator jwt
Start the account server
Upload the local accounts in the nsc directory structure
Generate the NATS Server config that points to the account server
Start the NATS Server in trusted operator mode
Try to subscribe on account without permissions, this should fail
Subscribe then publish to subject should work on 'test' since enough permissions
Published message on 'test' subject would be received by started subscriber above
Subscribe using the system account user credentials can receive all system events