Rest 身份验证入口点之后的Spring安全流
我正在尝试使用spring security保护我的REST服务。我的问题是,我在身份验证入口点卡住了。即使我配置了UsernamePasswordAuthenticationFilter,执行流也无法到达那里。 下面是XML配置Rest 身份验证入口点之后的Spring安全流,rest,spring-security,Rest,Spring Security,我正在尝试使用spring security保护我的REST服务。我的问题是,我在身份验证入口点卡住了。即使我配置了UsernamePasswordAuthenticationFilter,执行流也无法到达那里。 下面是XML配置 <sec:http create-session="stateless" auto-config="false" authentication-manager-ref="authenticationManager"
<sec:http create-session="stateless" auto-config="false"
authentication-manager-ref="authenticationManager"
entry-point-ref="http403EntryPoint"
>
<sec:form-login
login-processing-url="/login"
password-parameter="password"
username-parameter="username"
/>
<!-- <sec:custom-filter ref="tokenCreatorAndValidator" position="FORM_LOGIN_FILTER" /> -->
<sec:intercept-url pattern="/**"
method="POST"
access="ROLE_USER"
/>
</sec:http>
<sec:authentication-manager alias="authenticationManager">
<sec:authentication-provider user-service-ref="authenticatorDAO">
</sec:authentication-provider>
</sec:authentication-manager>
<bean id="http403EntryPoint"
class="com.app.login.RestAuthenticationEntryPoint" />
有人能告诉我我做错了什么吗?很抱歉,我无法发表评论,因此将此作为答案发布 检查ExceptionTranslationFilter是否在现有配置中被调用 或 您是否在ExceptionTranslationFilter中注入了http403EntryPoint
<bean id="etf" class="org.springframework.security.web.access.ExceptionTranslationFilter">
<property name="authenticationEntryPoint" ref="http403EntryPoint"/>
</bean
没有,我没有注入entrypoint引用。而且我在错误跟踪中没有得到任何异常。在开始方法完成后,流程现在就开始了。如果我添加一个自定义筛选器来代替表单\u login\u筛选器,用户会得到身份验证,但AuthenticationEntryPoint会抛出“需要身份验证”错误。我的问题是,为什么在用户成功通过身份验证后执行authenticationentrypoint?
<bean id="etf" class="org.springframework.security.web.access.ExceptionTranslationFilter">
<property name="authenticationEntryPoint" ref="http403EntryPoint"/>
</bean