使用定制拦截器与 WebSphere Application Server 安全性集成

该部分描述了如何创建 SSO 拦截器以便与 WebSphere® Application Server 安全性集成。

开始之前

必须使用 LDAP 用户凭证在 WebSphere Application Server 中对您进行配置。
注: 必须使包含 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 目录中(从 war 文件中扩展的文件中)查找 web.xml 文件。编辑该文件以添加安全上下文。例如,在文件结束处,在 </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 启动过程的一部分而启动,所以先启动 WebSphere Application Server,然后启动 Build Forge。

新建 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_user1LDAP_user2|local_user2LDAP_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。

反馈