grails-audit-logging-plugin
grails-audit-logging-plugin copied to clipboard
Audit logging ignores multitenant mode
Hi, we are implementing an application which uses the GORM multitenancy in DATABASE mode, e.g.
grails:
gorm:
multiTenancy:
mode: DATABASE
However, the audit-logging plugin ignores the resolved tenant data source and always writes to the DEFAULT data source.
Could you add support for multitenancy?
feel free to send in a PR.
Ok, looking at it... it seems that the AuditLogListener is only reacting to events from the DEFAULT data source. Whatever happens in other data sources related to different tenants is completely ignored.
Could you point me in the right direction for fixing this?
Aha, this is related to #57 - it says "not possible"......
In the AuditLoggingGrailsPlugin descriptor, we register an AuditLogListener per DataSource. So you need to enable multi tenancy in the audit-test sub-project's AuditTrail domain class, as you write tests for this feature, right? ;-)
In the AuditLogListener, you need to figure out if the Domain object is tenant enabled and store the AuditTrail using this tennant id. Maybe 11.2.3 in Gorm 6.1 docs can be a hint.
Please note that the plugin must stay ORM agnostic. So you need to find an ORM independent way. Thus, don't deal with Hibernate / Mongo / etc. classes directly.
Haven't played around with tenancy yet, so the info above is just a rough guess.
Do we have support for multitenancy now?