cap-js / audit-logging

CDS plugin providing integration to the SAP Audit Log service as well as out-of-the-box personal data-related audit logging based on annotations.
https://cap.cloud.sap/docs/guides/data-privacy
Apache License 2.0
4 stars 1 forks source link

add support to supply user and timestamp by consumer #64

Closed soccermax closed 7 months ago

soccermax commented 8 months ago

would be nice if we could adjust the following coding, proposal would be to check if tenant, user, timestamp is present in req.data. The data from the global cds.context should only be used if the data is not supplied via req.data.

FYI: @sjvans

    // add common audit log entry fields
    this.before('*', req => {
      const { tenant, user, timestamp: time } = cds.context
      Object.assign(req.data, { uuid: cds.utils.uuid(), tenant, user: user.id, time })
    })
sjvans commented 8 months ago

hi @soccermax

do you have a specific use case in mind? we intentionally decided not to allow to provide custom values until there is a verified need.

soccermax commented 8 months ago

We do our own outboxing with the event-queue but I assume that this would not be very different from the persistent outbox approach from cds. The user in the context of the global cds as well as the timestamp does not match the reality of the user and timestamp before the outboxing. Outbox runs in the context of a technical user and the timestamp does not match anymore