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 2022/10/26 14:47:05 UTC
[airavata-custos] branch baremetal updated: fix reset password
This is an automated email from the ASF dual-hosted git repository.
isjarana pushed a commit to branch baremetal
in repository https://gitbox.apache.org/repos/asf/airavata-custos.git
The following commit(s) were added to refs/heads/baremetal by this push:
new dd2b87b80 fix reset password
new e37ac9c86 Merge pull request #313 from isururanawaka/baremetal
dd2b87b80 is described below
commit dd2b87b80ba8fd5c06232c79a8c7822abd11cdb3
Author: Isuru Ranawaka <ir...@gmail.com>
AuthorDate: Wed Oct 26 10:46:23 2022 -0400
fix reset password
---
.../src/main/proto/IamAdminService.proto | 1 +
.../user/management/service/UserManagementService.java | 16 ++++++++++++++--
2 files changed, 15 insertions(+), 2 deletions(-)
diff --git a/custos-core-services/iam-admin-core-service/src/main/proto/IamAdminService.proto b/custos-core-services/iam-admin-core-service/src/main/proto/IamAdminService.proto
index 77fe2bb28..917b20297 100644
--- a/custos-core-services/iam-admin-core-service/src/main/proto/IamAdminService.proto
+++ b/custos-core-services/iam-admin-core-service/src/main/proto/IamAdminService.proto
@@ -181,6 +181,7 @@ message ResetUserPassword {
string access_token = 4;
string client_id = 5;
string client_sec = 6;
+ string old_password = 7;
}
diff --git a/custos-integration-services/user-management-service/src/main/java/org/apache/custos/user/management/service/UserManagementService.java b/custos-integration-services/user-management-service/src/main/java/org/apache/custos/user/management/service/UserManagementService.java
index 63961b589..92401a25d 100644
--- a/custos-integration-services/user-management-service/src/main/java/org/apache/custos/user/management/service/UserManagementService.java
+++ b/custos-integration-services/user-management-service/src/main/java/org/apache/custos/user/management/service/UserManagementService.java
@@ -27,6 +27,7 @@ import org.apache.custos.iam.service.UserAttribute;
import org.apache.custos.iam.service.*;
import org.apache.custos.identity.client.IdentityClient;
import org.apache.custos.identity.service.AuthToken;
+import org.apache.custos.identity.service.AuthenticationRequest;
import org.apache.custos.identity.service.GetUserManagementSATokenRequest;
import org.apache.custos.integration.core.utils.Constants;
import org.apache.custos.user.profile.client.UserProfileClient;
@@ -577,7 +578,18 @@ public class UserManagementService extends UserManagementServiceGrpc.UserManagem
.build();
AuthToken token = identityClient.getUserManagementSATokenRequest(userManagementSATokenRequest);
- if (token != null && token.getAccessToken() != null) {
+ AuthenticationRequest authenticationRequest = AuthenticationRequest
+ .newBuilder()
+ .setClientId(request.getClientId())
+ .setClientSecret(request.getClientSec())
+ .setTenantId(request.getTenantId())
+ .setUsername(request.getUsername())
+ .setPassword(request.getOldPassword())
+ .build();
+
+ AuthToken authToken = identityClient.authenticate(authenticationRequest);
+
+ if (authToken.getAccessToken() != null && token != null && token.getAccessToken() != null) {
request = request.toBuilder().setAccessToken(token.getAccessToken()).build();
@@ -586,7 +598,7 @@ public class UserManagementService extends UserManagementServiceGrpc.UserManagem
responseObserver.onCompleted();
} else {
LOGGER.error("Cannot find service token");
- responseObserver.onError(Status.CANCELLED.
+ responseObserver.onError(Status.PERMISSION_DENIED.
withDescription("Cannot find service token").asRuntimeException());
}