사용자가 로그인했는지 여부에 관계없이 외부 소스 정보를 수신하는 웹 앱 필터에서 실행 중입니다. Heres 내 필터 :HttpServletResponse # addHeader에 문제가 있습니까?
@Override
public void doFilter(ServletRequest request, ServletResponse response,
FilterChain chain) throws IOException, ServletException
{
HttpServletRequest httpRequest = (HttpServletRequest) request;
HttpServletResponse httpResponse = (HttpServletResponse) response;
String loginBean = httpRequest.getHeader(CommonVariables.LOGIN_BEAN);
if (loginBean == null)
{
System.out.println("FILTER-----------");
try
{
String login;
String domain;
//Here i'm getting login and domain string
loginBean = domain + "\\" + login;
httpResponse.addHeader("LoginBean", loginBean);
System.out.println(login + " " + domain);
} catch (Exception e)
{
e.printStackTrace();
//redirect to login page
httpResponse.sendRedirect("...");
return;
}
}
chain.doFilter(request, response);
}
아니요 그런 헤더가 다음 필터로 전달 되지만요. 그럼 난 내 CustoUserDetailsService에 loginBean 문자열을 구문 분석하고 실제로 사용 사용자 개체를 받기 위해 노력
<http use-expressions="true" auto-config="false" entry-point-ref="http403EntryPoint">
<!-- Additional http configuration omitted -->
<custom-filter position="PRE_AUTH_FILTER" ref="siteminderFilter" />
</http>
<beans:bean id="siteminderFilter" class=
"org.springframework.security.web.authentication.preauth.RequestHeaderAuthenticationFilter">
<beans:property name="principalRequestHeader" value="LoginBean"/>
<beans:property name="authenticationManager" ref="authenticationManager" />
</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="userDetailsService"/>
</beans:bean>
</beans:property>
</beans:bean>
<beans:bean id="http403EntryPoint" class="org.springframework.security.web.authentication.Http403ForbiddenEntryPoint"/>
<beans:bean id="userDetailsService" class="com.execon.security.CustomUserDetailsService"/>
<authentication-manager alias="authenticationManager">
<authentication-provider ref="preauthAuthProvider" />
</authentication-manager>
봄 보안 컨텍스트 : 그러므로 나는 봄 보안 PRE_AUTH_FILTER을 구현했습니다. 그러나 그것은 해고되지 않으며, 응용 프로그램이 실패합니다
이org.springframework.security.web.authentication.preauth.PreAuthenticatedCredentialsNotFoundException: LoginBean header not found in request.
그래서 헤더가 잘못 설정되어 의미? 아니면 전혀 설정하지 않습니까? 무엇이 잘못 되었을까요?
필터 설정 LoginBean은 먼저 실행 된 다음 Spring SEcurity로 이동합니다. 당신은 response
에서 뭔가를 설정하고 봄의 클래스가 request
에서 같은를 찾고 있습니다
17:12:15,669 INFO [stdout] (http--127.0.0.1-8080-2) FILTER-----------
17:12:15,669 INFO [stdout] (http--127.0.0.1-8080-2) LOGIN DOMAIN
대단히 감사합니다. :) – kamil