Commit 4abfc51a authored by Sanjeev-SLB's avatar Sanjeev-SLB
Browse files

Merge remote-tracking branch 'origin/master' into fix-vulnerabilities

parents 91ec0a03 1044fc71
Pipeline #27829 passed with stages
in 89 minutes and 50 seconds
.classpath
.factorypath
.project
.settings/
target/
......
......@@ -86,6 +86,9 @@ The following software have components provided under the terms of this license:
- Joda-Time (from http://www.joda.org/joda-time/)
- Joda-Time (from http://www.joda.org/joda-time/)
- Json Path (from https://github.com/jayway/JsonPath)
- Logback Contrib :: JSON :: Classic (from )
- Logback Contrib :: JSON :: Core (from )
- Logback Contrib :: Jackson (from )
- Lucene Common Analyzers (from )
- Lucene Core (from )
- Lucene Grouping (from )
......@@ -109,7 +112,10 @@ The following software have components provided under the terms of this license:
- Netty/Handler (from )
- Netty/Resolver (from )
- Netty/Transport (from http://netty.io/)
- Nimbus Content Type (from https://bitbucket.org/connect2id/nimbus-content-type)
- Nimbus JOSE+JWT (from https://bitbucket.org/connect2id/nimbus-jose-jwt)
- Nimbus LangTag (from https://bitbucket.org/connect2id/nimbus-language-tags)
- OAuth 2.0 SDK with OpenID Connect extensions (from https://bitbucket.org/connect2id/oauth-2.0-sdk-with-openid-connect-extensions)
- Objenesis (from http://objenesis.org)
- OpenCensus (from https://github.com/census-instrumentation/opencensus-java)
- OpenCensus (from https://github.com/census-instrumentation/opencensus-java)
......@@ -345,6 +351,9 @@ The following software have components provided under the terms of this license:
- Eclipse Xtend Active Annotations Library (from https://www.eclipse.org/Xtext/)
- Eclipse Xtend Runtime Library (from https://www.eclipse.org/Xtext/)
- Logback Classic Module (from )
- Logback Contrib :: JSON :: Classic (from )
- Logback Contrib :: JSON :: Core (from )
- Logback Contrib :: Jackson (from )
- Logback Core Module (from )
- SnakeYAML (from http://www.snakeyaml.org)
- jakarta.annotation-api (from https://projects.eclipse.org/projects/ee4j.ca)
......@@ -464,6 +473,9 @@ The following software have components provided under the terms of this license:
- Elastic JNA Distribution (from https://github.com/java-native-access/jna)
- Javassist (from http://www.javassist.org/)
- Logback Classic Module (from )
- Logback Contrib :: JSON :: Classic (from )
- Logback Contrib :: JSON :: Core (from )
- Logback Contrib :: Jackson (from )
- Logback Core Module (from )
========================================================================
......
......@@ -30,7 +30,7 @@
<maven.compiler.source>1.8</maven.compiler.source>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<springfox-version>2.7.0</springfox-version>
<osdu.oscorecommon.version>0.3.23</osdu.oscorecommon.version>
<osdu.oscorecommon.version>0.3.28</osdu.oscorecommon.version>
</properties>
<licenses>
......
......@@ -18,7 +18,14 @@ FROM amazoncorretto:8
ARG JAR_FILE=provider/register-aws/target/*spring-boot.jar
# Harcoding this value since Register-core requires this variable. AWS does not use it. Might change in future
ENV ENVIRONMENT=DEV
#Default to using self signed generated TLS cert
ENV USE_SELF_SIGNED_SSL_CERT true
WORKDIR /
COPY ${JAR_FILE} app.jar
COPY /provider/register-aws/build-aws/ssl.sh /ssl.sh
COPY /provider/register-aws/build-aws/entrypoint.sh /entrypoint.sh
EXPOSE 8080
ENTRYPOINT java $JAVA_OPTS -jar /app.jar
ENTRYPOINT ["/bin/sh", "-c", ". /entrypoint.sh"]
......@@ -27,9 +27,11 @@ phases:
runtime-versions:
java: corretto8
commands:
# fix error noted here: https://github.com/yarnpkg/yarn/issues/7866
- curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add -
- if [ $(echo $CODEBUILD_SOURCE_VERSION | grep -c ^refs/heads.*) -eq 1 ]; then echo "Branch name found"; else echo "This build only supports branch builds" && exit 1; fi
- apt-get update -y
- apt-get install -y maven
- apt-get update -y -qq >/dev/null
- apt-get install -y maven -qq >/dev/null
- java -version
- mvn -version
- mkdir -p /root/.m2
......@@ -56,7 +58,7 @@ phases:
- printenv
- echo "Building primary service assemblies..."
- mvn -B test install -pl register-core,provider/register-aws -Ddeployment.environment=prod
- mvn -ntp -B test install -pl register-core,provider/register-aws -Ddeployment.environment=prod
- echo "Building integration testing assemblies and gathering artifacts..."
- ./testing/register-test-aws/build-aws/prepare-dist.sh
......@@ -89,4 +91,4 @@ artifacts:
name: ${REPO_NAME}_${BRANCH_NAME}_$(date +%F)_${CODEBUILD_BUILD_NUMBER}.zip
cache:
paths:
- "/root/.m2/**/*"
\ No newline at end of file
- "/root/.m2/**/*"
if [ -n $USE_SELF_SIGNED_SSL_CERT ];
then
export SSL_KEY_PASSWORD=$RANDOM$RANDOM$RANDOM;
export SSL_KEY_STORE_PASSWORD=$SSL_KEY_PASSWORD;
export SSL_KEY_STORE_DIR=/tmp/certs;
export SSL_KEY_STORE_NAME=osduonaws.p12;
export SSL_KEY_STORE_PATH=$SSL_KEY_STORE_DIR/$SSL_KEY_STORE_NAME;
export SSL_KEY_ALIAS=osduonaws;
./ssl.sh;
fi
java $JAVA_OPTS -jar /app.jar
\ No newline at end of file
# Copyright © 2021 Amazon Web Services
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#!/usr/bin/env bash
#Future: Support for using Amazon Cert Manager
# if [ "$1" == "webserver" ] && [ -n $ACM_CERTIFICATE_ARN ];
# then
# aws acm export-certificate --certificate-arn $ACM_CERTIFICATE_ARN --passphrase $(echo -n 'aws123' | openssl base64 -e) | jq -r '"\(.PrivateKey)"' > ${SSL_KEY_PATH}.enc
# openssl rsa -in ${SSL_KEY_PATH}.enc -out $SSL_KEY_PATH -passin pass:aws123
# aws acm get-certificate --certificate-arn $ACM_CERTIFICATE_ARN | jq -r '"\(.CertificateChain)"' > $SSL_CERT_PATH
# aws acm get-certificate --certificate-arn $ACM_CERTIFICATE_ARN | jq -r '"\(.Certificate)"' >> $SSL_CERT_PATH
# fi
if [ -n $USE_SELF_SIGNED_SSL_CERT ];
then
mkdir -p $SSL_KEY_STORE_DIR
pushd $SSL_KEY_STORE_DIR
keytool -genkeypair -alias $SSL_KEY_ALIAS -keyalg RSA -keysize 2048 -storetype PKCS12 -keystore $SSL_KEY_STORE_NAME -validity 3650 -keypass $SSL_KEY_PASSWORD -storepass $SSL_KEY_PASSWORD -dname "CN=localhost, OU=AWS, O=Energy, L=Houston, ST=TX, C=US"
popd
fi
......@@ -64,7 +64,7 @@
<dependency>
<groupId>org.opengroup.osdu.core.aws</groupId>
<artifactId>os-core-lib-aws</artifactId>
<version>0.3.11</version>
<version>0.3.17</version>
</dependency>
<dependency>
<groupId>org.opengroup.osdu</groupId>
......@@ -148,4 +148,4 @@
</plugin>
</plugins>
</build>
</project>
\ No newline at end of file
</project>
# Copyright © 2020 Amazon Web Services
# Copyright 2020 Amazon Web Services
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
......@@ -45,4 +45,11 @@ logging.slf4jlogger.enabled=true
logging.mdccontext.enabled=true
# if this is turned on then the service tries to connect to elastic search
management.health.elasticsearch.enabled=false
\ No newline at end of file
management.health.elasticsearch.enabled=false
server.ssl.enabled=${SSL_ENABLED:true}
server.ssl.key-store-type=PKCS12
server.ssl.key-store=${SSL_KEY_STORE_PATH:/certs/osduonaws.p12}
server.ssl.key-alias=${SSL_KEY_ALIAS:osduonaws}
server.ssl.key-password=${SSL_KEY_PASSWORD:}
server.ssl.key-store-password=${SSL_KEY_STORE_PASSWORD:}
\ No newline at end of file
......@@ -31,11 +31,10 @@
</parent>
<dependencies>
<dependency>
<groupId>org.opengroup.osdu</groupId>
<artifactId>core-lib-gcp</artifactId>
<version>0.1.21</version>
<version>0.6.1-SNAPSHOT</version>
</dependency>
<dependency>
......@@ -54,6 +53,12 @@
<artifactId>spring-security-config</artifactId>
</dependency>
<dependency>
<groupId>ch.qos.logback.contrib</groupId>
<artifactId>logback-json-classic</artifactId>
<version>0.1.5</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
......
......@@ -83,7 +83,7 @@ public class DatastoreActionRepo implements IActionRepo {
@Override
public Action get(String id) {
Datastore ds = dataStoreTenants.get(tenantInfo.getName());
Datastore ds = dataStoreTenants.get(tenantInfo);
Key key = createkey(ds, id);
Entity entity = ds.get(key);
if (entity == null)
......@@ -101,7 +101,7 @@ public class DatastoreActionRepo implements IActionRepo {
}
private Action createActionInDatastore(Action action) {
Datastore ds = dataStoreTenants.get(tenantInfo.getName());
Datastore ds = dataStoreTenants.get(tenantInfo);
Key key = createkey(ds, action.getId());
FullEntity<Key> entity = convertActionToEntity(action, key);
......@@ -134,7 +134,7 @@ public class DatastoreActionRepo implements IActionRepo {
}
private boolean deleteFromDatastore(String id) {
Datastore ds = dataStoreTenants.get(tenantInfo.getName());
Datastore ds = dataStoreTenants.get(tenantInfo);
boolean output = false;
Key key = createkey(ds, id);
......@@ -166,7 +166,7 @@ public class DatastoreActionRepo implements IActionRepo {
@Override
public List<Action> getAllActions() {
Datastore ds = dataStoreTenants.get(tenantInfo.getName());
Datastore ds = dataStoreTenants.get(tenantInfo);
Query<Entity> q = Query
.newGqlQueryBuilder(Query.ResultType.ENTITY, "Select * from ACTION")
......
......@@ -65,7 +65,7 @@ public class DatastoreDdmsRepository implements IDdmsRepository {
@Override
public Ddms create(Ddms ddms) {
Datastore ds = dataStoreTenants.get(tenantInfo.getName());
Datastore ds = dataStoreTenants.get(tenantInfo);
Key key = createkey(ds, ddms.getId());
FullEntity<Key> entity = convertDmsToEntity(ddms, key);
......@@ -95,7 +95,7 @@ public class DatastoreDdmsRepository implements IDdmsRepository {
@Override
public Ddms get(String id) {
Datastore ds = dataStoreTenants.get(tenantInfo.getName());
Datastore ds = dataStoreTenants.get(tenantInfo);
Key key = createkey(ds, id);
Entity entity = ds.get(key);
if (entity == null)
......@@ -106,7 +106,7 @@ public class DatastoreDdmsRepository implements IDdmsRepository {
@Override
public List<Ddms> query(String type) {
List<Ddms> output = new ArrayList<>();
Datastore ds = dataStoreTenants.get(tenantInfo.getName());
Datastore ds = dataStoreTenants.get(tenantInfo);
Query<Entity> q = Query
.newGqlQueryBuilder(Query.ResultType.ENTITY, "SELECT * FROM DDMS WHERE interfaces.type=@t")
.setBinding("t", type)
......@@ -122,7 +122,7 @@ public class DatastoreDdmsRepository implements IDdmsRepository {
@Override
public boolean delete(String id) {
Datastore ds = dataStoreTenants.get(tenantInfo.getName());
Datastore ds = dataStoreTenants.get(tenantInfo);
boolean output = false;
Key key = createkey(ds, id);
......
......@@ -16,47 +16,42 @@
package org.opengroup.osdu.register.provider.gcp.ddms.datastore;
import static java.util.Objects.isNull;
import com.google.cloud.datastore.Datastore;
import org.apache.commons.lang3.StringUtils;
import java.util.HashMap;
import java.util.Map;
import lombok.RequiredArgsConstructor;
import org.opengroup.osdu.core.common.model.http.AppException;
import org.opengroup.osdu.core.common.model.http.DpsHeaders;
import org.opengroup.osdu.core.gcp.multitenancy.DatastoreFactory;
import org.opengroup.osdu.core.common.model.tenant.TenantInfo;
import org.opengroup.osdu.core.gcp.multitenancy.IDatastoreFactory;
import org.opengroup.osdu.core.gcp.multitenancy.TenantFactory;
import org.opengroup.osdu.core.common.model.http.AppException;
import org.springframework.stereotype.Component;
import java.util.HashMap;
import java.util.Map;
@Component
@RequiredArgsConstructor
public class DatastoreMultiTenantAccess {
private final IDatastoreFactory factory;
private final Map<String, Datastore> tenantRepositories = new HashMap<>();
public DatastoreMultiTenantAccess() {
this(new DatastoreFactory(new TenantFactory()));
}
DatastoreMultiTenantAccess(IDatastoreFactory factory) {
this.factory = factory;
}
public Datastore get(String tenantName) {
if (StringUtils.isBlank(tenantName))
throw invalidTenantGivenException(tenantName);
if (!tenantRepositories.containsKey(tenantName)) {
addRepository(tenantName);
public Datastore get(TenantInfo tenantInfo) {
if (isNull(tenantInfo)){
throw invalidTenantGivenException("null");
}
if (!tenantRepositories.containsKey(tenantInfo.getName())) {
addRepository(tenantInfo);
}
return tenantRepositories.get(tenantName);
return tenantRepositories.get(tenantInfo.getName());
}
private void addRepository(String tenantName) {
Datastore ds = factory.getDatastore(tenantName, tenantName);
if (ds == null)
throw invalidTenantGivenException(tenantName);
tenantRepositories.put(tenantName, ds);
private void addRepository(TenantInfo tenantInfo) {
Datastore ds = factory.getDatastore(tenantInfo);
if (ds == null) {
throw invalidTenantGivenException(tenantInfo.getName());
}
tenantRepositories.put(tenantInfo.getName(), ds);
}
private AppException invalidTenantGivenException(String tenantName) {
......
......@@ -66,7 +66,7 @@ public class DatastoreAccess implements IDatastoreAccess {
@Override
public Subscription get(String id) {
Datastore ds = dataStoreTenants.get(tenantInfo.getName());
Datastore ds = dataStoreTenants.get(tenantInfo);
Key key = createKey(ds, id);
Entity entity = ds.get(key);
if (entity == null)
......@@ -83,7 +83,7 @@ public class DatastoreAccess implements IDatastoreAccess {
@Override
public List<Subscription> query(String notificationId) {
List<Subscription> output = new ArrayList<>();
Datastore ds = dataStoreTenants.get(tenantInfo.getName());
Datastore ds = dataStoreTenants.get(tenantInfo);
Query<Entity> q = Query
.newGqlQueryBuilder(Query.ResultType.ENTITY, "SELECT * FROM SUBSCRIPTION WHERE notificationId=@t")
.setBinding("t", notificationId)
......@@ -114,7 +114,7 @@ public class DatastoreAccess implements IDatastoreAccess {
@Override
public List<Subscription> getAll() throws Exception {
Datastore ds = dataStoreTenants.get(tenantInfo.getName());
Datastore ds = dataStoreTenants.get(tenantInfo);
Query<Entity> q = Query
.newGqlQueryBuilder(Query.ResultType.ENTITY, "Select * from SUBSCRIPTION")
.setNamespace(NAMESPACE).build();
......@@ -131,7 +131,7 @@ public class DatastoreAccess implements IDatastoreAccess {
}
private Subscription createSubscriberInDatastore(Subscription s) {
Datastore ds = dataStoreTenants.get(tenantInfo.getName());
Datastore ds = dataStoreTenants.get(tenantInfo);
Key key = createKey(ds, s.getId());
Transaction txn = ds.newTransaction();
......@@ -162,7 +162,7 @@ public class DatastoreAccess implements IDatastoreAccess {
}
private boolean deleteFromDatastore(String id, boolean deleteSubscription) {
Datastore ds = dataStoreTenants.get(tenantInfo.getName());
Datastore ds = dataStoreTenants.get(tenantInfo);
boolean output = false;
Key key = createKey(ds, id);
......@@ -198,7 +198,7 @@ public class DatastoreAccess implements IDatastoreAccess {
}
private boolean updateInDataStore(String id, Secret secret) {
Datastore ds = dataStoreTenants.get(tenantInfo.getName());
Datastore ds = dataStoreTenants.get(tenantInfo);
boolean output = false;
Key key = createKey(ds, id);
......
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<include resource="org/springframework/boot/logging/logback/defaults.xml"/>
<springProfile name="local">
<appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<pattern>%yellow([%thread]) %highlight(| %-5level |) %green(%d) %cyan(| %logger{15} |) %highlight(%msg) %n</pattern>
<charset>utf8</charset>
</encoder>
</appender>
<root level="DEBUG">
<appender-ref ref="CONSOLE"/>
</root>
</springProfile>
<springProfile name="!local">
<appender name="stdout" class="ch.qos.logback.core.ConsoleAppender">
<encoder class="ch.qos.logback.core.encoder.LayoutWrappingEncoder">
<layout class="ch.qos.logback.contrib.json.classic.JsonLayout">
<timestampFormat>yyyy-MM-dd HH:mm:ss.SSS</timestampFormat>
<timestampFormatTimezoneId>Etc/UTC</timestampFormatTimezoneId>
<appendLineSeparator>true</appendLineSeparator>
<jsonFormatter class="org.opengroup.osdu.core.gcp.logging.formatter.GoogleJsonFormatter">
<prettyPrint>false</prettyPrint>
</jsonFormatter>
</layout>
</encoder>
</appender>
<root level="debug">
<appender-ref ref="stdout"/>
</root>
</springProfile>
</configuration>
\ No newline at end of file
package org.opengroup.osdu.register.middleware;
import org.apache.http.HttpStatus;
import org.opengroup.osdu.core.common.http.ResponseHeaders;
import org.opengroup.osdu.core.common.http.ResponseHeadersFactory;
import org.opengroup.osdu.core.common.model.http.DpsHeaders;
import org.opengroup.osdu.register.utils.AppServiceConfig;
import org.opengroup.osdu.register.utils.ServiceRequestInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
import javax.servlet.*;
......@@ -14,6 +15,7 @@ import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;
import java.util.Map;
import javax.inject.Inject;
@Component
public class RegisterFilter implements Filter {
......@@ -27,6 +29,12 @@ public class RegisterFilter implements Filter {
@Autowired
private AppServiceConfig serviceConfig;
// defaults to * for any front-end, string must be comma-delimited if more than one domain
@Value("${ACCESS_CONTROL_ALLOW_ORIGIN_DOMAINS:*}")
String ACCESS_CONTROL_ALLOW_ORIGIN_DOMAINS;
private ResponseHeadersFactory responseHeadersFactory = new ResponseHeadersFactory();
@Override
public void init(FilterConfig filterConfig) {
//do nothing
......@@ -41,8 +49,8 @@ public class RegisterFilter implements Filter {
this.headers.addCorrelationIdIfMissing();
Map<String, List<Object>> standardHeaders = ResponseHeaders.STANDARD_RESPONSE_HEADERS;
for (Map.Entry<String, List<Object>> header : standardHeaders.entrySet()) {
Map<String, String> responseHeaders = responseHeadersFactory.getResponseHeaders(ACCESS_CONTROL_ALLOW_ORIGIN_DOMAINS);
for(Map.Entry<String, String> header : responseHeaders.entrySet()){
httpResponse.addHeader(header.getKey(), header.getValue().toString());
}
httpResponse.addHeader(DpsHeaders.CORRELATION_ID, this.headers.getCorrelationId());
......
......@@ -38,13 +38,13 @@ echo $INTEGRATION_TEST_OUTPUT_BIN_DIR
rm -rf "$INTEGRATION_TEST_OUTPUT_DIR"
mkdir -p "$INTEGRATION_TEST_OUTPUT_DIR" && mkdir -p "$INTEGRATION_TEST_OUTPUT_BIN_DIR"
echo "Building integration testing assemblies and gathering artifacts..."
mvn install -f "$INTEGRATION_TEST_SOURCE_DIR_CORE"/pom.xml
mvn install dependency:copy-dependencies -DskipTests -f "$INTEGRATION_TEST_SOURCE_DIR_AWS"/pom.xml -DincludeGroupIds=org.opengroup.osdu -Dmdep.copyPom
mvn -ntp install -f "$INTEGRATION_TEST_SOURCE_DIR_CORE"/pom.xml
mvn -ntp install dependency:copy-dependencies -DskipTests -f "$INTEGRATION_TEST_SOURCE_DIR_AWS"/pom.xml -DincludeGroupIds=org.opengroup.osdu -Dmdep.copyPom
cp "$INTEGRATION_TEST_SOURCE_DIR_AWS"/target/dependency/* "${INTEGRATION_TEST_OUTPUT_BIN_DIR}"
(cd "${INTEGRATION_TEST_OUTPUT_BIN_DIR}" && ls *.jar | sed -e 's/\.jar$//' | xargs -I {} echo mvn install:install-file -Dfile={}.jar -DpomFile={}.pom >> install-deps.sh)
(cd "${INTEGRATION_TEST_OUTPUT_BIN_DIR}" && ls *.jar | sed -e 's/\.jar$//' | xargs -I {} echo mvn -ntp install:install-file -Dfile={}.jar -DpomFile={}.pom >> install-deps.sh)
chmod +x "${INTEGRATION_TEST_OUTPUT_BIN_DIR}"/install-deps.sh
mvn clean -f "$INTEGRATION_TEST_SOURCE_DIR_AWS"/pom.xml
mvn -ntp clean -f "$INTEGRATION_TEST_SOURCE_DIR_AWS"/pom.xml
cp -R "$INTEGRATION_TEST_SOURCE_DIR_AWS"/* "${INTEGRATION_TEST_OUTPUT_DIR}"/
#copy testing parent pom to output
cp "$INTEGRATION_TEST_SOURCE_DIR/pom.xml" "${OUTPUT_DIR}/testing"
\ No newline at end of file
cp "$INTEGRATION_TEST_SOURCE_DIR/pom.xml" "${OUTPUT_DIR}/testing"
......@@ -48,7 +48,7 @@ export REGISTER_CUSTOM_PUSH_URL1=$REGISTER_BASE_URL$REGISTER_CUSTOM_PUSH_PATH1
#### RUN INTEGRATION TEST #########################################################################
mvn test -f "$SCRIPT_SOURCE_DIR"/../pom.xml
mvn -ntp test -f "$SCRIPT_SOURCE_DIR"/../pom.xml
TEST_EXIT_CODE=$?
#### COPY TEST REPORTS #########################################################################
......@@ -59,4 +59,4 @@ if [ -n "$1" ]
cp -R "$SCRIPT_SOURCE_DIR"/../target/surefire-reports "$1"
fi
echo "### Register-Service Integration Tests Finished ###"
exit $TEST_EXIT_CODE
\ No newline at end of file
exit $TEST_EXIT_CODE
......@@ -130,7 +130,7 @@
<dependency>
<groupId>org.opengroup.osdu.core.aws</groupId>
<artifactId>os-core-lib-aws</artifactId>
<version>0.3.11</version>
<version>0.3.16</version>
</dependency>
<dependency>
<groupId>com.amazonaws</groupId>
......
......@@ -23,7 +23,7 @@ import org.opengroup.osdu.core.aws.iam.IAMConfig;
import java.util.HashMap;
import java.util.Map;
//TODO: CognitoClient should use the client from core lib
public class AwsCognitoClient {
// Parameter value locations
......@@ -85,9 +85,14 @@ public class AwsCognitoClient {
public static AWSCognitoIdentityProvider generateCognitoClient()
{
return AWSCognitoIdentityProviderClientBuilder.standard()
.withCredentials(IAMConfig.amazonAWSCredentials())
.withRegion(AwsConfig.getAwsRegion())
.build();
AWSCognitoIdentityProviderClientBuilder builder = AWSCognitoIdentityProviderClientBuilder.standard()
.withCredentials(IAMConfig.amazonAWSCredentials());
String region = System.getenv("AWS_COGNITO_REGION");
if (region!=null){
builder.setRegion(region);
}else{
builder.withRegion(AwsConfig.getAwsRegion());
}
return builder.build();
}
}
Markdown is supported
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