Commit 2fec88b7 authored by neelesh thakur's avatar neelesh thakur
Browse files

remove gcp dependency from core

parent 55ee1908
......@@ -56,11 +56,6 @@
<artifactId>os-core-common</artifactId>
<version>0.0.20</version>
</dependency>
<dependency>
<groupId>org.opengroup.osdu</groupId>
<artifactId>core-lib-gcp</artifactId>
<version>0.1.21</version>
</dependency>
</dependencies>
</dependencyManagement>
......
......@@ -37,6 +37,7 @@
<dependency>
<groupId>org.opengroup.osdu</groupId>
<artifactId>core-lib-gcp</artifactId>
<version>0.1.21</version>
</dependency>
<dependency>
......
......@@ -38,6 +38,6 @@ env_variables:
JETTY_MODULES_ENABLE: 'gzip'
JAVA_OPTS: -Xms2048m -Xmx3072m
SPRING_PROFILES_ACTIVE: 'dev'
GOOGLE_AUDIENCES: "GOOGLE-AUDIENCES"
INTEGRATION_TEST_AUDIENCES: "GOOGLE-AUDIENCES"
SUBSCRIBER_SECRET: "SUBSCRIBER-SECRET"
SUBSCRIBER_PRIVATE_KEY_ID: "SUBSCRIBER-PRIVATE-KEY-ID"
\ No newline at end of file
......@@ -20,9 +20,9 @@ import com.google.cloud.datastore.*;
import org.opengroup.osdu.core.common.model.http.AppException;
import org.opengroup.osdu.core.common.model.tenant.TenantInfo;
import org.opengroup.osdu.register.provider.gcp.ddms.datastore.DatastoreMultiTenantAccess;
import org.opengroup.osdu.register.provider.gcp.util.GcpAppServiceConfig;
import org.opengroup.osdu.register.subscriber.model.Secret;
import org.opengroup.osdu.register.subscriber.model.Subscription;
import org.opengroup.osdu.register.utils.AppServiceConfig;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;
......@@ -42,7 +42,7 @@ public class DatastoreAccess implements IDatastoreAccess {
@Autowired
private ModelEntityHelper modelEntityHelper;
@Autowired
private AppServiceConfig config;
private GcpAppServiceConfig config;
private static final String NAMESPACE = "DE";
private static final String KIND = "SUBSCRIPTION";
......
/*
* Copyright 2017-2020, Schlumberger
*
* 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.
*/
package org.opengroup.osdu.register.provider.gcp.util;
import org.opengroup.osdu.register.utils.AppServiceConfig;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Primary;
import org.springframework.stereotype.Component;
@Component
@Primary
public class GcpAppServiceConfig extends AppServiceConfig {
@Value("${GOOGLE_CLOUD_PROJECT}")
private String googleCloudProject;
@Value("${SERVICE_IDENTITY}")
private String serviceIdentity;
public String getGoogleCloudProject() {
return googleCloudProject;
}
public String getServiceAccountIdentity() {
return String.format("%s@%s.iam.gserviceaccount.com", serviceIdentity, googleCloudProject);
}
}
\ No newline at end of file
/*
* Copyright 2017-2020, Schlumberger
*
* 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.
*/
package org.opengroup.osdu.register.provider.gcp.util;
import lombok.SneakyThrows;
import org.apache.http.impl.client.HttpClients;
import org.opengroup.osdu.core.gcp.GoogleIdToken.IGoogleIdTokenFactory;
import org.opengroup.osdu.register.utils.IGoogleServiceAccount;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
@Component
public class GoogleServiceAccountImpl implements IGoogleServiceAccount {
@Autowired
private IGoogleIdTokenFactory googleIdTokenFactory;
@SneakyThrows
@Override
public String getIdToken(String keyString, String audience) {
return this.googleIdTokenFactory.getGoogleIdToken(keyString, audience, HttpClients.createDefault());
}
@SneakyThrows
@Override
public String getPrivateKeyId(String keyString) {
return this.googleIdTokenFactory.getPrivateKeyId(keyString);
}
}
\ No newline at end of file
......@@ -5,7 +5,7 @@ STORAGE_API=https://os-storage-dot-opendes.appspot.com/api/storage/v2
RECORDS_CHANGE_PUBSUB_ENDPOINT=https://os-notification-dot-opendes.appspot.com/push-handlers/records-changed
GOOGLE_CLOUD_PROJECT=opendes
GCLOUD_REGION=us-central
GOOGLE_AUDIENCES={GOOGLE_AUDIENCES}
INTEGRATION_TEST_AUDIENCES={GOOGLE_AUDIENCES}
SUBSCRIBER_SECRET={SUBSCRIBER_SECRET}
SUBSCRIBER_PRIVATE_KEY_ID={SUBSCRIBER_PRIVATE_KEY_ID}
enable.appengine.log.factory=true
\ No newline at end of file
......@@ -5,7 +5,7 @@ STORAGE_API=https://os-storage-dot-opendes.appspot.com/api/storage/v2
RECORDS_CHANGE_PUBSUB_ENDPOINT=https://os-notification-dot-opendes.appspot.com/push-handlers/records-changed
GOOGLE_CLOUD_PROJECT=opendes
GCLOUD_REGION=us-central
GOOGLE_AUDIENCES=245464679631-ktfdfpl147m1mjpbutl00b3cmffissgq.apps.googleusercontent.com
INTEGRATION_TEST_AUDIENCES=245464679631-ktfdfpl147m1mjpbutl00b3cmffissgq.apps.googleusercontent.com
SUBSCRIBER_SECRET={SUBSCRIBER_SECRET}
SUBSCRIBER_PRIVATE_KEY_ID={SUBSCRIBER_PRIVATE_KEY_ID}
enable.appengine.log.factory=false
\ No newline at end of file
......@@ -82,10 +82,6 @@
<groupId>org.opengroup.osdu</groupId>
<artifactId>os-core-common</artifactId>
</dependency>
<dependency>
<groupId>org.opengroup.osdu</groupId>
<artifactId>core-lib-gcp</artifactId>
</dependency>
<dependency>
<groupId>com.google.api</groupId>
<artifactId>gax-grpc</artifactId>
......
......@@ -113,7 +113,7 @@ public class SubscriberTestListenerApi {
try {
GoogleIdTokenVerifier verifier = new GoogleIdTokenVerifier.Builder(new NetHttpTransport(), JacksonFactory.getDefaultInstance())
.setAudience(Collections.singletonList(this.serviceConfig.getGoogleAudiences()))
.setAudience(Collections.singletonList(this.serviceConfig.getIntegrationTestJwtAudiences()))
.build();
GoogleIdToken idToken = verifier.verify(headers.getAuthorization());
return idToken != null;
......
......@@ -19,20 +19,19 @@ package org.opengroup.osdu.register.subscriber.services;
import com.google.common.hash.Hashing;
import com.google.gson.JsonElement;
import com.google.gson.JsonParser;
import org.apache.http.impl.client.HttpClients;
import org.opengroup.osdu.core.common.cryptographic.ISignatureService;
import org.opengroup.osdu.core.common.http.HttpRequest;
import org.opengroup.osdu.core.common.http.HttpResponse;
import org.opengroup.osdu.core.common.http.IHttpClient;
import org.opengroup.osdu.core.common.logging.JaxRsDpsLog;
import org.opengroup.osdu.core.common.model.http.DpsHeaders;
import org.opengroup.osdu.core.common.cryptographic.ISignatureService;
import org.opengroup.osdu.core.gcp.GoogleIdToken.IGoogleIdTokenFactory;
import org.opengroup.osdu.register.utils.AppServiceConfig;
import org.opengroup.osdu.register.utils.Constants;
import org.opengroup.osdu.register.subscriber.model.GsaSecret;
import org.opengroup.osdu.register.subscriber.model.HmacSecret;
import org.opengroup.osdu.register.subscriber.model.Secret;
import org.opengroup.osdu.register.subscriber.model.Subscription;
import org.opengroup.osdu.register.utils.AppServiceConfig;
import org.opengroup.osdu.register.utils.Constants;
import org.opengroup.osdu.register.utils.IGoogleServiceAccount;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
......@@ -51,7 +50,7 @@ public class ChallengeResponseCheck {
@Autowired
private ISignatureService signatureService;
@Autowired
private IGoogleIdTokenFactory googleIdTokenFactory;
private IGoogleServiceAccount googleServiceAccount;
@Autowired
private AppServiceConfig serviceConfig;
@Autowired
......@@ -89,8 +88,8 @@ public class ChallengeResponseCheck {
JsonParser jsonParser = new JsonParser();
JsonElement root = jsonParser.parse(gsaSecret.getValue().getKey());
String keyString = root.getAsJsonObject().toString();
String idToken = this.googleIdTokenFactory.getGoogleIdToken(keyString, gsaSecret.getValue().getAudience(), HttpClients.createDefault());
secretString = this.googleIdTokenFactory.getPrivateKeyId(keyString);
String idToken = this.googleServiceAccount.getIdToken(keyString, gsaSecret.getValue().getAudience());
secretString = this.googleServiceAccount.getPrivateKeyId(keyString);
// send gsa challange with idtoken in header
response = sendGsaChallenge(input, crc, idToken);
......
......@@ -22,18 +22,14 @@ import org.springframework.stereotype.Component;
@Component
public class AppServiceConfig {
@Value("${GOOGLE_CLOUD_PROJECT}")
private String googleCloudProject;
@Value("${GOOGLE_AUDIENCES}")
private String googleAudiences;
@Value("${INTEGRATION_TEST_AUDIENCES}")
private String integrationTestJwtAudiences;
@Value("${CRON_JOB_EXPECTED_IP}")
private String cronJobExpectedIp;
@Value("${ACCEPT_HTTP:false}")
private boolean acceptHttp;
@Value("${ENVIRONMENT}")
private String environment;
@Value("${SERVICE_IDENTITY}")
private String serviceIdentity;
@Value("${PERSISTENCE:CLOUD_NATIVE}")
private String persistence;
@Value("${ENTITLEMENTS_API}")
......@@ -45,12 +41,8 @@ public class AppServiceConfig {
@Value("${SUBSCRIBER_SECRET}")
private String subscriberSecret;
public String getGoogleCloudProject() {
return googleCloudProject;
}
public String getGoogleAudiences() {
return googleAudiences;
public String getIntegrationTestJwtAudiences() {
return integrationTestJwtAudiences;
}
public boolean getAcceptHttp() {
......@@ -86,10 +78,6 @@ public class AppServiceConfig {
"TEST".equalsIgnoreCase(environment) || "P4D".equalsIgnoreCase(environment);
}
public String getServiceAccountIdentity() {
return String.format("%s@%s.iam.gserviceaccount.com", serviceIdentity, googleCloudProject);
}
public String getMongoDatabaseName() {
return String.format("ddms-db-%s", getDeploymentEnvironment()).toLowerCase();
}
......
/*
* Copyright 2017-2020, Schlumberger
*
* 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.
*/
package org.opengroup.osdu.register.utils;
public interface IGoogleServiceAccount {
String getIdToken(String keyString, String audience);
String getPrivateKeyId(String keyString);
}
\ No newline at end of file
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