content: package jnpf.config;
  
  import jnpf.config.password.MyPasswordEncoder;
  import jnpf.impl.UserDetailsServiceImpl;
  import org.springframework.beans.factory.annotation.Autowired;
  import org.springframework.context.annotation.Bean;
  import org.springframework.context.annotation.Configuration;
  import org.springframework.security.authentication.AuthenticationManager;
  import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder;
  import org.springframework.security.config.annotation.web.builders.HttpSecurity;
  import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
  import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
  
  /**
   * 安全认证
   *
   * @author JNPF开发平台组
   * @version V3.1.0
   * @copyright 引迈信息技术有限公司（https://www.jnpfsoft.com）
   * @date 2021-03-23
   */
  @Configuration
  @EnableWebSecurity
  public class SecurityConfig extends WebSecurityConfigurerAdapter {
  
      @Autowired
      private UserDetailsServiceImpl userDetailsService;
      @Autowired
      private MyPasswordEncoder passwordEncoder;
  
      /**
       * 配置请求路径
       * @param http
       * @throws Exception
       */
      @Override
      protected void configure(HttpSecurity http) throws Exception {
          http.csrf().disable().authorizeRequests()
                  .antMatchers("/RSA/publicKey").permitAll();
      }
  
      /**
       * 保证成功刷新token
       * @param auth
       * @throws Exception
       */
      @Autowired
      public void globalUserDetails(AuthenticationManagerBuilder auth) throws Exception {
          // 用户来源于数据库
          auth.userDetailsService(userDetailsService).passwordEncoder(passwordEncoder);
      }
  
      @Bean
      @Override
      public AuthenticationManager authenticationManager() throws Exception {
          return super.authenticationManager();
      }
  
  }
  