2014-11-24 45 views
1

我在IBM WebSphere上部署了JAX-RS Web服务,我希望在接收请求(从其他服务器委派)时保护此WS。 因此,我使用basic auth并在BasicAuthSecurityHandler对象上设置用户名和密码,并将请求委托给其他服务器。 现在,当其他服务器收到请求时,我使用全局安全下的WAS中的联合存储库并执行身份验证。jax-rs only认证无授权

如果我在部署描述符中注释掉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> 

回答

1

创建auth-constraint和映射iapawas012作用的专题ALL_AUTHENTICATED。它基本上说任何成功认证的用户都有权调用你的服务。
你可以做到这一点无论是在上Enterprise Application > yourApplication > Security role to user/group mapping Web管理控制台或通过META-INF文件夹中的EAR绑定文件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> 
+0

非常感谢你,能解决问题。 – user2608576 2014-11-25 08:07:27