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 2021/06/07 14:19:51 UTC
[airavata-custos] branch develop updated: Fix aborting removal of
group default owner
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 f70cb71 Fix aborting removal of group default owner
new bdbb8ef Merge pull request #192 from isururanawaka/develop
f70cb71 is described below
commit f70cb710a6b6eb08c078941961b18bc09bfa53b9
Author: Isuru Ranawaka <ir...@gmail.com>
AuthorDate: Mon Jun 7 10:18:50 2021 -0400
Fix aborting removal of group default owner
---
.../custos/server/core/AgentProfileService_pb2.py | 18 ++++++++++++++++
.../server/core/CredentialStoreService_pb2.py | 18 ++++++++++++++++
.../core/FederatedAuthenticationService_pb2.py | 18 ++++++++++++++++
.../custos/server/core/IamAdminService_pb2.py | 18 ++++++++++++++++
.../custos/server/core/IdentityService_pb2.py | 18 ++++++++++++++++
.../integration/ClusterManagementService_pb2.py | 18 ++++++++++++++++
.../repository/GroupMembershipRepository.java | 2 ++
.../user/profile/service/UserProfileService.java | 24 +++++++++++++++++++++-
8 files changed, 133 insertions(+), 1 deletion(-)
diff --git a/custos-client-sdks/custos-python-sdk/custos/server/core/AgentProfileService_pb2.py b/custos-client-sdks/custos-python-sdk/custos/server/core/AgentProfileService_pb2.py
index 31d01a9..22b462f 100644
--- a/custos-client-sdks/custos-python-sdk/custos/server/core/AgentProfileService_pb2.py
+++ b/custos-client-sdks/custos-python-sdk/custos/server/core/AgentProfileService_pb2.py
@@ -1,4 +1,22 @@
# -*- coding: utf-8 -*-
+
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you 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.
+
# Generated by the protocol buffer compiler. DO NOT EDIT!
# source: AgentProfileService.proto
"""Generated protocol buffer code."""
diff --git a/custos-client-sdks/custos-python-sdk/custos/server/core/CredentialStoreService_pb2.py b/custos-client-sdks/custos-python-sdk/custos/server/core/CredentialStoreService_pb2.py
index 4428782..257a183 100644
--- a/custos-client-sdks/custos-python-sdk/custos/server/core/CredentialStoreService_pb2.py
+++ b/custos-client-sdks/custos-python-sdk/custos/server/core/CredentialStoreService_pb2.py
@@ -1,4 +1,22 @@
# -*- coding: utf-8 -*-
+
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you 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.
+
# Generated by the protocol buffer compiler. DO NOT EDIT!
# source: CredentialStoreService.proto
"""Generated protocol buffer code."""
diff --git a/custos-client-sdks/custos-python-sdk/custos/server/core/FederatedAuthenticationService_pb2.py b/custos-client-sdks/custos-python-sdk/custos/server/core/FederatedAuthenticationService_pb2.py
index 0425718..5286ff3 100644
--- a/custos-client-sdks/custos-python-sdk/custos/server/core/FederatedAuthenticationService_pb2.py
+++ b/custos-client-sdks/custos-python-sdk/custos/server/core/FederatedAuthenticationService_pb2.py
@@ -1,4 +1,22 @@
# -*- coding: utf-8 -*-
+
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you 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.
+
# Generated by the protocol buffer compiler. DO NOT EDIT!
# source: FederatedAuthenticationService.proto
"""Generated protocol buffer code."""
diff --git a/custos-client-sdks/custos-python-sdk/custos/server/core/IamAdminService_pb2.py b/custos-client-sdks/custos-python-sdk/custos/server/core/IamAdminService_pb2.py
index b1a8c63..9024a42 100644
--- a/custos-client-sdks/custos-python-sdk/custos/server/core/IamAdminService_pb2.py
+++ b/custos-client-sdks/custos-python-sdk/custos/server/core/IamAdminService_pb2.py
@@ -1,4 +1,22 @@
# -*- coding: utf-8 -*-
+
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you 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.
+
# Generated by the protocol buffer compiler. DO NOT EDIT!
# source: IamAdminService.proto
"""Generated protocol buffer code."""
diff --git a/custos-client-sdks/custos-python-sdk/custos/server/core/IdentityService_pb2.py b/custos-client-sdks/custos-python-sdk/custos/server/core/IdentityService_pb2.py
index adabd34..53e0fa4 100644
--- a/custos-client-sdks/custos-python-sdk/custos/server/core/IdentityService_pb2.py
+++ b/custos-client-sdks/custos-python-sdk/custos/server/core/IdentityService_pb2.py
@@ -1,4 +1,22 @@
# -*- coding: utf-8 -*-
+
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you 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.
+
# Generated by the protocol buffer compiler. DO NOT EDIT!
# source: IdentityService.proto
"""Generated protocol buffer code."""
diff --git a/custos-client-sdks/custos-python-sdk/custos/server/integration/ClusterManagementService_pb2.py b/custos-client-sdks/custos-python-sdk/custos/server/integration/ClusterManagementService_pb2.py
index 8ad76e1..4102d87 100644
--- a/custos-client-sdks/custos-python-sdk/custos/server/integration/ClusterManagementService_pb2.py
+++ b/custos-client-sdks/custos-python-sdk/custos/server/integration/ClusterManagementService_pb2.py
@@ -1,4 +1,22 @@
# -*- coding: utf-8 -*-
+
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you 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.
+
# Generated by the protocol buffer compiler. DO NOT EDIT!
# source: ClusterManagementService.proto
"""Generated protocol buffer code."""
diff --git a/custos-core-services/user-profile-core-service/src/main/java/org/apache/custos/user/profile/persistance/repository/GroupMembershipRepository.java b/custos-core-services/user-profile-core-service/src/main/java/org/apache/custos/user/profile/persistance/repository/GroupMembershipRepository.java
index 0220fd1..14e8f34 100644
--- a/custos-core-services/user-profile-core-service/src/main/java/org/apache/custos/user/profile/persistance/repository/GroupMembershipRepository.java
+++ b/custos-core-services/user-profile-core-service/src/main/java/org/apache/custos/user/profile/persistance/repository/GroupMembershipRepository.java
@@ -36,5 +36,7 @@ public interface GroupMembershipRepository extends JpaRepository<UserGroupMember
public List<UserGroupMembership>
findAllByGroupIdAndUserProfileIdAndUserGroupMembershipTypeId(String groupId, String userProfileId, String groupMembershipId);
+ public List<UserGroupMembership> findAllByGroupIdAndUserGroupMembershipTypeId(String id, String groupMembershipId);
+
}
diff --git a/custos-core-services/user-profile-core-service/src/main/java/org/apache/custos/user/profile/service/UserProfileService.java b/custos-core-services/user-profile-core-service/src/main/java/org/apache/custos/user/profile/service/UserProfileService.java
index 1ceeabf..d02e1b0 100644
--- a/custos-core-services/user-profile-core-service/src/main/java/org/apache/custos/user/profile/service/UserProfileService.java
+++ b/custos-core-services/user-profile-core-service/src/main/java/org/apache/custos/user/profile/service/UserProfileService.java
@@ -253,7 +253,7 @@ public class UserProfileService extends UserProfileServiceGrpc.UserProfileServic
responseObserver.onCompleted();
} catch (Exception ex) {
String msg = "Error occurred while fetching user profile for tenant " + request.getTenantId();
- LOGGER.error(msg,ex);
+ LOGGER.error(msg, ex);
responseObserver.onError(Status.INTERNAL.withDescription(msg).asRuntimeException());
}
@@ -803,6 +803,17 @@ public class UserProfileService extends UserProfileServiceGrpc.UserProfileServic
List<UserGroupMembership> memberships =
groupMembershipRepository.findAllByGroupIdAndUserProfileId(effectiveGroupId, userId);
+ List<UserGroupMembership> userGroupMemberships = groupMembershipRepository
+ .findAllByGroupIdAndUserGroupMembershipTypeId(effectiveGroupId, DefaultGroupMembershipTypes.OWNER.name());
+
+ if (userGroupMemberships != null && userGroupMemberships.size() == 1 &&
+ userGroupMemberships.get(0).getUserProfile().getUsername().equals(username)) {
+ String msg = "Default owner " + username + " cannot be removed from group " + group_id;
+ LOGGER.error(msg);
+ responseObserver.onError(Status.ABORTED.withDescription(msg).asRuntimeException());
+ return;
+ }
+
if (memberships != null && !memberships.isEmpty()) {
memberships.forEach(membership -> {
@@ -1294,6 +1305,17 @@ public class UserProfileService extends UserProfileServiceGrpc.UserProfileServic
return;
}
+ List<UserGroupMembership> userMemberships = groupMembershipRepository
+ .findAllByGroupIdAndUserGroupMembershipTypeId(effectiveGroupId, DefaultGroupMembershipTypes.OWNER.name());
+
+ if (userMemberships != null && userMemberships.size() == 1 &&
+ userMemberships.get(0).getUserProfile().getUsername().equals(username)) {
+ String msg = "Default owner " + username + " cannot be changed for group " + groupId;
+ LOGGER.error(msg);
+ responseObserver.onError(Status.ABORTED.withDescription(msg).asRuntimeException());
+ return;
+ }
+
UserGroupMembership groupMembership = userGroupMemberships.get(0);
UserGroupMembershipType groupMembershipType = groupMembership.getUserGroupMembershipType();