Musti Kamil
04/19/2023, 12:39 AMDennis (Cerbos)
04/19/2023, 1:21 AMMusti Kamil
04/19/2023, 1:59 AMDennis (Cerbos)
04/19/2023, 2:02 AMMusti Kamil
04/19/2023, 3:32 AMDennis (Cerbos)
04/19/2023, 3:39 AMi share you yaml filesCan you please point me to these? I see the JS code and the request JSON object but not any yaml file.
Musti Kamil
04/19/2023, 6:08 PMDennis (Cerbos)
04/20/2023, 2:08 AMcerbosCheck
object. Please console.log
and share it.Musti Kamil
04/20/2023, 1:51 PMDennis (Cerbos)
04/21/2023, 6:55 AMdocker run --rm --name cerbos -d -v $(pwd)/cerbos/policies:/policies -p 3592:3592 -p 3593:3593 <http://ghcr.io/cerbos/cerbos:0.26.0|ghcr.io/cerbos/cerbos:0.26.0>
2. Slightly modified authorization.js
:
const { GRPC } = require("@cerbos/grpc");
// The Cerbos PDP instance
const cerbos = new GRPC("localhost:3593", {
tls: false,
});
module.exports = async (user, action, resourceAtrr = {}) => {
const cerbosObject = {
principal: {
id: user.id.toString(),
roles: [user?.role || "unknown"],
attributes: user,
},
resource: {
kind: "blogpost",
id: resourceAtrr?.id + "" || "new",
attributes: resourceAtrr,
},
actions: [action],
};
const cerbosCheck = await cerbos.checkResource(cerbosObject);
return cerbosCheck.isAllowed(action);
};
3. Run the following script:
const authorise = require("./authorization");
(async function() {
let user = {id: 1, role: "member", blocked: false};
let r = await authorise(user, "create", {});
console.log("allowed:", r);
}())
Prints allowed: true
.Musti Kamil
04/21/2023, 11:50 AMDennis (Cerbos)
04/22/2023, 2:22 AMauthorization.js
and my script give you allowed: false
in your environment?
2. I assume you run Cerbos with the command I posted previously. Please post the output of docker logs cerbos
command.
3. Which nodejs version are you using?