IMPORTANT: We are moving to Discord (link: https://discord.gg/TSEcDRP)! Support @Gitter is no longer guaranteed
icebob on master
fix: disableHeartbeatChecks sho… same opts issue with "disableOf… Merge pull request #858 from ke… (compare)
icebob on master
Wrap decryption code in a try b… log the error if decryption fai… Merge pull request #853 from ci… (compare)
Hi there.
How do I change bodyparser json limit in moleculer-web?
Attempt:
@Service({
name: "api",
mixins: [
ApiGateway,
],
settings: {
routes: [
{
authentication: true,
whitelist: [
'api.ok',
],
aliases: {
'/': 'api.ok',
},
bodyParsers: {
json: { limit: "5MB" },
urlencoded: { extended: true, limit: "5MB" }
}
}]
}
})
But don't work =/
Hia,
Being a newbie to moleculerjs I'm trying to use passport with moleculerjs for authorization using Azure AD passport plugin. Thanks to the mixin https://github.com/icebob/kantab/blob/master/backend/mixins/passport.mixin.js by @icebob I'm able to apply the authorization at the alias level in API gateway service successfully. Now I'm trying to extend this functionality by using this mixin in a dedicated identity service that does the authentication and authorization based on the service name passed to it. I was thinking of using the authorize
method of API gateway to forward the requests to identity service if theauthorization
route setting is set to true
. However, when I call the identity service using ctx.call
method the passport mixin is not being invoked! Here is my authorize method.
async authorize(ctx, route, req) {
let verified;
// Verify JWT token
try {
verified = await ctx.call("identify.verifyToken");
if (verified) {
this.logger.info("Authenticated via JWT: ", user.username);
ctx.meta.user = _.pick(user, ["_id", "username", "email", "image"]);
ctx.meta.token = token;
ctx.meta.userID = user._id;
}
} catch (err) {
console.log(err);
throw new UnAuthorizedError(ApiGateway.Errors.ERR_INVALID_USER);
}
}
and here is the snippet of my identity service
const passportMixin = require("../mixins/passport.mixin");
module.exports = {
name: "identity",
mixins: [passportMixin({ successRedirect: "/api/v1/customer" })],
settings: {
routes: [],
aliases: {},
},
actions: {
verifyToken: {
rest: "GET /verify",
async handler(ctx) {
try {
console.log("Token is being verified");
} catch (err) {
console.log(err);
}
},
},
},
};
The passport mixin is defined to apply passport plugin at alias level like below and the callback is set to forward the request to a customer
service
route.aliases["GET /verify"] = (req, res) =>
passport.authenticate("oauth-bearer", { session: false })(
req,
res,
callback(req, res)
);
I would've thought the identity service invokes the passport plugin before running the verifyToken method but the plugin doesn't get invoked and only the method is run printing the debug statement. My question is can I use passport mixin in other services than API gateway service and if so, what am I doing wrong here?
Thanks in advance!
Your question not clear... if u want fast response just go discord channel https://discord.com/channels/585148559155003392/585148559754657799