Spring Security 6 using form login authentication with json payload request

89 Views Asked by At

How is one supposed to specify a custom a ServerFormLoginAuthenticationConverter in ServerHttpSecurity.FormLoginSpec when it is hard coded and there is no easy access to the authentication filter.

      MediaTypeServerWebExchangeMatcher htmlMatcher = new MediaTypeServerWebExchangeMatcher(new MediaType[]{MediaType.TEXT_HTML});
      htmlMatcher.setIgnoredMediaTypes(Collections.singleton(MediaType.ALL));
      ServerHttpSecurity.this.defaultEntryPoints.add(0, new DelegatingServerAuthenticationEntryPoint.DelegateEntry(htmlMatcher, this.authenticationEntryPoint));
      AuthenticationWebFilter authenticationFilter = new AuthenticationWebFilter(this.authenticationManager);
      authenticationFilter.setRequiresAuthenticationMatcher(this.requiresAuthenticationMatcher);
      authenticationFilter.setAuthenticationFailureHandler(this.authenticationFailureHandler);
      authenticationFilter.setAuthenticationConverter(new ServerFormLoginAuthenticationConverter());
      authenticationFilter.setAuthenticationSuccessHandler(this.authenticationSuccessHandler);
      authenticationFilter.setSecurityContextRepository(this.securityContextRepository);
      http.addFilterAt(authenticationFilter, SecurityWebFiltersOrder.FORM_LOGIN);
0

There are 0 best solutions below