mirror of https://gitee.com/maxjhandsome/pig
end: 注释服务端跨域配置,由前端代理处理跨域。
This commit is contained in:
parent
3c7d16b0ff
commit
607ada9079
|
@ -5,12 +5,7 @@ import org.springframework.boot.autoconfigure.SpringBootApplication;
|
|||
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
|
||||
import org.springframework.cloud.netflix.feign.EnableFeignClients;
|
||||
import org.springframework.cloud.netflix.zuul.EnableZuulProxy;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.core.annotation.Order;
|
||||
import org.springframework.security.config.annotation.method.configuration.EnableGlobalMethodSecurity;
|
||||
import org.springframework.web.cors.CorsConfiguration;
|
||||
import org.springframework.web.cors.UrlBasedCorsConfigurationSource;
|
||||
import org.springframework.web.filter.CorsFilter;
|
||||
|
||||
/**
|
||||
* @author lengleng
|
||||
|
@ -26,16 +21,17 @@ public class PigGatewayApplication {
|
|||
SpringApplication.run(PigGatewayApplication.class, args);
|
||||
}
|
||||
|
||||
@Bean
|
||||
@Order(Integer.MAX_VALUE)
|
||||
public CorsFilter corsFilter() {
|
||||
final UrlBasedCorsConfigurationSource urlBasedCorsConfigurationSource = new UrlBasedCorsConfigurationSource();
|
||||
final CorsConfiguration corsConfiguration = new CorsConfiguration();
|
||||
corsConfiguration.setAllowCredentials(true);
|
||||
corsConfiguration.addAllowedOrigin("*");
|
||||
corsConfiguration.addAllowedHeader("*");
|
||||
corsConfiguration.addAllowedMethod("*");
|
||||
urlBasedCorsConfigurationSource.registerCorsConfiguration("/**", corsConfiguration);
|
||||
return new CorsFilter(urlBasedCorsConfigurationSource);
|
||||
}
|
||||
// 开发时候配置跨域,现在使用vue-cli 自己的代理解决,生成部署,是用Nginx 代理
|
||||
// @Bean
|
||||
// @Order(Integer.MAX_VALUE)
|
||||
// public CorsFilter corsFilter() {
|
||||
// final UrlBasedCorsConfigurationSource urlBasedCorsConfigurationSource = new UrlBasedCorsConfigurationSource();
|
||||
// final CorsConfiguration corsConfiguration = new CorsConfiguration();
|
||||
// corsConfiguration.setAllowCredentials(true);
|
||||
// corsConfiguration.addAllowedOrigin("*");
|
||||
// corsConfiguration.addAllowedHeader("*");
|
||||
// corsConfiguration.addAllowedMethod("*");
|
||||
// urlBasedCorsConfigurationSource.registerCorsConfiguration("/**", corsConfiguration);
|
||||
// return new CorsFilter(urlBasedCorsConfigurationSource);
|
||||
// }
|
||||
}
|
||||
|
|
|
@ -27,10 +27,10 @@ public class PermissionServiceImpl implements PermissionService {
|
|||
|
||||
@Override
|
||||
public boolean hasPermission(HttpServletRequest request, Authentication authentication) {
|
||||
//ele-admin options 跨域配置
|
||||
if (HttpMethod.OPTIONS.name().equalsIgnoreCase(request.getMethod())) {
|
||||
return true;
|
||||
}
|
||||
//ele-admin options 跨域配置,现在处理是通过前端配置代理,不使用这种方式,存在风险
|
||||
// if (HttpMethod.OPTIONS.name().equalsIgnoreCase(request.getMethod())) {
|
||||
// return true;
|
||||
// }
|
||||
Object principal = authentication.getPrincipal();
|
||||
List<SimpleGrantedAuthority> grantedAuthorityList = (List<SimpleGrantedAuthority>) authentication.getAuthorities();
|
||||
boolean hasPermission = false;
|
||||
|
|
Loading…
Reference in New Issue