使用自訂攔截程式來與 WebSphere Application Server 安全整合

本節說明如何建立 SSO 攔截程式,來與 WebSphere® Application Server 安全整合。

開始之前

您在 WebSphere Application Server 中必須以 LDAP 使用者認證來配置。
註: 您必須使包含 WebSphere Application Server 使用者的 Build Forge LDAP 網域成為「預設」LDAP 伺服器。若要執行這項作業,請移至這個 Build Forge LDAP 網域,然後選取設為預設值

關於這項作業

所提供的「表單 SSO 攔截程式」會以表單型登入頁面來鑑別使用者。以下是如何建立自訂 SSO 攔截程式的範例。自訂攔截程式會使用自訂攔截程式類別。

攔截程式類別會存取 WebSphere Application Server,以取得經過鑑別的使用者認證。取得這些認證之後,即會加以快取。後續登入會使用快取的認證。

保護授權服務 (AuthServlet)

Build Forge 通常會在所提供的 Apache Tomcat 應用程式伺服器中,將其服務當成應用程式來執行。

關於這項作業

下列指示會配置 Build Forge 來使用 WebSphere Application Server,而非 Tomcat。請遵循使用 WebSphere Application Server 而非 Apache Tomcat 一節中的指示,但有一個例外:jas.war 檔包含名為 web.xml 的檔案,您需要擷取並修改它,才能新增安全限制。在 WebSphere Application Server 下安裝這個應用程式之前,修改 war 檔之後必須重新產生它,才能使用這個檔案的受保護版本。

若要重新產生 war 檔,請完成下列步驟。

程序

  1. 導覽至包含 jas.war 檔的目錄(Tomcat 伺服器根目錄中的 webapps 目錄)。 將這個檔案複製到暫存位置,例如:C:\jas
  2. 展開 WAR 檔。 從指令行執行指令:%IBM_JAVA_HOME%\jar -xvf jas.war,以展開 war 檔的內容。
    註: Java 必須可供使用,且必須已建立 IBM_JAVA_HOME 環境變數。
  3. 儲存 jas.war 檔以供之後擷取:
    1. Windows:copy jas.war jas.war.bak
    2. UNIX 或 Linux:cp jas.war jas.war.bak
  4. WEB-INF 目錄中找出 web.xml 檔(在從 war 檔展開的檔案中)。請編輯這個檔案來新增安全環境定義。例如,在檔案尾端的 </web-app> 標籤前加入以下各行:
    <security-constraint id="SecurityConstraint_1">
             <web-resource-collection id="WebResourceCollection_1">
                <web-resource-name>/*</web-resource-name>
                <url-pattern>/AuthServlet/*</url-pattern>
                <http-method>GET</http-method>
                <http-method>POST</http-method>
                <http-method>PUT</http-method>
                <http-method>DELETE</http-method>
             </web-resource-collection>
             <auth-constraint id="AuthConstraint_1">
                <description>myconstraint:+:</description>
                <role-name>User</role-name>
             </auth-constraint>
             <user-data-constraint id="UserDataConstraint_1">
                <transport-guarantee>NONE</transport-guarantee>
             </user-data-constraint>
          </security-constraint>
          <login-config id="LoginConfig_1">
             <auth-method>BASIC</auth-method>
             <realm-name>full-qualified-domain</realm-name>
          </login-config>
          <security-role id="SecurityRole_1">
             <role-name>User</role-name>
          </security-role>
    註: <auth-method> 可以是 WebSphere Application Server 支援的任何 J2EE 鑑別方法。最常用的鑑別方法是 FORM,其需要額外的配置參數。請參閱 WebSphere Application Server 文件,以取得在應用程式中配置 FORM 的指示。
  5. 從指令行執行下列指令,以重新產生 war 檔(從解壓縮的同一個目錄中呼叫):
    %IBM_JAVA_HOME%\jar -cvf jas.war

    您現在應該有新版的 jas,其已修改來保護含有 J2EE 限制的 AuthServlet。請完成搭配 WebSphere Application Server 執行的安裝指示,並透過應用程式->安裝新的應用程式來安裝這個版本的 jas.war。在配置 WebSphere Application Server 時,請確定 Build Forge 不在執行中。

    安裝之後,移至應用程式 > 企業應用程式。按一下要配置的應用程式名稱。在詳細內容下,按一下安全角色至使用者/群組對映鏈結。請對「使用者」選取所有已鑑別的使用者勾選框。進行這項變更之後,將變更儲存至主要配置。

    WebSphere Application Server 下也需要啟用應用程式安全。若要執行這項作業,請移至安全 > 安全管理、應用程式和基礎架構。請務必勾選啟用應用程式安全

    此時,請重新啟動 WebSphere Application Server,然後重新啟動 Build Forge 伺服器。
    註: jas 現在會在 WebSphere Application Server 啟動過程中啟動,所以在啟動 Build Forge 之前,請先啟動 WebSphere Application Server

建立新的 SSO 配置

建立新的 SSO 配置來使用攔截程式。

程序

  1. 在 Build Forge 主控台中,移至管理 > 安全 > SSO
  2. 按一下新增 SSO 配置
  3. 設定配置的內容。
    • 名稱 - 輸入這個配置的名稱。
    • Java 類別 - 輸入 com.buildforge.services.server.sso.was.WebSphereSSOInterceptor
    • 作用中 - 選取
  4. 按一下儲存
  5. 移動這個配置,使其成為清單的第一個項目。 在配置名稱左邊的功能表中,選取移至頂端

將 LDAP 使用者或 LDAP 群組對映到本端使用者

將 LDAP 使用者或 LDAP 群組對映到本端使用者,例如本端 root 使用者。

關於這項作業

建立 WebSphere Application Server SSO 攔截程式後,您可以將攔截程式配置成:
  • 將 LDAP 使用者對映到本端使用者,包含 root
  • 將 LDAP 群組對映到本端使用者,例如 root

若要設定對映,請定義環境,然後在攔截程式中參照該環境。

定義環境

程序

  1. 在 Build Forge 主控台中,按一下環境
  2. 指定環境的名稱,然後按一下儲存環境
  3. 將 LDAP 使用者對映到本端使用者,設定及儲存下列變數:
    1. ldap_user_list_mapping 設為 LDAP_user1|local_user1;LDAP_user2|local_user2;LDAP_user3|local_user3
    2. ldap_realm_name 設為 LDAP_domain_name
    例如,假設設定下列環境:
    		ldap_user_list_mapping = user1|root;user2|root;user3|root
    		ldap_realm_name = bluepages.ibm.com:389

    在此情況下,LDAP user1、user2 和 user3 全部都會對映到本端 root 使用者。

  4. 若要將特定 LDAP 群組的成員對映到本端使用者,請設定並儲存下列變數:
    1. ldap_group_name_mapping 設為 LDAP_group|local_user
    2. ldap_realm_name 設為 LDAP_domain_name
    註: 如果您同時使用這兩種對映,則使用者對映優先於群組對映。
    群組對映範例,假設設定下列環境:
    		ldap_group_name_mapping = cn=bf_admin,ou=memberlist,ou=ibmgroups,o=ibm.com|root
    		ldap_realm_name = bluepages.ibm.com:389

    在此情況下,LDAP 群組 cn=bf_admin,ou=memberlist,ou=ibmgroups,o=ibm.com 的成員就會對映到本端 root 使用者。

參照環境

程序

  1. 在 Build Forge 主控台中,按一下管理 > 安全 > SSO
  2. 按一下 WebSphere Application Server SSO 攔截程式的名稱。
  3. 針對您剛剛定義的環境配置設定環境內容。
  4. 按一下儲存
  5. 移動這個配置,使其成為清單的第一個項目。 在配置名稱左邊的功能表中,選取移至頂端

執行 SSO 自訂攔截程式

您可以使用新配置登入。

關於這項作業

這個自訂的 SSO 攔截程式現在容許 WebSphere Application Server 安全技術鑑別使用者(透過將 AuthServlet 要求當成使用者傳給 Build Forge 的方式)。

程序

  1. 開啟 Web 瀏覽器,並輸入位址 http://localhost 您現在會看到鑑別頁面,而非 Build Forge 登入表單。
  2. 輸入使用者認證,然後按一下 Enter 鍵。
    註: 鑑別之後,就會自動登入。

    登出之後,會顯示預設的 jsp 頁面,而非登入表單。如果您仍然通過鑑別,則會自動完成後續的登入。

回復至表單型 SSO

您可以回復使用 SSO 登入表單。

關於這項作業

若要重新配置系統以使用「表單登入」,您必須在 WebSphere Application Server 下解除安裝 jas,然後重新安裝原始的 jas.war 檔。請在 Build Forge 下,確定已啟用表單型 SSO 攔截程式,且是列出的最上方項目。停用自訂 WebSphere Application Server 攔截程式。若要讓變更生效,您必須重新啟動 WebSphere Application Server 及 Build Forge。

程序

  1. 解除安裝 jas,並重新安裝原始 jas.war 檔。
  2. 在 Build Forge 下,確定已啟用表單 SSO 攔截程式,且是列出的第一個項目(請參閱上述「Build Forge SSO 安全配置」)。
  3. 停用自訂 WebSphere Application Server 攔截程式。
  4. 重新啟動 WebSphere Application Server
  5. 重新啟動 Build Forge。

意見