Issue
- This article outlines how to configure two Liferay DXP bundles for SAML authentication with one functioning as the Service Provider (SP) and the second as the Identity Provider (IdP).
Environment
- DXP 7.4
Resolution
Note: The below steps are for testing purposes only.
- Extract two 7.4 bundles to folders titled
SPandIdPand put DXP activation keys in both deploy folders. - Add
127.0.0.1 liferaytest.comin the local environment’s 'hosts' file to makeliferaytest.comviable. (User can refer to: Modify your hosts file or How to Edit Hosts File in Windows, MacOS and Linux) - Create a file called
com.liferay.portal.search.elasticsearch7.configuration.ElasticsearchConfiguration.configin both bundles’ osgi/config folders and add the following content:sidecarHttpPort="AUTO"
- In the
IdPbundle, navigate to[tomcat home]/confand openserver.xmland change the port numbers to the following:
<Server port="9005" shutdown="SHUTDOWN">
<Connector port="9080" protocol="HTTP/1.1"
connectionTimeout="20000"
redirectPort="8443" URIEncoding="UTF-8" /> - Start the bundles.
-
Configuring the Liferay DXP (SP) bundle as the SP:
- Access the SP bundle.
- Sign in as the Administrator
- Navigate to the Open Menu icon > Control Panel > Security > SAML Admin.
-
On the General tab:
- Select - SAML Role: Service Provider
- Enter - Entity Id: samlsp
- Click On Save
-
Under Certificate and Private Key, click on Create Certificate
- Common Name: test
- Organization: test
- Organization Unit: test
- Locality: test
- State: test
- Country: test
- Validity (days): 356
- Key Algorithm: RSA
- Key Length (Bits): 2048
- Key Password: liferaysp
- Check the box next to Enabled and click on Save
-
Configuring the Liferay DXP (IDP) bundle as the IdP:
- Access the IDP bundle.
- Sign in as the Administrator
-
Configure the bundle to use a virtual host of
liferaytest.com:-
--> Navigate to the Control Panel > Virtual Instances > Click three dots > then, Edit
--> Under Virtual Host, enter 'liferaytest.com' and save it. - Navigate to the Control Panel > Security > SAML Admin.
-
On the General tab:
- Select - SAML Role: Identity Provider
- Enter - Entity Id: samlidp
- Click On Save
-
Under Certificate and Private Key, click on Create Certificate
- Common Name: test
- Organization: test
- Organization Unit: test
- Locality: test
- State: test
- Country: test
- Validity (days): 356
- Key Algorithm: RSA
- Key Length (Bits): 2048
- Key Password: liferayidp
- On the General tab click the box next to Enabled and then click on Save
-
Select the Service Provider Connections tab then Add Service Provider
- Name: samlsp
- Entity Id: samlsp
- Enabled: Checked
-
Metadata URL:
http://localhost:8080/c/portal/saml/metadata - Name Identifier Format: Email Address
- Name Identifier Attribute Name: emailAddress
- Attributes Enabled: Checked
-
Under the 'Attributes' section, enter values as below:
firstName
lastName
screenName
emailAddress
9. Click on Save, you should return to the Service Provider Connections tab if the configurations are saved successfully.
-
Return to the Service Provider Liferay DXP bundle:
- Sign in as the Administrator if the account was signed out.
- Return to the SAML Admin menu
- Select the Identity Provider Connections then click on Add Identity Provider
- Name: samlidp
- Entity ID: samlidp
- Enabled: Checked
-
Metadata URL:
http://liferaytest.com:9080/c/portal/saml/metadata - Name Identifier Format: Email Address
- Under the 'Attribute Mapping' section, Click on the '+' icon and add four 'Basic User Fields'
-
Enter the values as shown in below image:
- Click on Save.
- Now, drag and drop one 'Sign In' widget to the Home Page of the Service Provider and Publish it. (In case the SAML configurations are incorrect this will allow for a direct login to the Service Provider bypassing the SAML authentication entirely)
-
Testing the SAML authentication:
- Sign out of the SP bundle or use a different browser.
- Access the SP bundle.
- Click on the Sign In button in the top right corner.
- The user should be redirected to the IDP, in this case:
http://liferaytest.com:9080/web/guest/home?... - Sign in using the provided portlet.
- The user should be redirected to the SP and logged in there.
You have Successfully Configured Liferay as both SP and IdP.