KEYCLOAK-4328

This commit is contained in:
Bill Burke 2017-10-18 09:37:17 -04:00
parent fe76b2428b
commit 649bca7618
3 changed files with 62 additions and 8 deletions

View file

@ -34,6 +34,7 @@ import org.keycloak.storage.ldap.mappers.LDAPStorageMapper;
import org.keycloak.storage.user.SynchronizationResult;
import javax.ws.rs.BadRequestException;
import javax.ws.rs.GET;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
@ -78,6 +79,36 @@ public class UserStorageProviderResource {
this.adminEvent = adminEvent;
}
/**
* Need this for admin console to display simple name of provider when displaying user detail
*
* KEYCLOAK-4328
*
* @param id
* @return
*/
@GET
@Path("{id}/name")
@NoCache
@Produces(MediaType.APPLICATION_JSON)
public Map<String, String> getSimpleName(@PathParam("id") String id) {
auth.users().requireQuery();
ComponentModel model = realm.getComponent(id);
if (model == null) {
throw new NotFoundException("Could not find component");
}
if (!model.getProviderType().equals(UserStorageProvider.class.getName())) {
throw new NotFoundException("found, but not a UserStorageProvider");
}
Map<String, String> data = new HashMap<>();
data.put("id", model.getId());
data.put("name", model.getName());
return data;
}
/**
* Trigger sync of users
*

View file

@ -325,6 +325,7 @@ module.controller('UserTabCtrl', function($scope, $location, Dialog, Notificatio
module.controller('UserDetailCtrl', function($scope, realm, user, BruteForceUser, User,
Components,
UserImpersonation, RequiredActions,
UserStorageOperations,
$location, $http, Dialog, Notifications) {
$scope.realm = realm;
$scope.create = !user.id;
@ -352,18 +353,36 @@ module.controller('UserDetailCtrl', function($scope, realm, user, BruteForceUser
if(user.federationLink) {
console.log("federationLink is not null. It is " + user.federationLink);
if ($scope.access.viewRealm) {
Components.get({realm: realm.realm, componentId: user.federationLink}, function (link) {
$scope.federationLinkName = link.name;
$scope.federationLink = "#/realms/" + realm.realm + "/user-storage/providers/" + link.providerId + "/" + link.id;
});
} else {
// KEYCLOAK-4328
UserStorageOperations.simpleName.get({realm: realm.realm, componentId: user.federationLink}, function (link) {
$scope.federationLinkName = link.name;
$scope.federationLink = $location.absUrl();
})
}
} else {
console.log("federationLink is null");
}
if(user.origin) {
if ($scope.access.viewRealm) {
Components.get({realm: realm.realm, componentId: user.origin}, function (link) {
$scope.originName = link.name;
$scope.originLink = "#/realms/" + realm.realm + "/user-storage/providers/" + link.providerId + "/" + link.id;
})
}
else {
// KEYCLOAK-4328
UserStorageOperations.simpleName.get({realm: realm.realm, componentId: user.origin}, function (link) {
$scope.originName = link.name;
$scope.originLink = $location.absUrl();
})
}
} else {
console.log("origin is null");
}

View file

@ -1789,6 +1789,10 @@ module.factory('UserStorageOperations', function($resource) {
realm : '@realm',
componentId : '@componentId'
});
object.simpleName = $resource(authUrl + '/admin/realms/:realm/user-storage/:componentId/name', {
realm : '@realm',
componentId : '@componentId'
});
return object;
});