SugarCRM inside of Liferay
Certainly the title of the article may seem a little odd, but I have not found better title. I could give a title like “Integration between CRM ….” but then I was not very convinced!
We are going through a phase where it is needed more and more integration between most disparate information systems with different responsibilities, it’s like doing a puzzle, combine sets different pieces so that their collaboration allows to reach the goal, trying to maintain a single interface to interact with the whole or parts of the puzzle.
We will then see how it is possible and easy to put SugarCRM “inside” Liferay. Assuming a scenario where Liferay implements a web portal of a hypothetical company would not be something out of the ordinary, give access to CRM from the web portal without having to be forced to open a new browser window and avoid repeating the authentication .
Achieving the goal is really simple with Liferay, it is only an activity configuration of the iFrame portlet, already available with Liferay. As shown in the course of the discussion is applicable to the Community Edition and Enterprise Edition of Liferay, the version used is a 6.1 CE GA2.
To ensure that the proposed solution is applicable, it is essential that the following requirements are met:
- Access to the portal with an administrative role or a role that allows you to add applications (portlets) and configuration options;
- Ability to perform administrative tasks, such as operations of start, stop and change configurations;
- URL of SugarCRM.
Each user of the portal, so authenticated, you can access directly from the portal to the application of CRM, without repeating the authentication procedure. As introduced above, this is possible through iframe portlets.
The Iframe portlet makes it possible to embed another HTML page inside the current page. Furthermore the user can navigate through the embedded page without loosing the context of the portal page.
The Iframe portlet uses the HTML iframe tag that is part of HTML 4 and is supported in all major browsers. The iframe portlet will adjust to the size of the HTML page if that page is hosted in the same server. The browser will add scrollbars if the embedded page does not fit within the size of the iframe.
An important feature of this portlet and fundamental in this scenario, the possibility to perform the authentication process for us. Supports two types of authentication: Basic and Form, we will use the second method, however, the choice depends on the type of authentication supported by the web application to integrate.
You may have guessed that a prerequisite in order for the authentication to work properly, you must have your username (usually the attribute screen name) and password of the portal coincide with those of CRM.
Once you add the portlets on a your page, you just have to continue with the configuration whose main parameters and values are as follows:
- URL of SugarCRM to which you want to give access;
- Authentication type:
- Type: Form
- Method: POST
- FieldName: user_name
- Value: @screen_name@
- FieldName: user_password
- Value: @password@
- Hidden Variable
The values shown as @screen_name@ and @password@, then replaced at runtime with the actual values and then sent to SugarCRM in the process of authentication, that’s why it is necessary that the credentials match, in Otherwise you will be necessarily required to manually perform authentication in the form of SugarCRM. In Figure 1 is shown the configuration of the iFrame portlets. The specified URL refers to an instance of SugarCRM CE 6.5 hosted on the Cloud Open Shift.
There is a security mechanism such that your credentials are not stored (in session, cookies, etc …) by default, you can also make sure that only users belonging to a particular role can send your password to external systems through the iFrame portlet.
Through the configuration properties (see the Listing 2) you can enable the storage of the password (unencrypted) in session, and also specify the role to be assigned to users who need to be able to send your password to the outside through the iFrame portlet.
Listing 1 Get clear password from session (Link on Gist ).
Listing 1 shows GetPassword() class IFrameUtil com.liferay.portlet.iframe.util package that retrieves the user’s password from the session, checking the association role/user using the method isPasswordTokenEnabled().
Listing 2 Configuration properties file portal-ext.properties (Link su Gist).
The configuration (see Listing 2) shows the role (a name of your choice) to which users must belong and the explicit instruction to store in session, the user’s password. The application of this configuration requires a restart of the portal. The configuration shown in Listing 2 must be specified in the file portal-ext.properties. This file must be created or found within the directory webapps/ROOT/WEB-INF/classes.
After restarting the portal and set the iFrame portlet, you would login with your credentials to get your workspace ready to use CRM.
Figure 5 shows instead the passage of the parameters to the target application, in this case SugarCRM. I have highlighted in particular the password attribute, passed in the clear.
In this short article we have seen how easy it is to integrate SugarCRM “inside” Liferay exploiting the potential provision by the iFrame portlet. Is certainly convenient to be able to authenticate in a transparent manner. This solution can be used to integrate any type of web application.
- SugarCRM + PostgreSQL available OpenShift (musarra.wordpress.com)
- Released new version of SugarCRM PostgreSQL Virtual Appliance (musarra.wordpress.com)
- Released the first version of SugarCRM Java Client (musarra.wordpress.com)
- Liferay in Action (Manning) (i-programmer.info)
- Liferay iFrame Portlet (www.liferay.com)