Fix showing federation links of users in admin console
This commit is contained in:
parent
4b637036ac
commit
03d607b022
4 changed files with 22 additions and 23 deletions
|
@ -133,7 +133,6 @@ module.controller('UserFederatedIdentityCtrl', function($scope, realm, user, fed
|
||||||
$scope.realm = realm;
|
$scope.realm = realm;
|
||||||
$scope.user = user;
|
$scope.user = user;
|
||||||
$scope.federatedIdentities = federatedIdentities;
|
$scope.federatedIdentities = federatedIdentities;
|
||||||
console.log('showing federated identities of user');
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -54,16 +54,16 @@ public interface UserResource {
|
||||||
public List<UserSessionRepresentation> getUserSessions();
|
public List<UserSessionRepresentation> getUserSessions();
|
||||||
|
|
||||||
@GET
|
@GET
|
||||||
@Path("social-links")
|
@Path("federated-identity")
|
||||||
public List<FederatedIdentityRepresentation> getSocialLinks();
|
public List<FederatedIdentityRepresentation> getFederatedIdentity();
|
||||||
|
|
||||||
@POST
|
@POST
|
||||||
@Path("social-links/{provider}")
|
@Path("federated-identity/{provider}")
|
||||||
public Response addSocialLink(@PathParam("provider") String provider, FederatedIdentityRepresentation rep);
|
public Response addFederatedIdentity(@PathParam("provider") String provider, FederatedIdentityRepresentation rep);
|
||||||
|
|
||||||
@Path("social-links/{provider}")
|
@Path("federated-identity/{provider}")
|
||||||
@DELETE
|
@DELETE
|
||||||
public void removeSocialLink(final @PathParam("provider") String provider);
|
public void removeFederatedIdentity(final @PathParam("provider") String provider);
|
||||||
|
|
||||||
@Path("role-mappings")
|
@Path("role-mappings")
|
||||||
public RoleMappingResource roles();
|
public RoleMappingResource roles();
|
||||||
|
|
|
@ -264,7 +264,7 @@ public class UsersResource {
|
||||||
|
|
||||||
for (FederatedIdentityModel identity : identities) {
|
for (FederatedIdentityModel identity : identities) {
|
||||||
for (IdentityProviderModel identityProviderModel : realm.getIdentityProviders()) {
|
for (IdentityProviderModel identityProviderModel : realm.getIdentityProviders()) {
|
||||||
if (identityProviderModel.getProviderId().equals(identity.getIdentityProvider())) {
|
if (identityProviderModel.getId().equals(identity.getIdentityProvider())) {
|
||||||
FederatedIdentityRepresentation rep = ModelToRepresentation.toRepresentation(identity);
|
FederatedIdentityRepresentation rep = ModelToRepresentation.toRepresentation(identity);
|
||||||
|
|
||||||
rep.setIdentityProvider(identityProviderModel.getName());
|
rep.setIdentityProvider(identityProviderModel.getName());
|
||||||
|
@ -276,10 +276,10 @@ public class UsersResource {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Path("{username}/social-links/{provider}")
|
@Path("{username}/federated-identity/{provider}")
|
||||||
@POST
|
@POST
|
||||||
@NoCache
|
@NoCache
|
||||||
public Response addSocialLink(final @PathParam("username") String username, final @PathParam("provider") String provider, FederatedIdentityRepresentation rep) {
|
public Response addFederatedIdentity(final @PathParam("username") String username, final @PathParam("provider") String provider, FederatedIdentityRepresentation rep) {
|
||||||
auth.requireManage();
|
auth.requireManage();
|
||||||
UserModel user = session.users().getUserByUsername(username, realm);
|
UserModel user = session.users().getUserByUsername(username, realm);
|
||||||
if (user == null) {
|
if (user == null) {
|
||||||
|
@ -295,10 +295,10 @@ public class UsersResource {
|
||||||
return Response.noContent().build();
|
return Response.noContent().build();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Path("{username}/social-links/{provider}")
|
@Path("{username}/federated-identity/{provider}")
|
||||||
@DELETE
|
@DELETE
|
||||||
@NoCache
|
@NoCache
|
||||||
public void removeSocialLink(final @PathParam("username") String username, final @PathParam("provider") String provider) {
|
public void removeFederatedIdentity(final @PathParam("username") String username, final @PathParam("provider") String provider) {
|
||||||
auth.requireManage();
|
auth.requireManage();
|
||||||
UserModel user = session.users().getUserByUsername(username, realm);
|
UserModel user = session.users().getUserByUsername(username, realm);
|
||||||
if (user == null) {
|
if (user == null) {
|
||||||
|
|
|
@ -114,7 +114,7 @@ public class UserTest extends AbstractClientTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void addSocialLink() {
|
public void addFederatedIdentity() {
|
||||||
createUser();
|
createUser();
|
||||||
|
|
||||||
UserResource user = realm.users().get("user1");
|
UserResource user = realm.users().get("user1");
|
||||||
|
@ -123,19 +123,19 @@ public class UserTest extends AbstractClientTest {
|
||||||
link.setUserId("social-user-id");
|
link.setUserId("social-user-id");
|
||||||
link.setUserName("social-username");
|
link.setUserName("social-username");
|
||||||
|
|
||||||
Response response = user.addSocialLink("social-provider-id", link);
|
Response response = user.addFederatedIdentity("social-provider-id", link);
|
||||||
assertEquals(204, response.getStatus());
|
assertEquals(204, response.getStatus());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@Ignore("Refactor based on KEYCLOAK-883")
|
@Ignore("Refactor based on KEYCLOAK-883")
|
||||||
public void getSocialLinks() {
|
public void getFederatedIdentities() {
|
||||||
addSocialLink();
|
addFederatedIdentity();
|
||||||
|
|
||||||
UserResource user = realm.users().get("user1");
|
UserResource user = realm.users().get("user1");
|
||||||
assertEquals(1, user.getSocialLinks().size());
|
assertEquals(1, user.getFederatedIdentity().size());
|
||||||
|
|
||||||
FederatedIdentityRepresentation link = user.getSocialLinks().get(0);
|
FederatedIdentityRepresentation link = user.getFederatedIdentity().get(0);
|
||||||
assertEquals("social-provider-id", link.getIdentityProvider());
|
assertEquals("social-provider-id", link.getIdentityProvider());
|
||||||
assertEquals("social-user-id", link.getUserId());
|
assertEquals("social-user-id", link.getUserId());
|
||||||
assertEquals("social-username", link.getUserName());
|
assertEquals("social-username", link.getUserName());
|
||||||
|
@ -143,15 +143,15 @@ public class UserTest extends AbstractClientTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@Ignore("Refactor based on KEYCLOAK-883")
|
@Ignore("Refactor based on KEYCLOAK-883")
|
||||||
public void removeSocialLink() {
|
public void removeFederatedIdentity() {
|
||||||
addSocialLink();
|
addFederatedIdentity();
|
||||||
|
|
||||||
UserResource user = realm.users().get("user1");
|
UserResource user = realm.users().get("user1");
|
||||||
assertEquals(1, user.getSocialLinks().size());
|
assertEquals(1, user.getFederatedIdentity().size());
|
||||||
|
|
||||||
user.removeSocialLink("social-provider-id");
|
user.removeFederatedIdentity("social-provider-id");
|
||||||
|
|
||||||
assertEquals(0, user.getSocialLinks().size());
|
assertEquals(0, user.getFederatedIdentity().size());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
Loading…
Reference in a new issue