<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    Junky's IT Notebook

    統計

    留言簿(8)

    積分與排名

    WebSphere Studio

    閱讀排行榜

    評論排行榜

    Single SignOn - Integrating Liferay With CAS Server

    Introduction

    The following are a set of instructions for integrating Liferay Portal with CAS Server to setup single sign on (SSO) between Liferay and an existing web application.

    Setting up CAS server

    We will begin with setting up JA-SIG CAS server on Tomcat 5.x.x.

    Download cas-server WAR from Liferay's download page or the whole distribution from here and drop the cas-web.war file into Tomcat's webapps dir. In a production environment The CAS server should really run on its own tomcat instance but for testing purposes we'll drop it in the same instance as our Liferay portal.

    We'll need to edit the server.xml file in tomcat and uncomment the SSL section to open up port 8443.

    <Connector port="8443" maxHttpHeaderSize="8192"
    maxThreads="150" minSpareThreads="25" maxSpareThreads="75"
    enableLookups="false" disableUploadTimeout="true"
    acceptCount="100" scheme="https" secure="true"
    clientAuth="false" sslProtocol="TLS" />
    

    Setting up the CAS client

    Next we need to download the Yale CAS client from here. Get cas-client-2.0.11. Place the casclient.jar in ROOT/web-inf/lib of the Liferay install.

    Generate the SSL cert with Java keytool

    Now that we have everything we need, it's time to generate an SSL cert for our CAS server. Instructions and more information on SSL certs can be found here

    But I found some typos and errors on that page. So following the instructions below should get you what you need.

    In any directory ( I use my root ) enter the command:

    keytool -genkey -alias tomcat -keypass changeit -keyalg RSA

    Answer the questions: (note that your firstname and lastname MUST be hostname of your server and cannot be a IP address; this is very important as an IP address will fail client hostname verification even if it is correct)

    Enter keystore password:  changeit
    What is your first and last name?
    [Unknown]:  localhost
    What is the name of your organizational unit?
    [Unknown]:
    What is the name of your organization?
    [Unknown]:
    What is the name of your City or Locality?
    [Unknown]:
    What is the name of your State or Province?
    [Unknown]:
    What is the two-letter country code for this unit?
    [Unknown]:
    Is CN=localhost, OU=Unknown, O=Unknown, L=Unknown, ST=Unknown, C=Unknown correct?
    [no]: yes
    

    Then enter the command:

    keytool -export -alias tomcat -keypass changeit -file %FILE_NAME%
    

    I use server.cert for %FILE_NAME%. This command exports the cert you generated from your personal keystore (In windows your personal keystore is in C:\Documents and Settings\<username>\.keystore)

    Finally import the cert into Java's keystore with this command. Tomcat uses the keystore in your JRE (%JAVA_HOME%/jre/lib/security/cacerts)

    keytool -import -alias tomcat -file %FILE_NAME% -keypass changeit -keystore %JAVA_HOME%/jre/lib/security/cacerts
    

    Startup the CAS server

    Now you are ready to startup your CAS server. Simply startup Tomcat and access CAS with https://localhost:8443/cas You should see the CAS login screen and no errors in your catalina logs.

    Setting up Liferay Portal

    web.xml

    Note: If you are using Liferay 4.2, this filter is already defined. All you have to do is modify the URL parameters, if your CAS server is at a different location.

    It's time to move on to configuring Liferay. In the web.xml file you will need to add a new filter and its mapping directly above the first existing auto login filter mapping. This new filter we just added will redirect all login attempts to the CAS server. If your hostname is different you can modify the init-params accordingly.


    <filter>
    <filter-name>CAS Filter</filter-name>
    <filter-class>edu.yale.its.tp.cas.client.filter.CASFilter</filter-class>
    <init-param>
    <param-name>edu.yale.its.tp.cas.client.filter.loginUrl</param-name>
    <param-value>https://localhost:8443/cas-web/login</param-value>
    </init-param>
    <init-param>
    <param-name>edu.yale.its.tp.cas.client.filter.validateUrl</param-name>
    <param-value>https://localhost:8443/cas-web/proxyValidate</param-value>
    </init-param>
    <init-param>
    <param-name>edu.yale.its.tp.cas.client.filter.serviceUrl</param-name>
    <param-value>http://localhost:8080/c/portal/login</param-value>
    </init-param>
    </filter>
    

    If you use a ...serviceUrl param like above, after logging in with CAS, the browser will be redirected back to that serviceUrl. However, you can change it to the following and it will redirect back to the full URL that was originally requested. This allows you to have a deep link (e.g. to a certain layout with parameters for a portlet even) that is preserved through the CAS login process:

       <init-param>
    <param-name>edu.yale.its.tp.cas.client.filter.serverName</param-name>
    <param-value>localhost:8080</param-value>
    </init-param>
    


    <filter-mapping>
    <filter-name>CAS Filter</filter-name>
    <url-pattern>/c/portal/login</url-pattern>
    </filter-mapping>
    


    Then add the following to the rest of the auto login filters

    <filter-mapping>
    <filter-name>Auto Login Filter</filter-name>
    <url-pattern>/c/portal/login</url-pattern>
    <dispatcher>FORWARD</dispatcher>
    <dispatcher>INCLUDE</dispatcher>
    <dispatcher>REQUEST</dispatcher>
    </filter-mapping>
    

    system-ext.properties

    Note: this is only needed in Liferay 4.2

    Set the com.liferay.filters.sso.cas.CASFilter setting to true.

    Place the following in system-ext.properties:

       #
    # The CAS filter will redirect the user to the CAS login page for SSO. See
    # http://www.ja-sig.org/products/cas for more information.
    #
    com.liferay.filters.sso.cas.CASFilter=true
    

    portal-ext.properties

    Put this in portal-ext.properties.

    ##
    ## Auto Login
    ##
    
    #
    # Input a list of comma delimited class names that implement
    # com.liferay.portal.security.auth.AutoLogin. These classes will run in
    # consecutive order for all unauthenticated users until one of them return a
    # valid user id and password combination. If no valid combination is
    # returned, then the request continues to process normally. If a valid
    # combination is returned, then the portal will automatically login that
    # user with the returned user id and password combination.
    #
    # For example, com.liferay.portal.security.auth.BasicAutoLogin reads from a
    # cookie to automatically log in a user who previously logged in while
    # checking on the "Remember Me" box.
    #
    # This interface allows deployers to easily configure the portal to work
    # with other SSO servers. See com.liferay.portal.security.auth.CASAutoLogin
    # for an example of how to configure the portal with Yale's SSO server.
    #
    #auto.login.hooks=com.liferay.portal.security.auth.BasicAutoLogin
    auto.login.hooks=com.liferay.portal.security.auth.BasicAutoLogin,com.liferay.portal.security.auth.CASAutoLogin
    

    Comment the first auto.login.hooks property and uncomment the second to add CASAutoLogin to the list of AutoLogin implementations.

    Startup Liferay and Test

    Startup the portal and when the homepage loads up hit the login link. If all goes well you should be redirected to the CAS server's login screen. Login to CAS with liferay.com.1 as your username and liferay.com.1 as your password. You should now be logged into the portal.

    Next steps

    If the above test worked, you already have a CAS server installed and integrated with Liferay. The next steps are more related to properly configuring the CAS server than with Liferay. That's out of the scope of this article but we'll give a very brief summary.

    By integrating the CAS server Liferay, is no longer responsible for authenticating the users, it just trusts that the CAS server authenticates them properly. The CAS server has configurable strategies for authenticating users. So far the default one has been used, which just authenticates the user if the user and password are the same. That's completely unsecure so other options need to be considered before installing in a production environment. Some reasonable options would be:

    • To authenticate with LDAP: The CAS server includes an authentication handler for LDAP. You can read about it in http://www.ja-sig.org/products/cas/server/ldapauthhandler/index.html. If this option is chosen it is recommended that you also configure Liferay to authenticate against LDAP using the instructions in: LDAP. Then you'll need to provide some way to synchronized the users between LDAP and Liferay's database. Two options are:
      • Set up the automatic importer (see LDAP, available since v4.2)
      • Develop an extension to CASAutoLogin that upon successful login, if the user does not exist it is created with the user from LDAP (see this mb thread for details)
    • To authenticate with the portal's database: It is possible to develop your own CAS authentication handler that uses the information present in Liferay's database. One way of doing this would be using Liferay's services to authenticate the user.
    • To authenticate against another user store: in this case you'll also need to write your own CAS authentication handler and also provide Liferay some way to add the user entries in its own database.

    Some other steps that you might want to follow are:

    Also, check the references at the end of the article for more information.

    Troubleshooting

    If you created a cert with the %FILE_NAME%, you'll probably run into problems. Here are 2 commands to delete the tomcat alias from the keystore so you can start fresh:

    keytool -delete -alias tomcat -keystore %JAVA_HOME%/jre/lib/security/cacerts
    keytool -delete -alias tomcat -file server.cert
    
    • You may not be able to get https://localhost:8443/cas up and running after the cert key generation. If so, skip the test and try it after you've finished all the steps. If you can't login at that point, you've probably generated your cert incorrectly.
    • I've had problems with certs on IE7, make sure you try it out on Firefox and Opera.
    • Your certificate must be trusted. If you created a self-signed certificate, you must add it to your truststore. I mistakenly thought I could define the truststore settings on my Tomcat SSL Connector. That didn't work because CAS was redirecting (after logging in) to a non-SSL page. Since the HTTP connector didn't know to trust the self-signed certificate, I got the 'sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target' error. My solution was to follow the guidelines in the JSSE Reference Guide and define the truststore in the JAVA_OPTS (-Djavax.net.ssl.trustStore=/path/to/custom/truststore). I created both a custom keystore (needed by the SSL Connector and specified either in the Connector config or the JAVA_OPTS) and custom truststore.

    References

    • Lifecast: CAS Setup - Integrate Liferay Portal with a CAS server to access multiple applications with a single sign on.

    posted on 2007-05-29 17:07 junky 閱讀(4291) 評論(0)  編輯  收藏 所屬分類: portal

    主站蜘蛛池模板: 好湿好大好紧好爽免费视频| 91视频免费观看高清观看完整| jizz中国免费| 久久精品无码专区免费青青| 四虎影视www四虎免费| 亚洲精品国产成人片| 国产亚洲精品bv在线观看| 国产乱子伦精品免费视频| 久久久久久国产a免费观看黄色大片| 四虎国产精品免费视| 亚洲色图.com| 产传媒61国产免费| 在线观看日本免费a∨视频| 国产成人亚洲精品狼色在线| 国产精品亚洲精品观看不卡| 美女无遮挡拍拍拍免费视频| 国产在线观看片a免费观看| 亚洲色中文字幕无码AV| 亚洲日韩精品无码专区| 久久国产精品一区免费下载| 国产精品高清全国免费观看| 久久亚洲美女精品国产精品 | 国产精品久久免费视频| 亚洲人成电影在线天堂| 黄色网址在线免费观看| 动漫黄网站免费永久在线观看| 亚洲一区AV无码少妇电影☆| 日本亚洲欧美色视频在线播放| 中国人xxxxx69免费视频| 亚洲精品无码不卡在线播HE| 午夜亚洲国产精品福利| 97视频热人人精品免费| 亚洲日本精品一区二区 | 免费的黄色的网站| 99精品国产免费久久久久久下载| 亚洲国产精品一区二区久久hs| 香蕉视频在线观看免费| 岛国大片免费在线观看| 亚洲激情校园春色| 免费成人在线视频观看| 黑人大战亚洲人精品一区 |