2012-05-04 14 views
6

Tomcat 7で動作するJava 6アプリケーションとしてAxis Webサービスを作成しました。セキュリティのため、Spring Security 2.0.1フレームワークが統合されています。Springセキュリティ:WSDLドキュメントの認証を除外する

セキュリティのため、サービスエンドポイントは基本認証で保護する必要があります。ただし、WSDLドキュメントは公開されている必要があります。

私はこのような春のセキュリティ設定を作成している


<?xml version="1.0" encoding="UTF-8"?> 
<beans:beans xmlns="http://www.springframework.org/schema/security" 
    xmlns:beans="http://www.springframework.org/schema/beans" 
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
    xsi:schemaLocation=" 
      http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd 
      http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security-2.0.1.xsd"> 

    <http> 
     <intercept-url pattern="/services/InitechAuthenticationService*" access="ROLE_WSUSER" /> 
     <intercept-url pattern="/services/InitechAuthenticationService?wsdl" filters="none" /> 
     <http-basic /> 
    </http> 

    <authentication-provider> 
     <user-service> 
      <user name="internal" password="${WS_USER_INTERNAL_PASSWORD}" authorities="ROLE_WSUSER" /> 
      <user name="external" password="${WS_USER_EXTERNAL_PASSWORD}" authorities="ROLE_WSUSER" /> 
     </user-service> 
    </authentication-provider> 

</beans:beans> 
問題は関係なく、インターセプト-URL行の順序、ラインの


<intercept-url pattern="/services/InitechAuthenticationService*" access="ROLE_WSUSER" /> 

常に適用されるように見えるということです

行番号


<intercept-url pattern="/services/InitechAuthenticationService?wsdl" filters="none" /> 

は無視されます。何らかの形で行動をコントロールできると期待していたでしょう。 (この場合、Spring Securityが最初または最後のマッチングルールを選択するように)順序を指定するか、またはルールの特異性によって指定して、Spring Securityが最も特定のルール、つまりこの場合は「wsdl」を持つルールを選択するようにします。 WSDLドキュメントを認証から除外し、同時にWSを実際に使用するための認証を有効にする方法はありますか?

答えて

4

Ant Path Matcherの代わりに正規表現を使用するように構成のhttp部分を変更することで問題を解決しました。完全な作業の設定ここにある:


<?xml version="1.0" encoding="UTF-8"?> 
<beans:beans xmlns="http://www.springframework.org/schema/security" 
    xmlns:beans="http://www.springframework.org/schema/beans" 
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
    xsi:schemaLocation=" 
      http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd 
      http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security-2.0.1.xsd"> 

    <http path-type="regex"> 
     <intercept-url pattern="/services/InitechAuthenticationService*" access="ROLE_WSUSER" /> 
     <intercept-url pattern="/services/InitechAuthenticationService\\?wsdl" filters="none" /> 
     <http-basic /> 
    </http> 

    <authentication-provider> 
     <user-service> 
      <user name="internal" password="${WS_USER_INTERNAL_PASSWORD}" authorities="ROLE_WSUSER" /> 
      <user name="external" password="${WS_USER_EXTERNAL_PASSWORD}" authorities="ROLE_WSUSER" /> 
     </user-service> 
    </authentication-provider> 

</beans:beans> 

変更:

  1. は変更
  2. をhttpにパス型 "正規表現" 属性を追加しましたか? 〜に? intercept-url for wsdl
関連する問題