We are happy to share that we’ve introduced support for capturing audit decision logs from the Cerbos Hub Embedded Policy Decision Points (ePDP) using the latest version of the Cerbos Javascript SDK. This feature enables organizations to track and analyze authorization decisions made locally in embedded environments, ensuring complete visibility and auditability, without relying on a centralized PDP or Cerbos Hub.
Embedded PDPs allow applications to evaluate policies locally, making instant authorization decisions without network latency. This is particularly valuable for applications running in offline mode, edge computing environments, or serverless architectures. Until now, organizations leveraging Embedded PDPs lacked a built-in way to capture and review these decisions.
With this latest update, audit decision logs from Embedded PDPs can now be recorded locally and processed in real-time using the onDecision
hook in the Cerbos Javascript SDK, providing:
Every time the Embedded PDP evaluates a policy, it records key details such as:
These logs can be captured using the onDecision
callback, which provides a structured DecisionLogEntry
that can be processed locally, stored, or analyzed in real-time.
onDecision
hookThe onDecision
property in the Javascript SDK allows developers to specify a callback function that gets invoked whenever a decision is made. This makes it easy to store or process logs as needed.
Here's a sample log entry showing that user sally
was allowed to view expense1
.
{
"timestamp": "2023-01-05T15:51:13.150Z",
"requestId": "01GP1A25FW6BVX9JWYM9M6T0Z0",
"principal": {
"id": "sally",
"roles": ["USER"],
"attr": {
"region": "EMEA",
"department": "SALES"
}
},
"resource": {
"kind": "expense",
"id": "expense1",
"attr": {
"status": "PENDING",
"amount": "40",
"region": "EMEA",
"vendor": "Expense 1",
"approvedBy": "frank",
"createdAt": "2023-01-03T15:45:55.461Z",
"ownerId": "sally"
}
},
"action": "view",
"effect": "EFFECT_ALLOW",
"policy": "resource.expense.vdefault",
"effectiveDerivedRoles": ["OWNER"]
}
Below is an example of how to use the Cerbos Javascript SDK with Embedded PDP and capture audit decision logs using the onDecision
hook.
import { Embedded as Cerbos } from "@cerbos/embedded";
async function run() {
const cerbos = new Cerbos({
policy: "https://lite.cerbos.cloud/bundle?workspace=",
onDecision: (entry) => {
console.log("Audit log entry:", JSON.stringify(entry, null, 2));
// Optionally store the log entry in a database or file
}
});
const decision = await cerbos.isAllowed({
principal: {
id: "sally",
roles: ["USER"],
attr: { region: "EMEA", department: "SALES" }
},
resource: {
kind: "expense",
id: "expense1",
attr: { status: "PENDING", amount: "40", region: "EMEA" }
},
action: "view"
});
console.log("Authorization decision:", decision);
}
run();
Bringing audit logs to Embedded PDPs ensures that teams have full control over their authorization decisions, even in environments where traditional logging was previously challenging. Security engineers, product managers, and developers now have the same level of visibility and traceability as with centrally managed PDPs.
This feature is available in the latest version of the Cerbos Javascript SDK. To start using audit decision logs for Embedded PDPs, update your SDK and implement the onDecision
hook to capture logs locally.
Check out the documentation to get started. Feel free to book a call with a Cerbos engineer to see how our solution can help streamline access control in your applications.
Book a free Policy Workshop to discuss your requirements and get your first policy written by the Cerbos team
Join thousands of developers | Features and updates | 1x per month | No spam, just goodies.