我打开了这个question already。我需要知道如何允许spring-boot允许加载.css
的{{1}}和.js
个文件?
这是我的swagger
文件
WebSecurityConfig.java
答案 0 :(得分:0)
只允许对.css
和.js
路径的所有访问权限(正如您已使用/register
和其他途径执行此操作)
@Override
protected void configure(HttpSecurity httpSecurity) throws Exception {
httpSecurity
.csrf().disable()
.exceptionHandling().authenticationEntryPoint(unauthorizedHandler).and()
.sessionManagement().sessionCreationPolicy(SessionCreationPolicy.STATELESS).and()
.authorizeRequests()
.antMatchers("/auth/**").permitAll()
.antMatchers("/register/**").permitAll()
.antMatchers("/swagger-ui*").permitAll()
.antMatchers("/v2/**").permitAll()
.antMatchers("/webjars/**").permitAll() //swagger ui files
.antMatchers("/sysadmin/**").hasRole("SYSADMIN")
.antMatchers("/admin/**").hasRole("ADMIN")
.antMatchers("/siteadmin/**").hasRole("SITEADMIN")
.anyRequest().authenticated();
// Custom JWT based security filter
httpSecurity
.addFilterBefore(authenticationTokenFilterBean(), UsernamePasswordAuthenticationFilter.class);
}