OFBiz Single Sign On using CAS and LDAP
Setup the Java Key Store From the directory in which you want to create the keystore, run keytool with the following parameters. Generate the server certificate. $ keytool -genkey -alias tomcat -keyalg RSA -keypass changeit -storepass changeit -keystore keystore.jks When you press Enter, keytool prompts you to enter the server name, organizational unit, organization, locality, state, and country code. Note that you must enter the server name in response to keytool's first prompt, in which it asks for first and last names. For testing purposes, this can be localhost. Export the generated server certificate in keystore.jks into the file server.cer. $ keytool -export -alias tomcat -storepass changeit -file server.cer -keystore keystore.jks To create the trust-store file cacerts.jks and add the server certificate to the trust-store, run keytool from the directory where you created the keystore and server certificate. Use the following parameters: $ keytool -import -v -trustcacerts -alias tomcat -file server.cer -keystore cacerts.jks -keypass changeit -storepass changeit Information on the certificate, such as that shown next, will display. $ keytool -import -v -trustcacerts -alias tomcat -file server.cer -keystore cacerts.jks -keypass changeit -storepass changeit Owner: CN=localhost, OU=Sun Micro, O=Docs, L=Santa Clara, ST=CA, C=US Issuer: CN=localhost, OU=Sun Micro, O=Docs, L=Santa Clara, ST=CA, C=US Serial number: 3e932169 Valid from: Tue Apr 08 Certificate fingerprints: MD5: 52:9F:49:68:ED:78:6F:39:87:F3:98:B3:6A:6B:0F:90 SHA1: EE:2E:2A:A6:9E:03:9A:3A:1C:17:4A:28:5E:97:20:78:3F: Trust this certificate? [no]: Enter yes, and then press the Enter or Return key. The following information displays: Certificate was added to keystore [Saving cacerts.jks]
CAS Server Download CAS server from the CAS web site. Deploy cas-server-webapp-[version].war to Tomcat Set key store file to Tomcat keystoreFile="path/to/keystore.jks" Start Tomcat
OFBiz Certificate Set trust store's file to Java Virtual Machine (JVM) before start OFBiz. -Djavax.net.ssl.trustStore=path/to/cacerts.jks
LDAP Component OFBiz uses the LDAP component in the specialpurpose to check the security in a web application. OFBiz disabled LDAP component as default, you can enable this component by take the comment out from specialpurpose/component-load.xml file.
LDAP Properties LDAP properties file is specialpurpose/ldap/config/ldap.xml. You can change a filter condition you want.
Attributes Attribute : LDAP attbitue for filter e.g. uid=%u AuthenType : LDAP authentication method e.g. simple AuthenticaionHandler : CAS handler class e.g. org.ofbiz.ldap.cas.OFBizCasAuthenticationHandler AutoPartyId : Party's id for user login e.g. admin AutoSecurityGroupId : Security group's id for user login e.g. FULLADMIN BaseDN : The top level ofbiz LDAP directory tree e.g. dc=example,dc=com Filter : LDAP search filter e.g. (objectclass=*) Scope : LDAP search scope parameter e.g. sub,one, etc. URL : LDAP server's url e.g. ldap://localhost:389 UserOFBizLoginWhenLDAPFail : indicate that if LDAP fail then login with normal OFBiz's user or not. (true/false)
CAS CasLoginUri : URI to CAS login e.g. /login CasLogoutUri : URI to CAS logout e.g. /logout CasUrl : CAS Server's URL e.g. https://localhost:8443/cas CasValidateUri : URI to CAS validate e.g. /validate CasLdapHandler : LDAP hanlder class e.g. org.ofbiz.ldap.openldap.OFBizLdapAuthenticationHandler CasTGTCookieName : CAS TGT's cookie name e.g. CASTGC
OpenLDAP The LDAP component need data from LDAP server (OpenLDAP). The server needs to install, configure and populate OpenLDAP: see at the OpenLDAP web site.
Web Application Security Mapping Every web application you need to use LDAP (single sign on) feature, you need to change the event's path of some the security request mappings to org.ofbiz.ldap.LdapLoginWorker class.
checkLogin <request-map uri="checkLogin" edit="false"> <description>Verify a user is logged in.</description> <security https="true" auth="false"/> <event type="java" path="org.ofbiz.ldap.LdapLoginWorker" invoke="checkLogin"/> <response name="success" type="view" value="main"/> <response name="error" type="view" value="login"/> </request-map>
login <request-map uri="login"> <security https="true" auth="false"/> <event type="java" path="org.ofbiz.ldap.LdapLoginWorker" invoke="login"/> <response name="success" type="view" value="main"/> <response name="requirePasswordChange" type="view" value="requirePasswordChange"/> <response name="error" type="view" value="login"/> </request-map>
logout <request-map uri="logout"> <security https="true" auth="true"/> <event type="java" path="org.ofbiz.ldap.LdapLoginWorker" invoke="logout"/> <response name="success" type="request-redirect" value="main"/> <response name="error" type="view" value="main"/> </request-map>