【问题标题】:Spring Security suddenly stopped authenticating even tho it was working fine before即使之前运行良好,Spring Security 也突然停止了身份验证
【发布时间】:2014-11-02 06:58:01
【问题描述】:

这很奇怪。身份验证工作正常,但是当我今天启动该项目时,它不再工作了。我完全不知道有什么问题。当我输入正确的数据(是的,我 100% 确定它是正确的)并对其进行调试时,SPRING_SECURITY_LAST_EXCEPTION 包含 BadCredentialsException。这是我的 UserDetailsS​​ervice 类返回的内容:

如您所见,它从数据库中获取信息,构建用户并返回它,但 Spring Security 出于某种原因发疯了。
我的安全配置:

<context:component-scan base-package="pl.sikor.security" />

<http use-expressions="true">
    <intercept-url pattern="/game/**" access="isAuthenticated()"/>
    <intercept-url pattern="/**" access="permitAll"/>

    <form-login password-parameter="password"  username-parameter="username" login-page="/login"
                default-target-url="/game/profile" login-processing-url="/processLogin" authentication-failure-url="/login"/>
    <logout logout-url="/game/logout" logout-success-url="/logout" delete-cookies="true" invalidate-session="true"/>
</http>

<authentication-manager alias="authenticationManager">
    <authentication-provider user-service-ref="userDetailsServiceImpl">
        <password-encoder ref="bCryptPasswordEncoder" />
    </authentication-provider>
</authentication-manager>

<beans:bean id="bCryptPasswordEncoder" class="org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder"/>

我没有任何过滤器,springSecurityFilterChain 是唯一的,所以我想没有必要粘贴我的 web.xml 任何帮助将不胜感激。这让我发疯了。

顺便说一句,昨天,我使用 @OneToOne 和惰性获取类型将我的帐户表与另一个帐户表相关联,但我认为这与此无关。

【问题讨论】:

    标签: java spring spring-mvc authentication spring-security


    【解决方案1】:

    好的,我找到了。问题是我在 getter 上有 JPA 注释。当我把它们放在田野上时,它又开始工作了。
    我昨天把它们放在吸气剂上,因为人们说当你必须制作一个自定义吸气剂时很方便。我很想听听有人说为什么在我的情况下它会阻止 spring security 正常工作。

    【讨论】:

      猜你喜欢
      • 2017-06-16
      • 1970-01-01
      • 1970-01-01
      • 2016-08-26
      • 2016-10-14
      • 1970-01-01
      • 2012-11-27
      • 2011-10-17
      相关资源
      最近更新 更多