|
|
@@ -54,13 +54,24 @@ public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
|
|
|
@Override
|
|
|
protected void configure(HttpSecurity http) throws Exception {
|
|
|
//访问控制
|
|
|
- http.authorizeRequests()
|
|
|
+ http
|
|
|
+ //访问swagger
|
|
|
+ .anonymous()
|
|
|
+ .authorities("ROLE_ANONYMOUS").and()
|
|
|
+ .authorizeRequests()
|
|
|
+ .antMatchers("/**/*swagger*/**").permitAll()
|
|
|
+ .antMatchers("/**/*api-docs*/**").permitAll()
|
|
|
+ .and()
|
|
|
+ .authorizeRequests()
|
|
|
//跨域的Options请求进行放行
|
|
|
.requestMatchers(CorsUtils::isPreFlightRequest).permitAll()
|
|
|
- //其他所有接口都要在登陆认证状态下请求
|
|
|
- .anyRequest().authenticated()
|
|
|
//todo 具体角色权限配置等开发完成之后再配, 这里先配为默认所有权限
|
|
|
- .antMatchers("/**").hasAnyRole(WebSecurityConstants.STUDENT_ROLE, WebSecurityConstants.ADMIN_ROLE);
|
|
|
+ .antMatchers("/**").hasAnyRole(WebSecurityConstants.STUDENT_ROLE, WebSecurityConstants.ADMIN_ROLE)
|
|
|
+ //其他所有接口都要在登陆认证状态下请求
|
|
|
+ .anyRequest().authenticated();
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
|
|
|
//开启跨域
|
|
|
http.cors();
|