1

我在 IBM WebSphere 上部署了一个 JAX-RS Web 服务,我想在它接收到请求(从其他服务器委托)时保护这个 WS。所以我使用基本身份验证并在 BasicAuthSecurityHandler 对象上设置用户名和密码,并将请求委托给其他服务器。现在,当另一台服务器收到请求时,我在全局安全下使用 WAS 中的联合存储库并进行身份验证。

auth-constraint如果我在部署描述符中注释掉,则不会进行身份验证。我只想进行身份验证而不进行授权。我尝试@PermitAll在 Jax-WS 方法上使用注释,但授权也在执行 Jax-WS 方法之前发生。那么有什么方法可以跳过授权并仍然进行身份验证?

我没有与我的用户关联的任何规则,所以我想跳过授权。

<security-constraint id="SecurityConstraint_1">
  <display-name>RESTSecurity</display-name>
    <web-resource-collection id="WebResourceCollection_1">
      <web-resource-name>DelegateReqComApp</web-resource-name>
      <description>
          Protection area for Rest resource /addresses
      </description>
      <url-pattern>/rest/*</url-pattern>
      <http-method>GET</http-method>
      <http-method>POST</http-method>
    </web-resource-collection>

    <!-- Authorization Constraint commented out  -->
    <auth-constraint id="AuthConstraint_1">
        <description>
                Used to guard resources under this url-pattern
        </description>
        <role-name>iapawas012</role-name>
    </auth-constraint>
</security-constraint>
4

1 回答 1

1

创建auth-constraint并将角色映射iapawas012到特殊主题ALL_AUTHENTICATED。它基本上说任何成功通过身份验证的用户都有权调用您的服务。
您可以在 Web 管理控制台中执行此操作,也可以通过文件夹中 EAR 中的Enterprise Application > yourApplication > Security role to user/group mapping绑定文件执行此操作:ibm-application-bnd.xmlMETA-INF

<?xml version="1.0" encoding="UTF-8"?>
<application-bnd
    xmlns="http://websphere.ibm.com/xml/ns/javaee"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://websphere.ibm.com/xml/ns/javaee http://websphere.ibm.com/xml/ns/javaee/ibm-application-bnd_1_2.xsd"
    version="1.2">

    <security-role name="iapawas012">
        <special-subject type="ALL_AUTHENTICATED_USERS" />
    </security-role>
</application-bnd>
于 2014-11-24T23:05:14.933 回答