Merge branch 'master' into eureka

eureka
tanghc 5 years ago
commit 5ef8fec07f
  1. 4
      changelog.md
  2. 2
      sop-auth/pom.xml
  3. 2
      sop-common/pom.xml
  4. 6
      sop-common/sop-bridge-gateway/pom.xml
  5. 6
      sop-common/sop-bridge-zuul/pom.xml
  6. 4
      sop-common/sop-gateway-common/pom.xml
  7. 49
      sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/manager/AbstractConfiguration.java
  8. 4
      sop-common/sop-service-common/pom.xml
  9. 2
      sop-example/sop-book/sop-book-web/pom.xml
  10. 2
      sop-example/sop-easyopen/pom.xml
  11. 2
      sop-example/sop-springmvc/pom.xml
  12. 2
      sop-example/sop-story/sop-story-web/pom.xml
  13. 2
      sop-gateway/pom.xml
  14. 2
      sop-website/pom.xml

@ -1,5 +1,9 @@
# changelog
## 3.1.4
- 优化跨域
## 3.1.3
- 修复监控日志乱码问题

@ -26,7 +26,7 @@
<dependency>
<groupId>com.gitee.sop</groupId>
<artifactId>sop-service-common</artifactId>
<version>3.1.3-SNAPSHOT</version>
<version>3.1.4-SNAPSHOT</version>
</dependency>
<!-- sop相关配置 end-->

@ -5,7 +5,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>com.gitee.sop</groupId>
<artifactId>sop-common</artifactId>
<version>3.1.3-SNAPSHOT</version>
<version>3.1.4-SNAPSHOT</version>
<packaging>pom</packaging>
<properties>

@ -5,11 +5,11 @@
<parent>
<artifactId>sop-common</artifactId>
<groupId>com.gitee.sop</groupId>
<version>3.1.3-SNAPSHOT</version>
<version>3.1.4-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
<version>3.1.3-SNAPSHOT</version>
<version>3.1.4-SNAPSHOT</version>
<artifactId>sop-bridge-gateway</artifactId>
@ -17,7 +17,7 @@
<dependency>
<groupId>com.gitee.sop</groupId>
<artifactId>sop-gateway-common</artifactId>
<version>3.1.3-SNAPSHOT</version>
<version>3.1.4-SNAPSHOT</version>
</dependency>
<dependency>

@ -5,11 +5,11 @@
<parent>
<artifactId>sop-common</artifactId>
<groupId>com.gitee.sop</groupId>
<version>3.1.3-SNAPSHOT</version>
<version>3.1.4-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
<version>3.1.3-SNAPSHOT</version>
<version>3.1.4-SNAPSHOT</version>
<artifactId>sop-bridge-zuul</artifactId>
@ -17,7 +17,7 @@
<dependency>
<groupId>com.gitee.sop</groupId>
<artifactId>sop-gateway-common</artifactId>
<version>3.1.3-SNAPSHOT</version>
<version>3.1.4-SNAPSHOT</version>
</dependency>
<dependency>

@ -5,11 +5,11 @@
<parent>
<groupId>com.gitee.sop</groupId>
<artifactId>sop-common</artifactId>
<version>3.1.3-SNAPSHOT</version>
<version>3.1.4-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<artifactId>sop-gateway-common</artifactId>
<version>3.1.3-SNAPSHOT</version>
<version>3.1.4-SNAPSHOT</version>
<packaging>jar</packaging>
<name>sop-gateway-common</name>

@ -3,10 +3,10 @@ package com.gitee.sop.gatewaycommon.manager;
import com.gitee.sop.gatewaycommon.bean.ApiConfig;
import com.gitee.sop.gatewaycommon.bean.ApiContext;
import com.gitee.sop.gatewaycommon.bean.BeanInitializer;
import com.gitee.sop.gatewaycommon.interceptor.RouteInterceptor;
import com.gitee.sop.gatewaycommon.bean.SpringContext;
import com.gitee.sop.gatewaycommon.gateway.loadbalancer.NacosServerIntrospector;
import com.gitee.sop.gatewaycommon.interceptor.MonitorRouteInterceptor;
import com.gitee.sop.gatewaycommon.interceptor.RouteInterceptor;
import com.gitee.sop.gatewaycommon.limit.LimitManager;
import com.gitee.sop.gatewaycommon.loadbalancer.SopPropertiesFactory;
import com.gitee.sop.gatewaycommon.message.ErrorFactory;
@ -40,6 +40,7 @@ import org.springframework.context.event.EventListener;
import org.springframework.core.env.Environment;
import org.springframework.web.cors.CorsConfiguration;
import org.springframework.web.cors.UrlBasedCorsConfigurationSource;
import org.springframework.web.cors.reactive.CorsWebFilter;
import org.springframework.web.filter.CorsFilter;
import javax.annotation.PostConstruct;
@ -184,11 +185,35 @@ public class AbstractConfiguration implements ApplicationContextAware, Applicati
/**
* 跨域过滤器
* 跨域过滤器zuul
*/
@Bean
@ConditionalOnMissingBean
@ConditionalOnProperty("zuul.servlet-path")
public CorsFilter corsFilter() {
return createCorsFilter();
UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource();
source.registerCorsConfiguration("/**", createCorsConfiguration());
return new CorsFilter(source);
}
/**
* 跨域过滤器gateway采用react形式需要使用reactive包下的UrlBasedCorsConfigurationSource
*/
@Bean
@ConditionalOnMissingBean
@ConditionalOnProperty("sop.gateway-index-path")
public CorsWebFilter corsWebFilter() {
org.springframework.web.cors.reactive.UrlBasedCorsConfigurationSource source = new org.springframework.web.cors.reactive.UrlBasedCorsConfigurationSource();
source.registerCorsConfiguration("/**", createCorsConfiguration());
return new CorsWebFilter(source);
}
private CorsConfiguration createCorsConfiguration() {
CorsConfiguration corsConfiguration = new CorsConfiguration();
corsConfiguration.addAllowedOrigin("*");
corsConfiguration.addAllowedHeader("*");
corsConfiguration.addAllowedMethod("*");
return corsConfiguration;
}
/**
@ -211,24 +236,6 @@ public class AbstractConfiguration implements ApplicationContextAware, Applicati
return new EurekaServerIntrospector();
}
protected CorsFilter createCorsFilter() {
UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource();
this.registerCorsConfiguration(source);
return new CorsFilter(source);
}
protected void registerCorsConfiguration(UrlBasedCorsConfigurationSource source) {
source.registerCorsConfiguration("/**", corsConfiguration());
}
protected CorsConfiguration corsConfiguration() {
CorsConfiguration corsConfiguration = new CorsConfiguration();
corsConfiguration.addAllowedOrigin("*");
corsConfiguration.addAllowedHeader("*");
corsConfiguration.addAllowedMethod("*");
return corsConfiguration;
}
@Override
public void run(ApplicationArguments args) throws Exception {
this.isStartupCompleted = true;

@ -6,11 +6,11 @@
<parent>
<groupId>com.gitee.sop</groupId>
<artifactId>sop-common</artifactId>
<version>3.1.3-SNAPSHOT</version>
<version>3.1.4-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<artifactId>sop-service-common</artifactId>
<version>3.1.3-SNAPSHOT</version>
<version>3.1.4-SNAPSHOT</version>
<packaging>jar</packaging>
<name>sop-service-common</name>

@ -28,7 +28,7 @@
<dependency>
<groupId>com.gitee.sop</groupId>
<artifactId>sop-service-common</artifactId>
<version>3.1.3-SNAPSHOT</version>
<version>3.1.4-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>com.gitee.sop</groupId>

@ -29,7 +29,7 @@
<dependency>
<groupId>com.gitee.sop</groupId>
<artifactId>sop-service-common</artifactId>
<version>3.1.3-SNAPSHOT</version>
<version>3.1.4-SNAPSHOT</version>
</dependency>
<!-- 使用nacos注册中心

@ -20,7 +20,7 @@
<dependency>
<groupId>com.gitee.sop</groupId>
<artifactId>sop-service-common</artifactId>
<version>3.1.3-SNAPSHOT</version>
<version>3.1.4-SNAPSHOT</version>
</dependency>
<!-- nacos -->
<dependency>

@ -28,7 +28,7 @@
<dependency>
<groupId>com.gitee.sop</groupId>
<artifactId>sop-service-common</artifactId>
<version>3.1.3-SNAPSHOT</version>
<version>3.1.4-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>com.gitee.sop</groupId>

@ -34,7 +34,7 @@
<groupId>com.gitee.sop</groupId>
<artifactId>sop-bridge-gateway</artifactId>
<!--<artifactId>sop-bridge-zuul</artifactId>-->
<version>3.1.3-SNAPSHOT</version>
<version>3.1.4-SNAPSHOT</version>
</dependency>
<dependency>

@ -35,7 +35,7 @@
<dependency>
<groupId>com.gitee.sop</groupId>
<artifactId>sop-gateway-common</artifactId>
<version>3.1.3-SNAPSHOT</version>
<version>3.1.4-SNAPSHOT</version>
</dependency>
<dependency>

Loading…
Cancel
Save