title: How to migrate deprecated WebSecurityConfigurerAdapter to SecurityFilterChain?
body: <p>As they describe us <a href="https://github.com/spring-projects/spring-security/issues/10822" rel="nofollow noreferrer">here</a>, the <code>WebSecurityConfigurerAdapter</code> will deprecated in a while.</p>
  <p>I try to refactor the implementation of <code>WebSecurityConfigurerAdapter</code> with <code>SecurityFilterChain</code> due to I want to implement an JWT pattern.
  The main consideration which I faced is that the configure in returns void.</p>
  <pre class="lang-java prettyprint-override"><code>@Override
  protected void configure(AuthenticationManagerBuilder auth) throws Exception {
      auth.userDetailsService(userDetailsService).passwordEncoder(bCryptPasswordEncoder);
  }
  
  @Override
  protected void configure(HttpSecurity http) throws Exception {
      CustomAuthenticationFilter customAuthenticationFilter = new CustomAuthenticationFilter(authenticationManagerBean(), accessTokenExpiredInDays, refreshTokenExpiredInDays, jwtSecret);
      customAuthenticationFilter.setFilterProcessesUrl(&quot;/api/login&quot;);
      http
          .csrf().disable();
      http
          .sessionManagement()
              .sessionCreationPolicy(SessionCreationPolicy.STATELESS);
      http
          .authorizeRequests()
              .antMatchers(&quot;/error&quot;).permitAll();
      http
          .authorizeRequests()
              .antMatchers(&quot;/api/login/**&quot;, &quot;/api/token/refresh/**&quot;).permitAll();
      http
          .authorizeRequests()
              .anyRequest().authenticated();
      http
          .addFilter(customAuthenticationFilter);
      http
          .addFilterBefore(new CustomAuthorizationFilter(jwtSecret), UsernamePasswordAuthenticationFilter.class);
  }
  
  @Bean
  @Override
  public AuthenticationManager authenticationManagerBean() throws Exception{
      return super.authenticationManagerBean();
  }
  </code></pre>