Commit f6a6f8b5 authored by Marc Burnie [AWS]'s avatar Marc Burnie [AWS]
Browse files

Merge branch 'master' into master-dev-merge

parents d6a73e3e fa71adde
Pipeline #88331 failed with stages
in 25 minutes and 8 seconds
......@@ -3,7 +3,6 @@ variables:
OSDU_GCP_SERVICE: crs-catalog
OSDU_GCP_VENDOR: gcp
OSDU_GCP_APPLICATION_NAME: os-crs-catalog
OSDU_GCP_ENV_VARS: PROJECT_ID=$OSDU_GCP_PROJECT,ENTITLEMENT_URL=$OSDU_GCP_ENTITLEMENTS_V2_URL,CRS_CATALOG_HOSTNAME=$OSDU_GCP_CRS_CATALOG_HOSTNAME,AUDIENCES=$GOOGLE_AUDIENCE
OSDU_GCP_INT_TEST_TYPE: python
OSDU_GCP_PYTHON_INT_TEST_SUBDIR: testing/catalog_test_gcp
OSDU_GCP_HELM_PACKAGE_CHARTS: "devops/gcp/deploy devops/gcp/configmap"
......@@ -13,7 +12,8 @@ variables:
OSDU_GCP_HELM_CONFIG_SERVICE: crs-catalog-config
OSDU_GCP_HELM_DEPLOYMENT_SERVICE: crs-catalog-deploy
OSDU_GCP_HELM_CONFIG_SERVICE_VARS: "--set data.project_id=$OSDU_GCP_PROJECT --set data.audiences=$GOOGLE_AUDIENCE --set data.google_audiences=$GOOGLE_AUDIENCE"
OSDU_GCP_HELM_DEPLOYMENT_SERVICE_VARS: "--set data.image=$CI_REGISTRY_IMAGE/osdu-gcp:$CI_COMMIT_SHORT_SHA --set data.serviceAccountName=workload-identity-crs-catalog"
OSDU_GCP_HELM_CONFIG_SERVICE_VARS_DEV2: "--set data.project_id=$OSDU_GCP_PROJECT --set data.audiences=$GOOGLE_AUDIENCE --set data.google_audiences=$GOOGLE_AUDIENCE"
OSDU_GCP_HELM_DEPLOYMENT_SERVICE_VARS: "--set data.image=$CI_REGISTRY_IMAGE/osdu-gcp:$CI_COMMIT_SHORT_SHA --set data.serviceAccountName=$OSDU_GCP_SERVICE-k8s"
# --- end of osdu-gcp specific variables ---
AWS_BUILD_SUBDIR: provider/crs-catalog-aws/build-aws
......@@ -66,5 +66,7 @@ include:
osdu-gcp-test-python:
variables:
VIRTUAL_SERVICE_HOST_NAME: $OSDU_GCP_CRS_CATALOG_HOSTNAME
when: delayed
start_in: 3 minutes
osdu-gcp-dev2-test-python:
variables:
VIRTUAL_SERVICE_HOST_NAME: $OSDU_GCP_CRS_CATALOG_HOSTNAME
This diff is collapsed.
......@@ -28,7 +28,6 @@
<maven.compiler.showDeprecation>true</maven.compiler.showDeprecation>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<springfox-swagger2.version>2.7.0</springfox-swagger2.version>
</properties>
<prerequisites>
......@@ -69,25 +68,6 @@
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-jetty</artifactId>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger2</artifactId>
<version>${springfox-swagger2.version}</version>
<exclusions>
<exclusion>
<!--
Excluding com.google.guava:guava:jar:18.0, because it has security vulnerability
-->
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger-ui</artifactId>
<version>${springfox-swagger2.version}</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
......
......@@ -4,56 +4,54 @@ import org.opengroup.osdu.core.common.model.http.DpsHeaders;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import java.util.ArrayList;
import java.util.List;
import springfox.documentation.builders.ParameterBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.schema.ModelRef;
import springfox.documentation.builders.RequestParameterBuilder;
import springfox.documentation.oas.annotations.EnableOpenApi;
import springfox.documentation.service.ApiKey;
import springfox.documentation.service.AuthorizationScope;
import springfox.documentation.service.Parameter;
import springfox.documentation.service.ParameterType;
import springfox.documentation.service.RequestParameter;
import springfox.documentation.service.SecurityReference;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spi.service.contexts.SecurityContext;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;
import static java.util.Collections.singletonList;
import static org.apache.commons.lang3.StringUtils.startsWithIgnoreCase;
import static org.springframework.http.HttpHeaders.AUTHORIZATION;
@Configuration
@EnableSwagger2
@EnableOpenApi
public class SwaggerConfiguration {
private static final String BEARER_AUTH_KEY_NAME = "Bearer Authorization";
public static final String PASS_AS_HEADER = "header";
public static final String DEFAULT_INCLUDE_PATTERN = "/.*";
@Bean
public Docket api(List<Parameter> globalParameters) {
return new Docket(DocumentationType.SWAGGER_2)
public Docket api() {
RequestParameterBuilder builder = new RequestParameterBuilder();
List<RequestParameter> parameters = new ArrayList<>();
builder.name(DpsHeaders.DATA_PARTITION_ID)
.description("tenant")
.in(ParameterType.HEADER)
.required(true)
.build();
parameters.add(builder.build());
return new Docket(DocumentationType.OAS_30)
.globalRequestParameters(parameters)
.select()
.apis(RequestHandlerSelectors.basePackage("org.opengroup.osdu.crs.api"))
.paths(s -> !startsWithIgnoreCase(s, "/error"))
.build()
.globalOperationParameters(globalParameters)
.securitySchemes(singletonList(bearerAuth()))
.securityContexts(singletonList(securityContext()));
}
@Bean
public Parameter dataPatitionParameter() {
ParameterBuilder builder = new ParameterBuilder();
builder.name(DpsHeaders.DATA_PARTITION_ID)
.description("tenant")
.defaultValue("opendes")
.modelRef(new ModelRef("string"))
.parameterType(PASS_AS_HEADER)
.required(true)
.build();
return builder.build();
}
private ApiKey bearerAuth() {
return new ApiKey(BEARER_AUTH_KEY_NAME, AUTHORIZATION, PASS_AS_HEADER);
......@@ -62,7 +60,7 @@ public class SwaggerConfiguration {
private SecurityContext securityContext() {
return SecurityContext.builder()
.securityReferences(defaultAuth())
.forPaths(PathSelectors.any())
.operationSelector(o -> PathSelectors.regex(DEFAULT_INCLUDE_PATTERN).test(o.requestMappingPattern()))
.build();
}
......
......@@ -7,6 +7,6 @@ import org.springframework.web.bind.annotation.RequestMapping;
public class HomeController {
@RequestMapping(value = {"/", "/swagger"})
public String swagger() {
return "redirect:swagger-ui.html";
return "redirect:swagger-ui/index.html";
}
}
\ No newline at end of file
package org.opengroup.osdu.crs.swagger;
import io.swagger.v3.oas.models.OpenAPI;
import io.swagger.v3.oas.models.servers.Server;
import org.springframework.core.Ordered;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;
import springfox.documentation.oas.web.OpenApiTransformationContext;
import springfox.documentation.oas.web.WebMvcOpenApiTransformationFilter;
import springfox.documentation.spi.DocumentationType;
import javax.servlet.http.HttpServletRequest;
@Component
@Order(Ordered.LOWEST_PRECEDENCE)
public class SpringfoxSwaggerHostResolver implements WebMvcOpenApiTransformationFilter {
@Override
public boolean supports(DocumentationType delimiter) {
return delimiter == DocumentationType.OAS_30;
}
@Override
public OpenAPI transform(OpenApiTransformationContext<HttpServletRequest> context) {
OpenAPI swagger = context.getSpecification();
Server server = swagger.getServers().get(0);
if (server.getUrl().contains(":443")) {
// via the gateway
server.setUrl(server.getUrl().replace(":443",""));
}
return swagger;
}
}
......@@ -20,6 +20,7 @@ spec:
containers:
- name: "{{ .Values.conf.app_name }}"
image: "{{ .Values.data.image }}"
imagePullPolicy: "{{ .Values.data.imagePullPolicy }}"
envFrom:
- configMapRef:
name: "{{ .Values.conf.configmap }}"
......
......@@ -4,6 +4,7 @@ data:
limits_cpu: "1"
limits_memory: "1G"
serviceAccountName: ""
imagePullPolicy: "IfNotPresent"
image: ""
conf:
......
......@@ -12,6 +12,7 @@
<os-core-common.version>0.13.0-rc4</os-core-common.version>
<snakeyaml.version>1.26</snakeyaml.version>
<nimbus-jose-jwt.version>7.9</nimbus-jose-jwt.version>
<springfox.version>3.0.0</springfox.version>
</properties>
<licenses>
......@@ -95,6 +96,15 @@
</dependency>
</dependencies>
</dependencyManagement>
<!--Swagger-->
<dependencies>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-boot-starter</artifactId>
<version>${springfox.version}</version>
</dependency>
</dependencies>
<build>
<pluginManagement>
......
......@@ -53,10 +53,12 @@ public class AuthSecurityConfig extends WebSecurityConfigurerAdapter implements
"/actuator/**",
"/_ah/*",
"/v2/api-docs",
"/v3/api-docs",
"/configuration/ui",
"/swagger-resources/**",
"/configuration/security",
"/swagger-ui.html",
"/swagger-ui/**",
"/info",
"/webjars/**",
"/csrf",
......
......@@ -38,11 +38,13 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter implements Acc
"/index.html",
"/_ah/*",
"/v2/api-docs",
"/v3/api-docs",
"/configuration/ui",
"/swagger-resources/**",
"/configuration/security",
"/swagger",
"/swagger-ui.html",
"/swagger-ui/**",
"/info",
"/webjars/**",
"/csrf"
......
......@@ -53,10 +53,12 @@ public class AuthSecurityConfig extends WebSecurityConfigurerAdapter implements
"/actuator/**",
"/_ah/*",
"/v2/api-docs",
"/v3/api-docs",
"/configuration/ui",
"/swagger-resources/**",
"/configuration/security",
"/swagger-ui.html",
"/swagger-ui/**",
"/info",
"/webjars/**",
"/csrf",
......
......@@ -20,7 +20,7 @@
<app.id>crs-catalog-ocp</app.id>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<objectify.version>5.1.22</objectify.version>
<os-core-lib-ibm.version>0.13.0-rc5</os-core-lib-ibm.version>
<os-core-lib-ibm.version>0.13.0-rc6</os-core-lib-ibm.version>
<slf4j.version>1.7.25</slf4j.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.showDeprecation>true</maven.compiler.showDeprecation>
......
......@@ -41,10 +41,12 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter implements Acce
"/actuator/**",
"/_ah/*",
"/v2/api-docs",
"/v3/api-docs",
"/configuration/ui",
"/swagger-resources/**",
"/configuration/security",
"/swagger-ui.html",
"/swagger-ui/**",
"/info",
"/webjars/**",
"/csrf",
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment