| | |
| | | |
| | | /** |
| | | * 配置Spring Security |
| | | * |
| | | * @author lin |
| | | */ |
| | | @Configuration |
| | |
| | | matchers.add("/"); |
| | | matchers.add("/#/**"); |
| | | matchers.add("/static/**"); |
| | | matchers.add("/swagger-ui.html"); |
| | | matchers.add("/swagger-ui/"); |
| | | matchers.add("/index.html"); |
| | | matchers.add("/doc.html"); |
| | | matchers.add("/webjars/**"); |
| | |
| | | matchers.add("/js/**"); |
| | | matchers.add("/api/device/query/snap/**"); |
| | | matchers.add("/record_proxy/*/**"); |
| | | matchers.add("/api/emit"); |
| | | matchers.add("/favicon.ico"); |
| | | // 可以直接访问的静态数据 |
| | | web.ignoring().antMatchers(matchers.toArray(new String[0])); |
| | | } |
| | |
| | | |
| | | /** |
| | | * 配置认证方式 |
| | | * |
| | | * @param auth |
| | | * @throws Exception |
| | | */ |
| | |
| | | .authorizeRequests() |
| | | .requestMatchers(CorsUtils::isPreFlightRequest).permitAll() |
| | | .antMatchers(userSetting.getInterfaceAuthenticationExcludes().toArray(new String[0])).permitAll() |
| | | .antMatchers("/api/user/login","/index/hook/**","/zlm_Proxy/FhTuMYqB2HeCuNOb/record/t/1/2023-03-25/16:35:07-16:35:16-9353.mp4").permitAll() |
| | | .antMatchers("/api/user/login", "/index/hook/**", "/swagger-ui/**", "/doc.html").permitAll() |
| | | .anyRequest().authenticated() |
| | | // 异常处理器 |
| | | .and() |
| | |
| | | |
| | | } |
| | | |
| | | CorsConfigurationSource configurationSource(){ |
| | | CorsConfigurationSource configurationSource() { |
| | | // 配置跨域 |
| | | CorsConfiguration corsConfiguration = new CorsConfiguration(); |
| | | corsConfiguration.setAllowedHeaders(Arrays.asList("*")); |
| | |
| | | corsConfiguration.setExposedHeaders(Arrays.asList(JwtUtils.getHeader())); |
| | | |
| | | UrlBasedCorsConfigurationSource url = new UrlBasedCorsConfigurationSource(); |
| | | url.registerCorsConfiguration("/**",corsConfiguration); |
| | | url.registerCorsConfiguration("/**", corsConfiguration); |
| | | return url; |
| | | } |
| | | |