【问题标题】:jax-rs only authentication no authorizationjax-rs 仅认证无授权
【发布时间】:2015-01-22 12:25:13
【问题描述】:

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

如果我在部署描述符中注释掉auth-constraint,则不会进行身份验证。 我只想进行身份验证而不进行授权。 我尝试在 Jax-WS 方法上使用 @PermitAll 注释,但授权也在执行 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>

【问题讨论】:

    标签: websphere jax-rs restful-authentication ibm-was


    【解决方案1】:

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

    <?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>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-12-15
      • 2012-02-10
      • 2012-07-27
      • 2011-07-04
      • 2015-01-19
      • 2018-02-01
      • 1970-01-01
      • 2012-07-05
      相关资源
      最近更新 更多