airavata-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From machris...@apache.org
Subject airavata git commit: AIRAVATA-2431 Fix adding admin user to "admin" role
Date Fri, 09 Jun 2017 14:12:35 GMT
Repository: airavata
Updated Branches:
  refs/heads/develop f52024fe8 -> da720e3a6


AIRAVATA-2431 Fix adding admin user to "admin" role


Project: http://git-wip-us.apache.org/repos/asf/airavata/repo
Commit: http://git-wip-us.apache.org/repos/asf/airavata/commit/da720e3a
Tree: http://git-wip-us.apache.org/repos/asf/airavata/tree/da720e3a
Diff: http://git-wip-us.apache.org/repos/asf/airavata/diff/da720e3a

Branch: refs/heads/develop
Commit: da720e3a61eb18fbe46487373a58ced75e14b7ee
Parents: f52024f
Author: Marcus Christie <machristie@apache.org>
Authored: Fri Jun 9 10:12:07 2017 -0400
Committer: Marcus Christie <machristie@apache.org>
Committed: Fri Jun 9 10:12:07 2017 -0400

----------------------------------------------------------------------
 .../services/core/impl/TenantManagementKeycloakImpl.java      | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/airavata/blob/da720e3a/airavata-services/profile-service/iam-admin-services-core/src/main/java/org/apache/airavata/service/profile/iam/admin/services/core/impl/TenantManagementKeycloakImpl.java
----------------------------------------------------------------------
diff --git a/airavata-services/profile-service/iam-admin-services-core/src/main/java/org/apache/airavata/service/profile/iam/admin/services/core/impl/TenantManagementKeycloakImpl.java
b/airavata-services/profile-service/iam-admin-services-core/src/main/java/org/apache/airavata/service/profile/iam/admin/services/core/impl/TenantManagementKeycloakImpl.java
index 6638697..22c3888 100644
--- a/airavata-services/profile-service/iam-admin-services-core/src/main/java/org/apache/airavata/service/profile/iam/admin/services/core/impl/TenantManagementKeycloakImpl.java
+++ b/airavata-services/profile-service/iam-admin-services-core/src/main/java/org/apache/airavata/service/profile/iam/admin/services/core/impl/TenantManagementKeycloakImpl.java
@@ -32,6 +32,7 @@ import org.jboss.resteasy.client.jaxrs.ResteasyClient;
 import org.jboss.resteasy.client.jaxrs.ResteasyClientBuilder;
 import org.keycloak.admin.client.Keycloak;
 import org.keycloak.admin.client.KeycloakBuilder;
+import org.keycloak.admin.client.resource.RoleResource;
 import org.keycloak.admin.client.resource.UserResource;
 import org.keycloak.representations.idm.*;
 import org.slf4j.Logger;
@@ -170,7 +171,6 @@ public class TenantManagementKeycloakImpl implements TenantManagementInterface
{
             user.setLastName(gatewayDetails.getGatewayAdminLastName());
             user.setEmail(gatewayDetails.getGatewayAdminEmail());
             user.setEnabled(true);
-            user.setRealmRoles(Arrays.asList("admin"));
             List<String> requiredActionList = new ArrayList<>();
             requiredActionList.add("UPDATE_PASSWORD");
             user.setRequiredActions(requiredActionList);
@@ -183,6 +183,11 @@ public class TenantManagementKeycloakImpl implements TenantManagementInterface
{
                         user.getEmail(),
                         0, 1);
                 UserResource retrievedUser = client.realm(gatewayDetails.getGatewayId()).users().get(retrieveCreatedUserList.get(0).getId());
+
+                // Add user to the "admin" role
+                RoleResource adminRoleResource = client.realm(gatewayDetails.getGatewayId()).roles().get("admin");
+                retrievedUser.roles().realmLevel().add(Arrays.asList(adminRoleResource.toRepresentation()));
+
                 CredentialRepresentation credential = new CredentialRepresentation();
                 credential.setType(CredentialRepresentation.PASSWORD);
                 credential.setValue(ServerSettings.getGatewayAdminTempPwd());


Mime
View raw message