Disable read audit by default

Bot: SpringBot
Bot Version Number: v2.4.0.1
FilePath: serverside\src\main\java\epatient\entities\listeners\PrivilegeEntityListener.java
Location:


Reason:
By default, each entity is read audited. For performance reasons, I only want to enable this for a specific requirement. It would be really helpful if the line: auditService.createWith(entity) is placed inside a protected region and disabled by default. I will want to turn it on manually if needed.

Hi @Afriana_Putra_I_B,

Thanks for getting in touch.

So that I understand correctly, you specifically want the read auditing functionality to be enabled by exception for performance reasons?

Do you require something similar for the persistence auditing functionality?

hi @kellie.
For the read audit, I expect it should be disabled by default for performance reasons.
For the persistence audit, I think you can leave it as is since there’s a protected region where I can disable it manually.

Hi @Afriana_Putra_I_B,

We have added a new configuration option that allows for the response audits to be disabled globally as well as sufficient protected regions to configure the auditing on a per-entity basis.

This functionality will be available with the next SpringBot release.

By default, response audit logs will be globally enabled. If required, they can be disabled using the security.read-audit-enabled configuration property that can be found in application.properties.

Enable the surrounding protected region and set this property to false or overriding this property in another profile and setting it to false will disable the response auditing.

For per entity configuration, you can see in the following snippet that this global property can be ignored if required.

@PostLoad
public void afterLoad(ArticleEntity entity) throws JsonProcessingException {
	checkPermission(entity.getClass().getSimpleName(), "read");

	// % protected region % [Override the global configuration for read audits for the ArticleEntity here] off begin
	if (securityProperties.isReadAuditEnabled()) {
		// Create a new read record against this entity.
		auditService.createWith(entity);
	}
	// % protected region % [Override the global configuration for read audits for the ArticleEntity here] end

	// % protected region % [Add any custom logic to be executed before the entity has been loaded here] off begin
	// % protected region % [Add any custom logic to be executed before the entity has been loaded here] end
}

I believe that should resolve your issue.

Thanks @kellie, it should solve my problem. I look forward to the release.

1 Like

Hi @Afriana_Putra_I_B, good

SpringBot Release 2.4.1.0 has just been released and contains the changes to allow you to control the read audits.

We have updated our documentation to match this new functionality. So please refer to that for details.

2 Likes