title: Spring security configure issue
body: <p>Here is my configuration in security and the problem is all the requests such as <code>/v3/api-docs</code> will be redirected to <code>/login</code> or <code>/register</code>.I don't know why and Please help.</p>
  <pre><code>package reg.example.confgure;
  
  import org.springframework.beans.factory.annotation.Autowired;
  import org.springframework.context.annotation.Configuration;
  import org.springframework.http.HttpMethod;
  import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder;
  import org.springframework.security.config.annotation.method.configuration.EnableGlobalMethodSecurity;
  import org.springframework.security.config.annotation.web.builders.HttpSecurity;
  import org.springframework.security.config.annotation.web.builders.WebSecurity;
  import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
  import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
  
  import reg.example.model.User;
  import reg.example.service.UserRepositoryUserDetailService;
  
  @Configuration
  @EnableWebSecurity 
  public class SecurityConfiguration extends WebSecurityConfigurerAdapter { 
  
      @Autowired
      private UserRepositoryUserDetailService userDetailsService; 
  
      @Override
      public void configure(WebSecurity web) throws Exception {
          web.ignoring().antMatchers(&quot;/v3/api-docs&quot;,
                  &quot;/swagger-resources/configuration/ui&quot;,
                  &quot;/swagger-resources&quot;,
                  &quot;/swagger-resources/configuration/security&quot;,
                  &quot;/swagger-ui.html&quot;);
      }
  
      
      @Override
      protected void configure(AuthenticationManagerBuilder auth) throws Exception {
          auth
              .userDetailsService(this.userDetailsService)
                  .passwordEncoder(User.PASSWORD_ENCODER);
      }
  
      @Override
      protected void configure(HttpSecurity http) throws Exception { 
          http
              // 关闭csrf防护
              .csrf().disable()
              .headers().frameOptions().disable()
                  .and()
              .authorizeRequests()
              .antMatchers(&quot;/user/**&quot;).permitAll()
              .antMatchers(&quot;/v3/api-docs&quot;, &quot;/swagger-resources/configuration/ui&quot;,
                      &quot;/swagger-resources&quot;, &quot;/swagger-resources/configuration/security&quot;,
                      &quot;/swagger-ui.html&quot;, &quot;/webjars/**&quot;).permitAll()
              .antMatchers(&quot;/&quot;, &quot;/login&quot;,&quot;/register&quot;).permitAll()
              .anyRequest().authenticated()
                  .and()
              .formLogin()
                  .loginPage(&quot;/login&quot;)
                  .permitAll()
                  .and()
              .logout()
                  .permitAll();
      }
      
  
  
  }
  </code></pre>
  <pre><code>package reg.example.confgure;
  
  import org.springframework.context.annotation.Configuration;
  import org.springframework.web.servlet.config.annotation.ViewControllerRegistry;
  import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
  
  @Configuration
  public class MvcConfig implements WebMvcConfigurer {
  
      public void addViewControllers(ViewControllerRegistry registry) {
          registry.addViewController(&quot;/login&quot;).setViewName(&quot;login&quot;);
          registry.addViewController(&quot;/register&quot;).setViewName(&quot;register&quot;);
      }
      
  
  
  }
  </code></pre>