You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airavata.apache.org by is...@apache.org on 2020/04/29 17:01:58 UTC

[airavata-custos] branch develop updated: minimize update request operations

This is an automated email from the ASF dual-hosted git repository.

isjarana pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/airavata-custos.git


The following commit(s) were added to refs/heads/develop by this push:
     new c80e53d  minimize update request operations
     new 019e8ba  Merge pull request #45 from isururanawaka/microservices_based_impl
c80e53d is described below

commit c80e53d4f55ebb7f96bab2dde90b8438bc10ed4e
Author: Isuru Ranawaka <ir...@gmail.com>
AuthorDate: Wed Apr 29 13:00:56 2020 -0400

    minimize update request operations
---
 .../main/resources/iamAdminCoreService.properties  | 14 +++---
 .../main/resources/identityCoreService.properties  | 14 +++---
 .../interceptors/DynamicRegistrationValidator.java |  6 ++-
 .../management/interceptors/InputValidator.java    |  5 ++
 .../management/tasks/TenantActivationTask.java     | 56 ++++++++++++----------
 5 files changed, 54 insertions(+), 41 deletions(-)

diff --git a/custos-core-services/utility-services/custos-configuration-service/src/main/resources/iamAdminCoreService.properties b/custos-core-services/utility-services/custos-configuration-service/src/main/resources/iamAdminCoreService.properties
index 56474d4..73a8905 100644
--- a/custos-core-services/utility-services/custos-configuration-service/src/main/resources/iamAdminCoreService.properties
+++ b/custos-core-services/utility-services/custos-configuration-service/src/main/resources/iamAdminCoreService.properties
@@ -11,10 +11,10 @@ iam.federated.cilogon.token.userinfo.endpoint=https://cilogon.org/oauth2/userinf
 iam.federated.cilogon.issuer=https://cilogon.org
 iam.federated.cilogon.jwksUri=https://cilogon.org/oauth2/certs
 introspection.endpoint=https://custos.scigap.org:32036/identity-management/v1.0.0/token/introspect
-issuer=https://custos.scigap.org:32036/
-authorization.endpoint=https://custos.scigap.org:32036/identity-management/v1.0.0/authorize
-token.endpoint=https://custos.scigap.org:32036/identity-management/v1.0.0/token
-end.session.endpoint=https://custos.scigap.org:32036/identity-management/v1.0.0/logout
-user.info.endpoint=https://custos.scigap.org:32036/user-management/v1.0.0/userinfo
-jwks_uri=https://custos.scigap.org:32036/identity-management/v1.0.0/certs
-registration.endpoint=https://custos.scigap.org:32036/tenant-management/v1.0.0/oauth2/tenant
\ No newline at end of file
+issuer=https://custos.scigap.org/
+authorization.endpoint=https://custos.scigap.org/apiserver/identity-management/v1.0.0/authorize
+token.endpoint=https://custos.scigap.org/apiserver/identity-management/v1.0.0/token
+end.session.endpoint=https://custos.scigap.org/apiserver/identity-management/v1.0.0/logout
+user.info.endpoint=https://custos.scigap.org/apiserver/user-management/v1.0.0/userinfo
+jwks_uri=https://custos.scigap.org/apiserver/identity-management/v1.0.0/certs
+registration.endpoint=https://custos.scigap.org/apiserver/tenant-management/v1.0.0/oauth2/tenant
\ No newline at end of file
diff --git a/custos-core-services/utility-services/custos-configuration-service/src/main/resources/identityCoreService.properties b/custos-core-services/utility-services/custos-configuration-service/src/main/resources/identityCoreService.properties
index 8546f5a..d1c4e17 100644
--- a/custos-core-services/utility-services/custos-configuration-service/src/main/resources/identityCoreService.properties
+++ b/custos-core-services/utility-services/custos-configuration-service/src/main/resources/identityCoreService.properties
@@ -23,10 +23,10 @@ iam.server.url=https://keycloak.custos.scigap.org:31000/auth/
 iam.server.truststore.path=/home/ubuntu/keystore/keycloak-client-truststore.pkcs12
 iam.server.truststore.password=keycloak
 introspection.endpoint=https://custos.scigap.org:32036/identity-management/v1.0.0/token/introspect
-issuer=https://custos.scigap.org:32036/
-authorization.endpoint=https://custos.scigap.org:32036/identity-management/v1.0.0/authorize
-token.endpoint=https://custos.scigap.org:32036/identity-management/v1.0.0/token
-end.session.endpoint=https://custos.scigap.org:32036/identity-management/v1.0.0/logout
-user.info.endpoint=https://custos.scigap.org:32036/user-management/v1.0.0/userinfo
-jwks_uri=https://custos.scigap.org:32036/identity-management/v1.0.0/certs
-registration.endpoint=https://custos.scigap.org:32036/tenant-management/v1.0.0/oauth2/tenant
+issuer=https://custos.scigap.org/
+authorization.endpoint=https://custos.scigap.org/apiserver/identity-management/v1.0.0/authorize
+token.endpoint=https://custos.scigap.org/apiserver/identity-management/v1.0.0/token
+end.session.endpoint=https://custos.scigap.org/apiserver/identity-management/v1.0.0/logout
+user.info.endpoint=https://custos.scigap.org/apiserver/user-management/v1.0.0/userinfo
+jwks_uri=https://custos.scigap.org/apiserver/identity-management/v1.0.0/certs
+registration.endpoint=https://custos.scigap.org:/apiserver/tenant-management/v1.0.0/oauth2/tenant
diff --git a/custos-integration-services/tenant-management-service-parent/tenant-management-service/src/main/java/org/apache/custos/tenant/management/interceptors/DynamicRegistrationValidator.java b/custos-integration-services/tenant-management-service-parent/tenant-management-service/src/main/java/org/apache/custos/tenant/management/interceptors/DynamicRegistrationValidator.java
index 3789949..cdfe8b7 100644
--- a/custos-integration-services/tenant-management-service-parent/tenant-management-service/src/main/java/org/apache/custos/tenant/management/interceptors/DynamicRegistrationValidator.java
+++ b/custos-integration-services/tenant-management-service-parent/tenant-management-service/src/main/java/org/apache/custos/tenant/management/interceptors/DynamicRegistrationValidator.java
@@ -93,6 +93,10 @@ public class DynamicRegistrationValidator extends AuthInterceptor implements Int
 
             String clientId = tenantRequest.getClientId();
 
+            if (clientId == null || clientId.trim().equals("")) {
+                clientId = tenantRequest.getBody().getClientId();
+            }
+
             GetCredentialRequest request = GetCredentialRequest.newBuilder()
                     .setId(clientId)
                     .build();
@@ -105,7 +109,7 @@ public class DynamicRegistrationValidator extends AuthInterceptor implements Int
 
             Tenant tenant = validateTenant(metadata.getOwnerId(), tenantRequest.getTenantId(), headers);
 
-            return (ReqT) tenantRequest.toBuilder().setTenantId(tenant.getTenantId()).build();
+            return (ReqT) tenantRequest.toBuilder().setTenantId(tenant.getTenantId()).setClientId(clientId).build();
 
         } else if (method.equals("deleteTenant")) {
 
diff --git a/custos-integration-services/tenant-management-service-parent/tenant-management-service/src/main/java/org/apache/custos/tenant/management/interceptors/InputValidator.java b/custos-integration-services/tenant-management-service-parent/tenant-management-service/src/main/java/org/apache/custos/tenant/management/interceptors/InputValidator.java
index 8ccc5e5..4059dd2 100644
--- a/custos-integration-services/tenant-management-service-parent/tenant-management-service/src/main/java/org/apache/custos/tenant/management/interceptors/InputValidator.java
+++ b/custos-integration-services/tenant-management-service-parent/tenant-management-service/src/main/java/org/apache/custos/tenant/management/interceptors/InputValidator.java
@@ -106,6 +106,11 @@ public class InputValidator implements IntegrationServiceInterceptor {
 
         String clientId = tenantRequest.getClientId();
 
+        if (clientId == null || clientId.trim().equals("")) {
+            clientId = tenantRequest.getBody().getClientId();
+        }
+
+        LOGGER.info("CLient Id "+ clientId);
 
         if (clientId == null || clientId.trim().equals("")) {
             throw new MissingParameterException("client_id should not be null", null);
diff --git a/custos-integration-services/tenant-management-service-parent/tenant-management-service/src/main/java/org/apache/custos/tenant/management/tasks/TenantActivationTask.java b/custos-integration-services/tenant-management-service-parent/tenant-management-service/src/main/java/org/apache/custos/tenant/management/tasks/TenantActivationTask.java
index fb3d491..eabad78 100644
--- a/custos-integration-services/tenant-management-service-parent/tenant-management-service/src/main/java/org/apache/custos/tenant/management/tasks/TenantActivationTask.java
+++ b/custos-integration-services/tenant-management-service-parent/tenant-management-service/src/main/java/org/apache/custos/tenant/management/tasks/TenantActivationTask.java
@@ -216,19 +216,36 @@ public class TenantActivationTask<T, U> extends ServiceTaskImpl<T, U> {
         clientMetadataBuilder.setClientId(creMeta.getId());
 
 
-        RegisterClientResponse registerClientResponse = federatedAuthenticationClient
-                .addClient(clientMetadataBuilder.build());
-
-
-        CredentialMetadata credentialMetadataCILogon = CredentialMetadata
-                .newBuilder()
-                .setId(registerClientResponse.getClientId())
-                .setSecret(registerClientResponse.getClientSecret())
-                .setOwnerId(tenant.getTenantId())
-                .setType(Type.CILOGON)
-                .build();
-
-        credentialStoreServiceClient.putCredential(credentialMetadataCILogon);
+        if (!update) {
+            RegisterClientResponse registerClientResponse = federatedAuthenticationClient
+                    .addClient(clientMetadataBuilder.build());
+
+
+            CredentialMetadata credentialMetadataCILogon = CredentialMetadata
+                    .newBuilder()
+                    .setId(registerClientResponse.getClientId())
+                    .setSecret(registerClientResponse.getClientSecret())
+                    .setOwnerId(tenant.getTenantId())
+                    .setType(Type.CILOGON)
+                    .build();
+
+            credentialStoreServiceClient.putCredential(credentialMetadataCILogon);
+
+
+            ConfigureFederateIDPRequest request = ConfigureFederateIDPRequest
+                    .newBuilder()
+                    .setTenantId(tenant.getTenantId())
+                    .setClientID(registerClientResponse.getClientId())
+                    .setClientSec(registerClientResponse.getClientSecret())
+                    .setScope(tenant.getScope())
+                    .setRequesterEmail(tenant.getRequesterEmail())
+                    .setType(FederatedIDPs.CILOGON)
+                    .build();
+            iamAdminServiceClient.configureFederatedIDP(request);
+        } else {
+            federatedAuthenticationClient
+                    .updateClient(clientMetadataBuilder.build());
+        }
 
         org.apache.custos.tenant.profile.service.UpdateStatusRequest updateTenantRequest =
                 org.apache.custos.tenant.profile.service.UpdateStatusRequest.newBuilder()
@@ -236,19 +253,6 @@ public class TenantActivationTask<T, U> extends ServiceTaskImpl<T, U> {
                         .setStatus(TenantStatus.ACTIVE)
                         .setUpdatedBy(Constants.SYSTEM)
                         .build();
-
-        ConfigureFederateIDPRequest request = ConfigureFederateIDPRequest
-                .newBuilder()
-                .setTenantId(tenant.getTenantId())
-                .setClientID(registerClientResponse.getClientId())
-                .setClientSec(registerClientResponse.getClientSecret())
-                .setScope(tenant.getScope())
-                .setRequesterEmail(tenant.getRequesterEmail())
-                .setType(FederatedIDPs.CILOGON)
-                .build();
-        iamAdminServiceClient.configureFederatedIDP(request);
-
-
         return profileClient.updateTenantStatus(updateTenantRequest);
     }