簡體   English   中英

從版本 3 遷移到版本 4 后,Spring Security 無法正常工作

[英]Spring Security not working after migrating from version 3 to 4

最近我從 Spring Security 3 遷移到版本 4。之前一切正常,但現在沒有任何效果。

這是我的spring-security.xml

<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-4.2.xsd
    http://www.springframework.org/schema/security
    http://www.springframework.org/schema/security/spring-security-4.0.xsd">

    <http auto-config="true" use-expressions="true"> 
        <intercept-url pattern="/home.MRCMPU" access="permitAll"/>
        <intercept-url pattern="/loginFailure.MRCMPU" access="permitAll"/>
        <intercept-url pattern="/*.MRCMPU"  access="permitAll"/>
        <intercept-url pattern="/con" access="permitAll"/>

        <form-login 
            login-page="/home.MRCMPU"
            login-processing-url="/login"  authentication-success-handler-ref="AuthenticationSuccess" 
            authentication-failure-handler-ref="AuthenticationFailure" username-parameter="username" password-parameter="password" />
        <logout logout-url="/logout.MRCMPU" success-handler-ref="Logout" invalidate-session="true" delete-cookies="true"/>
    </http>

    <authentication-manager>
        <authentication-provider user-service-ref="Authentication"/>
    </authentication-manager>
</beans:beans>

任何人都可以從這段代碼中找到沖突嗎?

您在這里缺少許多引用的 bean。

  1. user-service-ref="Authentication"
  2. success-handler-ref="Logout"
  3. authentication-success-handler-ref="AuthenticationSuccess"
  4. authentication-failure-handler-ref="AuthenticationFailure"

對於上面提到的參考文獻,否則你應該有豆子,比如

未定義名為“Logout”的 bean

將拋出異常。

添加bean類,如

<bean id="Authentication"
     class="class which you need to refer">
 </bean>

最后我自己清除了它。 通過使用 xml 禁用 csrf

 <csrf disabled="true"/>

但是我怎么能在不禁用 csrf 令牌的情況下做到這一點

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM