Skip to content

Support for components in audit log service #16

@mesemus

Description

@mesemus

Is your feature request related to a problem? Please describe.

At CESNET, we use a central logging service based on GrayLog to log all security-related events. We would like to use invenio-audit-logs to pass the events to this service.

Describe the solution you'd like

It would be great if the audit logs service started using components in the same way as, for example, in invenio-rdm-records.

Then, in our config file, we could add

AUDIT_LOG_SERVICE_COMPONENTS = [
    GrayLogSendingComponent,
]

and have the logic separated there.

Describe alternatives you've considered

An option would be to batch-send the events in a background task. This is doable, but we would need to remember which messages have already been sent. That means we would need to either add a new database table or keep the information in Redis.

Changes required

In the service.config, we need to build the components:

class AuditLogServiceConfig(ServiceConfig, ConfiguratorMixin):
    # modified
    components = FromConfig("AUDIT_LOG_SERVICE_COMPONENTS", default=[])

and in the service itself:

class AuditLogService(RecordService):
    def create(self, identity, data, raise_errors=True, uow=None):
        ...
        record = self.record_cls.create(
            {},
            **data,
        )

        # added
        self.run_components(
            "create",
            identity,
            data=data,
            record=record,
            uow=uow,
        )

        # Persist record (DB and index)
        uow.register(AuditRecordCommitOp(record, self.indexer))

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions