storage link on user detail

This commit is contained in:
Bill Burke 2016-10-25 16:50:34 -04:00
parent 3fec344fa3
commit 3129e392b0
5 changed files with 48 additions and 4 deletions

View file

@ -33,6 +33,7 @@ public class UserRepresentation {
protected String self; // link protected String self; // link
protected String id; protected String id;
protected String origin;
protected Long createdTimestamp; protected Long createdTimestamp;
protected String username; protected String username;
protected Boolean enabled; protected Boolean enabled;
@ -240,4 +241,17 @@ public class UserRepresentation {
public void setGroups(List<String> groups) { public void setGroups(List<String> groups) {
this.groups = groups; this.groups = groups;
} }
/**
* Returns id of UserStorageProvider that loaded this user
*
* @return NULL if user stored locally
*/
public String getOrigin() {
return origin;
}
public void setOrigin(String origin) {
this.origin = origin;
}
} }

View file

@ -87,6 +87,7 @@ import org.keycloak.representations.idm.authorization.ResourceOwnerRepresentatio
import org.keycloak.representations.idm.authorization.ResourceRepresentation; import org.keycloak.representations.idm.authorization.ResourceRepresentation;
import org.keycloak.representations.idm.authorization.ResourceServerRepresentation; import org.keycloak.representations.idm.authorization.ResourceServerRepresentation;
import org.keycloak.representations.idm.authorization.ScopeRepresentation; import org.keycloak.representations.idm.authorization.ScopeRepresentation;
import org.keycloak.storage.StorageId;
import org.keycloak.util.JsonSerialization; import org.keycloak.util.JsonSerialization;
import java.io.IOException; import java.io.IOException;
@ -178,6 +179,8 @@ public class ModelToRepresentation {
public static UserRepresentation toRepresentation(KeycloakSession session, RealmModel realm, UserModel user) { public static UserRepresentation toRepresentation(KeycloakSession session, RealmModel realm, UserModel user) {
UserRepresentation rep = new UserRepresentation(); UserRepresentation rep = new UserRepresentation();
rep.setId(user.getId()); rep.setId(user.getId());
String providerId = StorageId.resolveProviderId(user);
rep.setOrigin(providerId);
rep.setUsername(user.getUsername()); rep.setUsername(user.getUsername());
rep.setCreatedTimestamp(user.getCreatedTimestamp()); rep.setCreatedTimestamp(user.getCreatedTimestamp());
rep.setLastName(user.getLastName()); rep.setLastName(user.getLastName());

View file

@ -1204,5 +1204,6 @@ userStorage.cachePolicy.evictionMinute=Eviction Minute
userStorage.cachePolicy.evictionMinute.tooltip=Minute of day the entry will become invalid on. userStorage.cachePolicy.evictionMinute.tooltip=Minute of day the entry will become invalid on.
userStorage.cachePolicy.maxLifespan=Max Lifespan userStorage.cachePolicy.maxLifespan=Max Lifespan
userStorage.cachePolicy.maxLifespan.tooltip=Max lifespan of a user cache entry in milliseconds. userStorage.cachePolicy.maxLifespan.tooltip=Max lifespan of a user cache entry in milliseconds.
user-origin-link=Storage Origin

View file

@ -335,6 +335,7 @@ module.controller('UserTabCtrl', function($scope, $location, Dialog, Notificatio
}); });
module.controller('UserDetailCtrl', function($scope, realm, user, BruteForceUser, User, module.controller('UserDetailCtrl', function($scope, realm, user, BruteForceUser, User,
Components,
UserFederationInstances, UserImpersonation, RequiredActions, UserFederationInstances, UserImpersonation, RequiredActions,
$location, Dialog, Notifications) { $location, Dialog, Notifications) {
$scope.realm = realm; $scope.realm = realm;
@ -362,13 +363,32 @@ module.controller('UserDetailCtrl', function($scope, realm, user, BruteForceUser
}; };
if(user.federationLink) { if(user.federationLink) {
console.log("federationLink is not null"); console.log("federationLink is not null");
UserFederationInstances.get({realm : realm.realm, instance: user.federationLink}, function(link) { if (user.federationLink.startsWith('f:')) {
$scope.federationLinkName = link.displayName; var componentId = user.federationLink.substring(2);
$scope.federationLink = "#/realms/" + realm.realm + "/user-federation/providers/" + link.providerName + "/" + link.id; var idx = componentId.indexOf(':');
}) componentId = componentId.substring(idx);
Components.get({realm: realm.realm, componentId: componentId}, function (link) {
$scope.federationLinkName = link.name;
$scope.federationLink = "#/realms/" + realm.realm + "/user-storage/providers/" + link.providerId + "/" + link.id;
})
} else {
UserFederationInstances.get({realm: realm.realm, instance: user.federationLink}, function (link) {
$scope.federationLinkName = link.displayName;
$scope.federationLink = "#/realms/" + realm.realm + "/user-federation/providers/" + link.providerName + "/" + link.id;
})
}
} else { } else {
console.log("federationLink is null"); console.log("federationLink is null");
} }
if(user.origin) {
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 {
console.log("origin is null");
}
console.log('realm brute force? ' + realm.bruteForceProtected) console.log('realm brute force? ' + realm.bruteForceProtected)
$scope.temporarilyDisabled = false; $scope.temporarilyDisabled = false;
var isDisabled = function () { var isDisabled = function () {

View file

@ -82,6 +82,12 @@
<a href="{{federationLink}}">{{federationLinkName}}</a> <a href="{{federationLink}}">{{federationLinkName}}</a>
</div> </div>
</div> </div>
<div class="form-group clearfix block" data-ng-show="!create && user.origin">
<label class="col-md-2 control-label">{{:: 'user-origin-link' | translate}}</label>
<div class="col-md-6">
<a href="{{originLink}}">{{originName}}</a>
</div>
</div>
<div class="form-group clearfix block"> <div class="form-group clearfix block">
<label class="col-md-2 control-label" for="emailVerified">{{:: 'email-verified' | translate}}</label> <label class="col-md-2 control-label" for="emailVerified">{{:: 'email-verified' | translate}}</label>
<div class="col-md-6"> <div class="col-md-6">