4646import org .springframework .security .web .authentication .session .SessionFixationProtectionStrategy ;
4747import org .springframework .security .web .context .HttpSessionSecurityContextRepository ;
4848import org .springframework .security .web .context .SecurityContextRepository ;
49+ import org .springframework .security .web .servlet .util .matcher .PathPatternRequestMatcher ;
4950
5051import java .io .IOException ;
5152
@@ -58,7 +59,7 @@ public WebEidAjaxLoginProcessingFilter(
5859 String defaultFilterProcessesUrl ,
5960 AuthenticationManager authenticationManager
6061 ) {
61- super (defaultFilterProcessesUrl );
62+ super (PathPatternRequestMatcher . withDefaults (). matcher ( HttpMethod . POST , defaultFilterProcessesUrl ) );
6263 this .setAuthenticationManager (authenticationManager );
6364 this .setAuthenticationSuccessHandler (new AjaxAuthenticationSuccessHandler ());
6465 this .setAuthenticationFailureHandler (new AjaxAuthenticationFailureHandler ());
@@ -69,10 +70,6 @@ public WebEidAjaxLoginProcessingFilter(
6970 @ Override
7071 public Authentication attemptAuthentication (HttpServletRequest request , HttpServletResponse response )
7172 throws AuthenticationException , IOException {
72- if (!HttpMethod .POST .name ().equals (request .getMethod ())) {
73- LOG .warn ("HttpMethod not supported: {}" , request .getMethod ());
74- throw new AuthenticationServiceException ("HttpMethod not supported: " + request .getMethod ());
75- }
7673 final String contentType = request .getHeader ("Content-type" );
7774 if (contentType == null || !contentType .startsWith ("application/json" )) {
7875 LOG .warn ("Content type not supported: {}" , contentType );
@@ -92,18 +89,4 @@ protected void successfulAuthentication(HttpServletRequest request, HttpServletR
9289 super .successfulAuthentication (request , response , chain , authResult );
9390 securityContextRepository .saveContext (SecurityContextHolder .getContext (), request , response );
9491 }
95-
96- @ Override
97- public void doFilter (ServletRequest req , ServletResponse res , FilterChain chain )
98- throws IOException , ServletException {
99-
100- HttpServletRequest request = (HttpServletRequest ) req ;
101-
102- if (!HttpMethod .POST .matches (request .getMethod ())) {
103- chain .doFilter (req , res );
104- return ;
105- }
106-
107- super .doFilter (req , res , chain );
108- }
10992}
0 commit comments