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 Allegati
76985 Visualizzazioni
Media (0 Voti)
La media del punteggio è 0.0 stelle su 5.
Commenti
Commenti Autore Data
Nice feature, Thanks. Jonas Yuan 8 settembre 2009 7.12
Really interesting. Is it avaliable only in... Denis Signoretto 9 settembre 2009 9.10
Some of the audit hooks require Liferay 5.3. Mika Koivisto 10 settembre 2009 14.06
Really good feature. Nagendra Kumar Busam 11 settembre 2009 4.42
It is very useful features. please let us know ... Gnaniyar Zubair 10 settembre 2009 4.40
You can download it from SVN... Mika Koivisto 10 settembre 2009 14.03
You really need to add community and org for... Lisa Simpson 11 settembre 2009 9.52
Nice Feature! Eagerly waiting!! Anand Abhyankar 14 dicembre 2009 3.47
Lots of customers ask for this! Looking forward... Juan Fernández 15 dicembre 2009 0.02
When can we expect 5.3 to arrive? Gunnar Velle 8 gennaio 2010 2.40
Hi Is this feature already available in... Renee Talabucon 13 luglio 2010 0.01
Hello! I have few questions: 1) Is there is a... Sergei Shimanski 15 novembre 2010 1.46
Yes, where can we find this functionality in... Peter Mesotten 1 dicembre 2010 1.46
The Audit portlet and hook will be available... Randall Hidajat 20 dicembre 2010 15.08
When 6.0.11 is expected to get released? Ahamed Hasan 28 dicembre 2010 10.00
This audit service is at least available in... David García González 25 gennaio 2011 2.09
Is there any documentation on how we can create... Chris Chan 2 febbraio 2011 18.47
Is there any documentation at all besides this... Jake Abernathy 22 aprile 2011 15.33
HI All! I want use audit -portlet in... Miller Huang 13 settembre 2011 0.19
I have Liferay EE 6.0 SP1. How do I install or... James Cameron 24 ottobre 2011 23.38
Hi David, You can download it from the same... Christopher Lui 2 novembre 2011 14.28
Thanks Christopher. Where may documentation on... James Cameron 9 novembre 2011 17.08
cool feature......., but where can we get its... Amey Panke 5 gennaio 2012 20.22
Want to use this feature. Where to find this... Mihir Jha 16 gennaio 2012 22.27
It would be helpful to have some more in-depth... Adam Spence 26 gennaio 2012 13.07

Nice feature, Thanks.
Inviato il 08/09/09 7.12.
Really interesting. Is it avaliable only in Lifera 5.3? Where can I download it?
Inviato il 09/09/09 9.10.
It is very useful features. please let us know where can we download this Audit Plugin?
Inviato il 10/09/09 4.40.
You can download it from SVN svn://svn.liferay.com/repos/public/plugins/incubation
Inviato il 10/09/09 14.03 in risposta a Gnaniyar Zubair.
Some of the audit hooks require Liferay 5.3.
Inviato il 10/09/09 14.06 in risposta a Denis Signoretto.
Really good feature.
Inviato il 11/09/09 4.42 in risposta a Mika Koivisto.
You really need to add community and org for the CREATE, REMOVE, and UPDATE. Not just the User Group.
Inviato il 11/09/09 9.52.
Nice Feature!
Eagerly waiting!!
Inviato il 14/12/09 3.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
Inviato il 15/12/09 0.02.
When can we expect 5.3 to arrive?
Inviato il 08/01/10 2.40.
Hi

Is this feature already available in Liferay 6? (i'm using RC 1)
Inviato il 13/07/10 0.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?
Inviato il 15/11/10 1.46 in risposta a Renee Talabucon.
Yes, where can we find this functionality in Liferay 6 EE?
Inviato il 01/12/10 1.46 in risposta a Sergei Shimanski.
The Audit portlet and hook will be available with Liferay 6.0.11
Inviato il 20/12/10 15.08 in risposta a Peter Mesotten.
When 6.0.11 is expected to get released?
Inviato il 28/12/10 10.00 in risposta 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.
Inviato il 25/01/11 2.09.
Is there any documentation on how we can create our own audit hooks?

Thanks in advance,
Chris
Inviato il 02/02/11 18.47.
Is there any documentation at all besides this wiki?
Inviato il 22/04/11 15.33 in risposta 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....
Inviato il 13/09/11 0.19 in risposta 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.
Inviato il 24/10/11 23.38 in risposta 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.
Inviato il 02/11/11 14.28 in risposta 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?
Inviato il 09/11/11 17.08 in risposta a Christopher Lui.
cool feature......., but where can we get its proper documentation??
Inviato il 05/01/12 20.22 in risposta a David Munro-Ford.
Want to use this feature. Where to find this plugin and other detail?
Inviato il 16/01/12 22.27 in risposta 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).
Inviato il 26/01/12 13.07.