2016-07-28 16 views
0

私たちはSpring Security 4.xを使用しており、BasicAuthenticationFilterを無効にしたいと考えています。 残念ながら、私はBasicAuthenticationFilterの要素とhttp要素のクラス名を構成する方法を見つけることができませんでした。http-basic要素でもスキーマの構成でもありません。スキーマ構成を使用してBasicAuthenticationFilterをオーバーライドする方法は?

BasicAuthenticationFilterのスキーマ構成をオーバーライドする方法はありますか?

私はBasicAuthenticationFilterをカスタムフィルタを使用してオーバーライドしようとしました。スキーマはデフォルトのBasicAuthenticationFilterを作成し続けます。

は非常に奇妙な

を追加しました。私はauto-config="falseを設定しましたが、デフォルトのBasicAuthenticationFilterの作成をまだ見ることができます。

したい場合にはxsdのスキーマのドキュメントを1としてhttp://docs.spring.io/spring-security/site/docs/4.0.x/reference/htmlsingle/#nsa-http

を追加しました

設定W/O豆の定義

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


    <sec:global-method-security pre-post-annotations="enabled"> 
     <!-- AspectJ pointcut expression that locates our "post" method and applies security that way 
     <protect-pointcut expression="execution(* bigbank.*Service.post*(..))" access="ROLE_TELLER"/> 
     --> 
    </sec:global-method-security> 

    <sec:http use-expressions="true" auto-config="true" pattern="/api/**" disable-url-rewriting="false" entry-point-ref="authenticationEntryPoint"> 
     <sec:custom-filter ref="rememberUrlFilter" before="BASIC_AUTH_FILTER"/> 
     <sec:custom-filter position="PRE_AUTH_FILTER" ref="ssoFilter" /> 

     <sec:intercept-url pattern="/api/**" access="isAuthenticated()" /> 
     <sec:intercept-url pattern="/**" access="isAuthenticated()"/> 
     <sec:logout logout-url="/logout.faces" success-handler-ref="logoutSuccessHandlerImpl" /> 
     <sec:http-basic entry-point-ref="authenticationEntryPoint"/> 
     <sec:csrf disabled="true"/> 
     <sec:headers disabled="true"/> 
     <!--<sec:custom-filter ref="basicAuthenticationFilter" after="BASIC_AUTH_FILTER"/>--> 

     <sec:custom-filter ref="localhostIntegrationFilter" after="ANONYMOUS_FILTER"/> 
     <sec:access-denied-handler ref="accessDeniedHandler"/> 
    </sec:http> 

    <bean class="org.primefaces.webapp.filter.FileUploadFilter" name="fileUploadFilter"/> 

    <sec:http use-expressions="true" auto-config="true" disable-url-rewriting="false"> 
     <sec:custom-filter ref="fileUploadFilter" before="FIRST"/> 
     <sec:custom-filter ref="rememberUrlFilter" before="BASIC_AUTH_FILTER"/> 
     <sec:custom-filter position="PRE_AUTH_FILTER" ref="ssoFilter" /> 

     <sec:intercept-url pattern="/pages/**" access="isAuthenticated()" /> 
     <sec:intercept-url pattern="/login.faces" access="isAnonymous()"/> 
     <sec:intercept-url pattern="/js/**" access="permitAll"/> 
     <sec:intercept-url pattern="/css/**" access="permitAll"/> 
     <sec:intercept-url pattern="/images/**" access="permitAll"/> 
     <sec:intercept-url pattern="/img/**" access="permitAll" /> 
     <sec:intercept-url pattern="/**" access="isAuthenticated()"/> 

     <sec:csrf disabled="true"/> 
     <sec:headers disabled="true"/> 

     <sec:form-login login-page="/login.faces" 
         login-processing-url="/j_spring_security_check" 
         authentication-failure-url="/login.faces" 
         default-target-url="/pages/defaultPage.faces" 
         username-parameter="j_username" 
         password-parameter="j_password" 
         authentication-failure-handler-ref="authenticationFailureHandler" 
     /> 

     <sec:logout logout-url="/logout.faces" 
        success-handler-ref="logoutSuccessHandlerImpl" 
       /> 

     <sec:custom-filter ref="localhostIntegrationFilter" after="ANONYMOUS_FILTER"/> 
     <sec:access-denied-handler ref="accessDeniedHandler"/> 
    </sec:http> 

... 

</beans> 
+0

あなたの春のXML – 6ton

+0

を共有してください私は豆なしで設定を追加した – Michael

答えて

1

マニュアルに従って作成するべきではありませんフィルタを置き換えるには、positionタグを使用する必要があります。

<sec:custom-filter ref="customBasicAuth" position="BASIC_AUTH_FILTER"/> 

また、<sec:http-basic要素を含めると、デフォルトの基本認証フィルタがフィルタチェーンに追加されます。

auto-configは、従来の属性ではありませんし、除去することができます(falseに設定する必要)

+0

感謝を定義、 '自動設定の削除'仕事をした! 'auto-config'をfalseに設定したときに追加する必要があるのは分かっていますか? 私は現在の要素に 'form-login'は必要なく、私は' logout'を持っています。 'auto-config = true'と同じ機能を追加することはできますか? ここで完全な答えがわからない: http://stackoverflow.com/questions/18609655/what-is-the-use-of-auto-config-true-in-spring-security – Michael

+0

リンクされた回答が正しい。 auto-config "loginフォームを自動的に登録するレガシーアトリビュート、BASIC認証、ログアウトURLとログアウトサービス"に関するxsdにも同じことが言及されています。この場合のログアウトサービスは、ログアウトを処理するフィルタです。 – 6ton

+0

ありがとう、賞金の価値があるあなたの助け:) – Michael

関連する問題