gpt4 book ai didi

java - Spring security PreAuthentication Filter 要求 AuthenticationEntryPoint

转载 作者:IT老高 更新时间:2023-10-28 13:47:38 24 4
gpt4 key购买 nike

我正在尝试将 PreAuthFilter(用于 Siteminder)与 Spring Security 3.0 一起使用。

 <http  use-expressions="true">
<intercept-url pattern="/admin/**" access="hasRole('ROLE_ADMIN')" />
<intercept-url pattern="/403.jsp" access="permitAll" />
<!-- Allow non-secure access to static resources -->
<intercept-url pattern="/css/**" filters="none" />
<intercept-url pattern="/images/**" filters="none" />

<custom-filter ref="siteminderFilter" position="PRE_AUTH_FILTER"/>

<!-- <form-login /> -->
<logout logout-success-url="/index.jsp"/>
</http>

<beans:bean id="siteminderFilter" class="org.springframework.security.web.authentication.preauth.RequestHeaderAuthenticationFilter">
<beans:property name="principalRequestHeader" value="SM_USER"/>
<beans:property name="authenticationManager" ref="authenticationManager" />
<beans:property name="exceptionIfHeaderMissing" value="false"/>
</beans:bean>

<beans:bean id="AdminUserDetailsService" class="com.fw.security.auth.MyUserDetailsService">
</beans:bean>

<beans:bean id="preauthAuthProvider" class="org.springframework.security.web.authentication.preauth.PreAuthenticatedAuthenticationProvider">
<beans:property name="preAuthenticatedUserDetailsService">
<beans:bean id="userDetailsServiceWrapper" class="org.springframework.security.core.userdetails.UserDetailsByNameServiceWrapper">
<beans:property name="userDetailsService" ref="AdminUserDetailsService"/>
</beans:bean>
</beans:property>
</beans:bean>

<authentication-manager alias="authenticationManager">
<authentication-provider ref="preauthAuthProvider" />
</authentication-manager>

以上配置失败

org.springframework.beans.factory.parsing.BeanDefinitionParsingException: Configuration problem: No AuthenticationEntryPoint could be established. Please make sure you have a login mechanism configured through the namespace (such as form-login) or specify a custom AuthenticationEntryPoint with the 'entry-point-ref' attribute 
Offending resource: ServletContext resource [/WEB-INF/security-app-context.xml]

1) 如何指定 AuthenticationEntryPoint???

2) 它真的适用于 PreAuthentication 场景吗???

解决方案

根据 axtavt 的 solution下面:

使用 Http403ForbiddenEntryPoint 创建一个 bean

<beans:bean id="http403EntryPoint" class="org.springframework.security.web.authentication.Http403ForbiddenEntryPoint">
</beans:bean>

并在

中引用它
<http  use-expressions="true" auto-config="false" entry-point-ref="http403EntryPoint">

最佳答案

我想在预认证的情况下你需要声明一个 Http403ForbiddenEntryPoint 并通过 entry-point-ref 引用它<http> 的属性.

关于java - Spring security PreAuthentication Filter 要求 AuthenticationEntryPoint,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8009834/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com