AuthToken microservice for microservice-framework
const MicroserviceClient = require('@microservice-framework/microservice-client');
require('dotenv').config();
var client = new MicroserviceClient({
URL: process.env.SELF_URL,
secureKey: process.env.SECURE_KEY
});
client.post({
ttl: 600,
credentials: {
username: 'Gormartsen'
},
scope:[
{
service: 'service1',
methods: {
get:true,
post:false,
put: false,
search: true,
delete: false,
}
},
{
service: 'service2',
methods: {
get:true,
post:false,
put: false,
search: true,
delete: false,
}
}
]
}, function(err, handlerResponse){
console.log(err);
console.log(JSON.stringify(handlerResponse , null, 2));
});
ttl
- access token live time. Use -1 to create immortal token.credentials
- object that will be available by requestDetails.credentials in GET/POST/PUT/SEARCH/DELETE methods under microservice.scope
- array of objects where:- service: SCOPE value from microservice register function.
- methods: true - access allowed, false - denied.
- 1.3.5 - fix 'access-token' validation
- 1.3.6 - add scope output on token GET