Introduction #

Many organizations have the need to produce a audit trail of user actions. In many countries this is mandated by law and the data might need to be stored for long time. Audit Service provides a pluggable way of storing the audit trail from Liferay Portal and plugins. The information is then processed by Audit Service plugin that can store the information into log files or database or both.

Architecture #

Audit Service leverages Liferays Lightweight Message Bus and Plugin architecture. The service itself is a plugin that handles the processing and logging of the audit messages sent through the Message Bus. Any plugin can then produce audit messages to the audit message bus destination. A set of audit message producers is implanted as a hook plugin to provide information on login, logout, user information changes, user role changes etc.

Figure 1. Audit Service Architecture

Audit Event Message #

The audit event message is pushed to the message bus in JSON format allowing the stored data to be easily extended. The table below describes the message fields and their data type.

Field Type Description
companyId LONG Portal instance companyId
userId LONG User ID of user performing the action
userName STRING Username of the user performing the action
className STRING Target object class name id
classPK STRING Target object primary key
type STRING Action type
sessionID STRING HTTP Session ID
clientIP STRING Remote client IP address
serverIP STRING Originating server IP
timestamp DATETIME Event timestamp
additionalInfo STRING Additional information for the action in JSON format

Audit Plugin #

Audit plugin registers a new destination (liferay/audit) and listener to the message bus. The listener dispatches the messages to the audit service for processing. Different processors can be registered with the audit service. By default the plugin comes with a Database Processor and Log4J Processor. Processors can be either be global or for a specific event type. For instance database processor would be global but Log processor would be only for login events.

Figure 2. Audit Service Class Diagram

Processors #

Database Processor #

Database processor stores all events to database for later analysis. This information could be searched through a portlet. The database size can quite quick become huge if lot of information is logged. Then an archival or cleanup task should be used to keep the table size reasonable.

Figure 3. Database Processor Class Diagram

Log4J Processor #

Log4J processor logs the event information using Log4J logging framework. With Log4J configuration the information can be directed to a log file or even to another system through JMS, SMTP or SysLog. If the information is logged to a log file the file rolling and archival can be configured through log4j configuration file. The default log formatter is CSV formatter that formats the messages in CSV for easy importing into Excel. Also a JSON formatter is provided and can be configured in WEB-INF/classes/META-INF/ext-spring.xml. With property audit.log.csv.columns you can control which fields from audit message are logged and what their order is. By default all fields are logged in the order defined in Table 1.

Audit Reports #

Audit plugin comes with a reporting portlet. It allows you to search and browse the audit events stored into database.

Audit Hooks #

Liferay provides a lot of places to hook for creating custom audit hooks. By default audit service comes with following hooks to provide information of services like authentication, authorization and user management:

Hook Event Type Description
Login login Logs all logins. Implemented by com.liferay.portal.audit.events.authentication.LoginAudit
Logout logout Logs all logouts. Implemented by com.liferay.portal.audit.events.authentication.LogoutAudit
Login Failure login-failure Logs all login failures. Implemented by com.liferay.portal.audit.events.authentication.LoginFailureAudit
Impersonation impersonate Logs when impersonation is started. Implemented by com.liferay.portal.audit.events.user.ImpersonationAudit
Role create role-create Logs removal of a role. Implemented by com.liferay.portal.audit.events.user.RoleModificationAudit
Role remove role-remove Logs removal of a role. Implemented by com.liferay.portal.audit.events.user.RoleModificationAudit
Role update role Logs update of a role. Implemented by com.liferay.portal.audit.events.user.RoleModificationAudit
Role grant role-grant Logs role assignment to User, User Group, Organization or Community. Implemented by com.liferay.portal.audit.events.user.RoleModificationAudit for regular roles and com.liferay.portal.audit.events.user.UserGroupRoleModificationAudit for Organization and Community roles. value.object.listener.com.liferay.portal.model.Role=com.liferay.portal.audit.events.user.RoleModificationAudit
Role revoke role-revoke Logs role removal to User, User Group, Organization or Community. Implemented by com.liferay.portal.audit.events.user.RoleModificationAudit for regular roles and com.liferay.portal.audit.events.user.UserGroupRoleModificationAudit for Organization and Community roles. value.object.listener.com.liferay.portal.model.Role=com.liferay.portal.audit.events.user.RoleModificationAudit
User create user-create
User remove user-remove
User update profile
User contact update profile
User address update profile
User Group create usergroup-create
User Group remove usergroup-delete
User Group update usergroup-update

Installation and Configuration Reference #

For auditing to work you need to install audit-portlet and audit-hook from plugins incubation and you need to use the portal trunk until 5.3 is released.

Future Improvements #

Archiving #

Database can quickly fill up with audit events if all the user activities are audited and thus a archiving solution needs to be developed.

More audit hooks #

More hooks need to developed for being able to audit all the user activities on the portal.

6 Anexos
76988 Visualizações
Média (0 Votos)
A média da avaliação é 0.0 estrelas de 5.
Comentários
Respostas do tópico Autor Data
Nice feature, Thanks. Jonas Yuan 8 de Setembro de 2009 07:12
Really interesting. Is it avaliable only in... Denis Signoretto 9 de Setembro de 2009 09:10
Some of the audit hooks require Liferay 5.3. Mika Koivisto 10 de Setembro de 2009 14:06
Really good feature. Nagendra Kumar Busam 11 de Setembro de 2009 04:42
It is very useful features. please let us know ... Gnaniyar Zubair 10 de Setembro de 2009 04:40
You can download it from SVN... Mika Koivisto 10 de Setembro de 2009 14:03
You really need to add community and org for... Lisa Simpson 11 de Setembro de 2009 09:52
Nice Feature! Eagerly waiting!! Anand Abhyankar 14 de Dezembro de 2009 03:47
Lots of customers ask for this! Looking forward... Juan Fernández 15 de Dezembro de 2009 00:02
When can we expect 5.3 to arrive? Gunnar Velle 8 de Janeiro de 2010 02:40
Hi Is this feature already available in... Renee Talabucon 13 de Julho de 2010 00:01
Hello! I have few questions: 1) Is there is a... Sergei Shimanski 15 de Novembro de 2010 01:46
Yes, where can we find this functionality in... Peter Mesotten 1 de Dezembro de 2010 01:46
The Audit portlet and hook will be available... Randall Hidajat 20 de Dezembro de 2010 15:08
When 6.0.11 is expected to get released? Ahamed Hasan 28 de Dezembro de 2010 10:00
This audit service is at least available in... David García González 25 de Janeiro de 2011 02:09
Is there any documentation on how we can create... Chris Chan 2 de Fevereiro de 2011 18:47
Is there any documentation at all besides this... Jake Abernathy 22 de Abril de 2011 15:33
HI All! I want use audit -portlet in... Miller Huang 13 de Setembro de 2011 00:19
I have Liferay EE 6.0 SP1. How do I install or... James Cameron 24 de Outubro de 2011 23:38
Hi David, You can download it from the same... Christopher Lui 2 de Novembro de 2011 14:28
Thanks Christopher. Where may documentation on... James Cameron 9 de Novembro de 2011 17:08
cool feature......., but where can we get its... Amey Panke 5 de Janeiro de 2012 20:22
Want to use this feature. Where to find this... Mihir Jha 16 de Janeiro de 2012 22:27
It would be helpful to have some more in-depth... Adam Spence 26 de Janeiro de 2012 13:07

Nice feature, Thanks.
Postado em 08/09/09 07:12.
Really interesting. Is it avaliable only in Lifera 5.3? Where can I download it?
Postado em 09/09/09 09:10.
It is very useful features. please let us know where can we download this Audit Plugin?
Postado em 10/09/09 04:40.
You can download it from SVN svn://svn.liferay.com/repos/public/plugins/incubation
Postado em 10/09/09 14:03 em resposta a Gnaniyar Zubair.
Some of the audit hooks require Liferay 5.3.
Postado em 10/09/09 14:06 em resposta a Denis Signoretto.
Really good feature.
Postado em 11/09/09 04:42 em resposta a Mika Koivisto.
You really need to add community and org for the CREATE, REMOVE, and UPDATE. Not just the User Group.
Postado em 11/09/09 09:52.
Nice Feature!
Eagerly waiting!!
Postado em 14/12/09 03:47.
Lots of customers ask for this! Looking forward to using it.

By the way, thanks for documenting its implementation (class diagrams finally! emoticon)

A nice article would be "how to improve/customize the audit service portlet" so that we can do what Lisa Simpson says or to audit whatever we want (for example docs edit or blog posting)
Regards
Postado em 15/12/09 00:02.
When can we expect 5.3 to arrive?
Postado em 08/01/10 02:40.
Hi

Is this feature already available in Liferay 6? (i'm using RC 1)
Postado em 13/07/10 00:01.
Hello!
I have few questions:
1) Is there is a link between this feature and User Behaviour Tracking (
http://www.liferay.com/community/wiki/-/wiki/Main/User+Behavior+Tracking)?
2) I have a licensed EE6, but 'Audit' tab doesn't appear in Control Panel. So where i can download audit-portlet to install?
Postado em 15/11/10 01:46 em resposta a Renee Talabucon.
Yes, where can we find this functionality in Liferay 6 EE?
Postado em 01/12/10 01:46 em resposta a Sergei Shimanski.
The Audit portlet and hook will be available with Liferay 6.0.11
Postado em 20/12/10 15:08 em resposta a Peter Mesotten.
When 6.0.11 is expected to get released?
Postado em 28/12/10 10:00 em resposta a Randall Hidajat.
This audit service is at least available in Liferay 6 SP1 EE. I dont know if it is available in the CE.
Postado em 25/01/11 02:09.
Is there any documentation on how we can create our own audit hooks?

Thanks in advance,
Chris
Postado em 02/02/11 18:47.
Is there any documentation at all besides this wiki?
Postado em 22/04/11 15:33 em resposta a Chris Chan.
HI All!
I want use audit -portlet in liferay6.0.5CE,but when i deploy it to liferay and use it ,i see the logs

07:20:38,004 ERROR [jsp:154] com.liferay.portal.kernel.bean.BeanLocatorException: BeanLocator has not been set
at com.liferay.portal.kernel.bean.PortletBeanLocatorUtil.locate(PortletBeanLocatorU­til.java:40)
at com.liferay.portal.audit.service.AuditEventLocalServiceUtil.getService(AuditEven­tLocalServiceUtil.java:149)
at com.liferay.portal.audit.service.AuditEventLocalServiceUtil.countEvents(AuditEve­ntLocalServiceUtil.java:121)
at org.apache.jsp.view_jsp._jspService(view_jsp.java:627)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:331)
­at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:329)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:265)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilt­erChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.­java:206)
at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java­:646)
at org.apache.catalina.core.ApplicationDispatcher.doInclude(ApplicationDispatcher.j­ava:551)
at org.apache.catalina.core.ApplicationDispatcher.include(ApplicationDispatcher.jav­a:488)
at com.liferay.portlet.PortletRequestDispatcherImpl.dispatch(PortletRequestDispatch­erImpl.java:315)
at com.liferay.portlet.PortletRequestDispatcherImpl.include(PortletRequestDispatche­rImpl.java:104)
at com.liferay.util.bridges.mvc.MVCPortlet.include(MVCPortlet.java:328)
at com.liferay.util.bridges.mvc.MVCPortlet.include(MVCPortlet.java:343)
at com.liferay.util.bridges.mvc.MVCPortlet.doView(MVCPortlet.java:127)

i do not know why ?anybody know this???

Thanks....
Postado em 13/09/11 00:19 em resposta a Jake Abernathy.
I have Liferay EE 6.0 SP1. How do I install or enable the Audit Plugin? I can't seem to find any documentation on this.
Postado em 24/10/11 23:38 em resposta a huang Miller min.
Hi David,

You can download it from the same customer portal where the EE bundles are stored. Please find the Audit Plugin and Audit Hook.
Postado em 02/11/11 14:28 em resposta a David Munro-Ford.
Thanks Christopher. Where may documentation on configuring this plugin, and a definitive list of all events that can be logged / audited?
Postado em 09/11/11 17:08 em resposta a Christopher Lui.
cool feature......., but where can we get its proper documentation??
Postado em 05/01/12 20:22 em resposta a David Munro-Ford.
Want to use this feature. Where to find this plugin and other detail?
Postado em 16/01/12 22:27 em resposta a Amey Panke.
It would be helpful to have some more in-depth documentation on how to actually use the Audit portlet. I'm not able to deploy the portlet(I believe because the display category is set to "category.hidden", I tried changing this to "Audits" to no avail, it still doesn't show up in the menu).
Postado em 26/01/12 13:07.