Closed bacteria323 closed 7 years ago
You should put the content of the JSON file, not the name of the file.
But can't I add the file to the settings like shown here: https://github.com/mcollina/mosca/wiki/Authentication-&-Authorization ?
I think that works only from the CLI.
do not put "credentials" field into mosca server setting obj , just define a setting var only for userAuth, like :
const authSetting = {credentials: "credentials.json" }
and pass it to setup func :
function setup() {
// setup authorizer
loadAuthorizer(authSetting, function(err, authorizer) {
if (err) {
// handle error here
}
if (authorizer) {
server.authenticate = authorizer.authenticate;
server.authorizeSubscribe = authorizer.authorizeSubscribe;
server.authorizePublish = authorizer.authorizePublish;
}
});
// you are good to go!
}
then put the setup func in server ready call back func. it works fine . Good luck.
see here: https://github.com/mcollina/mosca/wiki/Authentication-&-Authorization
Using Mosca's standalone authorizer with an embedded Mosca
I am trying to add credentials.json to the mosca settings file but I am getting the error:
My mosca settings is: