-
Notifications
You must be signed in to change notification settings - Fork 64
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: refactor SSL configuration (#2832)
* refactor TLS configuration Signed-off-by: achmelo <[email protected]> * builder default bug workaround Signed-off-by: achmelo <[email protected]> * default TLS protocol Signed-off-by: achmelo <[email protected]> --------- Signed-off-by: achmelo <[email protected]>
- Loading branch information
Showing
18 changed files
with
222 additions
and
205 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
72 changes: 72 additions & 0 deletions
72
...ateway-service/src/main/java/org/zowe/apiml/cloudgatewayservice/config/RoutingConfig.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
/* | ||
* This program and the accompanying materials are made available under the terms of the | ||
* Eclipse Public License v2.0 which accompanies this distribution, and is available at | ||
* https://www.eclipse.org/legal/epl-v20.html | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
* | ||
* Copyright Contributors to the Zowe Project. | ||
*/ | ||
|
||
package org.zowe.apiml.cloudgatewayservice.config; | ||
|
||
import org.springframework.beans.factory.annotation.Value; | ||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; | ||
import org.springframework.cloud.client.discovery.ReactiveDiscoveryClient; | ||
import org.springframework.cloud.gateway.discovery.DiscoveryLocatorProperties; | ||
import org.springframework.cloud.gateway.filter.FilterDefinition; | ||
import org.springframework.context.ApplicationContext; | ||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.context.annotation.Configuration; | ||
import org.zowe.apiml.cloudgatewayservice.service.ProxyRouteLocator; | ||
import org.zowe.apiml.cloudgatewayservice.service.RouteLocator; | ||
import org.zowe.apiml.util.CorsUtils; | ||
|
||
import java.util.ArrayList; | ||
import java.util.HashMap; | ||
import java.util.List; | ||
import java.util.Map; | ||
|
||
@Configuration | ||
public class RoutingConfig { | ||
|
||
@Value("${apiml.service.ignoredHeadersWhenCorsEnabled:-}") | ||
private String ignoredHeadersWhenCorsEnabled; | ||
|
||
@Bean | ||
@ConditionalOnProperty(name = "apiml.service.gateway.proxy.enabled", havingValue = "false") | ||
public RouteLocator apimlDiscoveryRouteDefLocator( | ||
ReactiveDiscoveryClient discoveryClient, DiscoveryLocatorProperties properties, List<FilterDefinition> filters, ApplicationContext context, CorsUtils corsUtils) { | ||
return new RouteLocator(discoveryClient, properties, filters, context, corsUtils); | ||
} | ||
|
||
@Bean | ||
@ConditionalOnProperty(name = "apiml.service.gateway.proxy.enabled", havingValue = "true") | ||
public RouteLocator proxyRouteDefLocator( | ||
ReactiveDiscoveryClient discoveryClient, DiscoveryLocatorProperties properties, List<FilterDefinition> filters, ApplicationContext context, CorsUtils corsUtils) { | ||
return new ProxyRouteLocator(discoveryClient, properties, filters, context, corsUtils); | ||
} | ||
|
||
@Bean | ||
public List<FilterDefinition> filters() { | ||
FilterDefinition circuitBreakerFilter = new FilterDefinition(); | ||
circuitBreakerFilter.setName("CircuitBreaker"); | ||
FilterDefinition retryFilter = new FilterDefinition(); | ||
retryFilter.setName("Retry"); | ||
|
||
retryFilter.addArg("retries", "5"); | ||
retryFilter.addArg("statuses", "SERVICE_UNAVAILABLE"); | ||
List<FilterDefinition> filters = new ArrayList<>(); | ||
filters.add(circuitBreakerFilter); | ||
filters.add(retryFilter); | ||
for (String headerName : ignoredHeadersWhenCorsEnabled.split(",")) { | ||
FilterDefinition removeHeaders = new FilterDefinition(); | ||
removeHeaders.setName("RemoveRequestHeader"); | ||
Map<String, String> args = new HashMap<>(); | ||
args.put("name", headerName); | ||
removeHeaders.setArgs(args); | ||
filters.add(removeHeaders); | ||
} | ||
return filters; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.