Last active
March 1, 2017 17:53
-
-
Save aricart/9e0a50543323465806217c8812dc6d22 to your computer and use it in GitHub Desktop.
node-nats publisher permission snippet
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Generated | |
authorization { | |
ADMIN = { | |
publish = ">" | |
subscribe = ">" | |
} | |
PUB = { | |
publish = "foo" | |
} | |
SUB = { | |
subscribe= "foo" | |
} | |
users = [ | |
{user: "admin", password: "test", permissions: $ADMIN}, | |
{user: "pub", password: "test", permissions: $PUB}, | |
{user: "sub", password: "test", permissions: $SUB}, | |
] | |
# default of 5 seconds for an authorization timeout. | |
timeout: 5.0 | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'use strict'; | |
var nats = require('nats').connect("nats://pub:test@localhost:4222"); | |
nats.on('error', function(e) { | |
console.log("Error [" + e + "]"); | |
console.log(e.stack); | |
process.exit(); | |
}); | |
function print(m) { | |
console.log("message: " + m); | |
} | |
// publish should fail | |
nats.publish("bar", ""); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment