Updated admin events
This commit is contained in:
parent
c193ba0c81
commit
12c3aa83dd
17 changed files with 140 additions and 246 deletions
|
@ -67,6 +67,8 @@ public class RepresentationToModel {
|
||||||
if (rep.isEventsEnabled() != null) newRealm.setEventsEnabled(rep.isEventsEnabled());
|
if (rep.isEventsEnabled() != null) newRealm.setEventsEnabled(rep.isEventsEnabled());
|
||||||
if (rep.getEventsExpiration() != null) newRealm.setEventsExpiration(rep.getEventsExpiration());
|
if (rep.getEventsExpiration() != null) newRealm.setEventsExpiration(rep.getEventsExpiration());
|
||||||
if (rep.getEventsListeners() != null) newRealm.setEventsListeners(new HashSet<>(rep.getEventsListeners()));
|
if (rep.getEventsListeners() != null) newRealm.setEventsListeners(new HashSet<>(rep.getEventsListeners()));
|
||||||
|
if (rep.isAdminEventsEnabled() != null) newRealm.setAdminEventsEnabled(rep.isAdminEventsEnabled());
|
||||||
|
if (rep.isAdminEventsDetailsEnabled() != null) newRealm.setAdminEventsDetailsEnabled(rep.isAdminEventsDetailsEnabled());
|
||||||
|
|
||||||
if (rep.getNotBefore() != null) newRealm.setNotBefore(rep.getNotBefore());
|
if (rep.getNotBefore() != null) newRealm.setNotBefore(rep.getNotBefore());
|
||||||
|
|
||||||
|
|
|
@ -25,6 +25,8 @@ import org.keycloak.representations.idm.IdentityProviderRepresentation;
|
||||||
import org.keycloak.util.JsonSerialization;
|
import org.keycloak.util.JsonSerialization;
|
||||||
import org.keycloak.util.Time;
|
import org.keycloak.util.Time;
|
||||||
|
|
||||||
|
import javax.ws.rs.core.UriInfo;
|
||||||
|
|
||||||
public class AdminEventBuilder {
|
public class AdminEventBuilder {
|
||||||
|
|
||||||
private static final Logger log = Logger.getLogger(AdminEventBuilder.class);
|
private static final Logger log = Logger.getLogger(AdminEventBuilder.class);
|
||||||
|
@ -92,18 +94,6 @@ public class AdminEventBuilder {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public AdminEventBuilder authRealm(String realmId) {
|
|
||||||
AuthDetails authDetails = adminEvent.getAuthDetails();
|
|
||||||
if(authDetails == null) {
|
|
||||||
authDetails = new AuthDetails();
|
|
||||||
authDetails.setRealmId(realmId);
|
|
||||||
} else {
|
|
||||||
authDetails.setRealmId(realmId);
|
|
||||||
}
|
|
||||||
adminEvent.setAuthDetails(authDetails);
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public AdminEventBuilder authClient(ClientModel client) {
|
public AdminEventBuilder authClient(ClientModel client) {
|
||||||
AuthDetails authDetails = adminEvent.getAuthDetails();
|
AuthDetails authDetails = adminEvent.getAuthDetails();
|
||||||
if(authDetails == null) {
|
if(authDetails == null) {
|
||||||
|
@ -116,18 +106,6 @@ public class AdminEventBuilder {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public AdminEventBuilder authClient(String clientId) {
|
|
||||||
AuthDetails authDetails = adminEvent.getAuthDetails();
|
|
||||||
if(authDetails == null) {
|
|
||||||
authDetails = new AuthDetails();
|
|
||||||
authDetails.setClientId(clientId);
|
|
||||||
} else {
|
|
||||||
authDetails.setClientId(clientId);
|
|
||||||
}
|
|
||||||
adminEvent.setAuthDetails(authDetails);
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public AdminEventBuilder authUser(UserModel user) {
|
public AdminEventBuilder authUser(UserModel user) {
|
||||||
AuthDetails authDetails = adminEvent.getAuthDetails();
|
AuthDetails authDetails = adminEvent.getAuthDetails();
|
||||||
if(authDetails == null) {
|
if(authDetails == null) {
|
||||||
|
@ -140,18 +118,6 @@ public class AdminEventBuilder {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public AdminEventBuilder authUser(String userId) {
|
|
||||||
AuthDetails authDetails = adminEvent.getAuthDetails();
|
|
||||||
if(authDetails == null) {
|
|
||||||
authDetails = new AuthDetails();
|
|
||||||
authDetails.setUserId(userId);
|
|
||||||
} else {
|
|
||||||
authDetails.setUserId(userId);
|
|
||||||
}
|
|
||||||
adminEvent.setAuthDetails(authDetails);
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public AdminEventBuilder authIpAddress(String ipAddress) {
|
public AdminEventBuilder authIpAddress(String ipAddress) {
|
||||||
AuthDetails authDetails = adminEvent.getAuthDetails();
|
AuthDetails authDetails = adminEvent.getAuthDetails();
|
||||||
if(authDetails == null) {
|
if(authDetails == null) {
|
||||||
|
@ -164,59 +130,45 @@ public class AdminEventBuilder {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public AdminEventBuilder resourcePath(String resourcePath) {
|
public AdminEventBuilder resourcePath(UriInfo uriInfo) {
|
||||||
adminEvent.setResourcePath(resourcePath);
|
String path = getResourcePath(uriInfo);
|
||||||
|
adminEvent.setResourcePath(path);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public AdminEventBuilder resourcePath(String resourcePath, boolean segment) {
|
public AdminEventBuilder resourcePath(UriInfo uriInfo, String id) {
|
||||||
if(segment) {
|
|
||||||
int index = resourcePath.lastIndexOf('/');
|
|
||||||
int subIndex = resourcePath.lastIndexOf('/', index - 1);
|
|
||||||
adminEvent.setResourcePath(resourcePath.substring(subIndex));
|
|
||||||
} else {
|
|
||||||
adminEvent.setResourcePath(resourcePath.substring(resourcePath.lastIndexOf('/')));
|
|
||||||
}
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public AdminEventBuilder resourcePath(Object model) {
|
|
||||||
StringBuilder sb = new StringBuilder();
|
StringBuilder sb = new StringBuilder();
|
||||||
sb.append(getResourcePath(model));
|
sb.append(getResourcePath(uriInfo));
|
||||||
|
sb.append("/");
|
||||||
|
sb.append(id);
|
||||||
adminEvent.setResourcePath(sb.toString());
|
adminEvent.setResourcePath(sb.toString());
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public AdminEventBuilder resourcePath(Object model, String resourcePath) {
|
private String getResourcePath(UriInfo uriInfo) {
|
||||||
|
String path = uriInfo.getPath();
|
||||||
|
|
||||||
StringBuilder sb = new StringBuilder();
|
StringBuilder sb = new StringBuilder();
|
||||||
sb.append(getResourcePath(model));
|
sb.append("/realms/");
|
||||||
sb.append(resourcePath.substring(resourcePath.lastIndexOf('/')));
|
sb.append(realm.getName());
|
||||||
adminEvent.setResourcePath(sb.toString());
|
sb.append("/");
|
||||||
return this;
|
String realmRelative = sb.toString();
|
||||||
|
|
||||||
|
path = path.substring(path.indexOf(realmRelative) + realmRelative.length());
|
||||||
|
|
||||||
|
if (path.contains("clients-by-id")) {
|
||||||
|
path = path.replaceAll("clients-by-id", "clients");
|
||||||
|
} else if (path.contains("roles-by-id")) {
|
||||||
|
path = path.replaceAll("roles-by-id", "roles");
|
||||||
|
} else if (path.contains("role-mappings/realm")) {
|
||||||
|
path = path.replaceFirst("role-mappings/realm", "role-mappings");
|
||||||
|
} else if (path.contains("role-mappings/clients")) {
|
||||||
|
path = path.replaceFirst("role-mappings/clients", "role-mappings");
|
||||||
}
|
}
|
||||||
|
|
||||||
public AdminEventBuilder resourcePath(Object model, String resourcePath, boolean segment) {
|
return path;
|
||||||
StringBuilder sb = new StringBuilder();
|
|
||||||
sb.append(getResourcePath(model));
|
|
||||||
int index = resourcePath.lastIndexOf('/');
|
|
||||||
int subIndex = resourcePath.lastIndexOf('/', index - 1);
|
|
||||||
sb.append(resourcePath.substring(subIndex));
|
|
||||||
adminEvent.setResourcePath(sb.toString());
|
|
||||||
return this;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public AdminEventBuilder resourcePath(Object model, Object subModel, String resourcePath) {
|
|
||||||
StringBuilder sb = new StringBuilder();
|
|
||||||
sb.append(getResourcePath(model));
|
|
||||||
int index = resourcePath.lastIndexOf('/');
|
|
||||||
int subIndex = resourcePath.lastIndexOf('/', index - 1);
|
|
||||||
sb.append(resourcePath.substring(subIndex, index+1));
|
|
||||||
sb.append(getResourcePath(subModel));
|
|
||||||
adminEvent.setResourcePath(sb.toString());
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public void error(String error) {
|
public void error(String error) {
|
||||||
adminEvent.setOperationType(OperationType.valueOf(adminEvent.getOperationType().name() + "_ERROR"));
|
adminEvent.setOperationType(OperationType.valueOf(adminEvent.getOperationType().name() + "_ERROR"));
|
||||||
adminEvent.setError(error);
|
adminEvent.setError(error);
|
||||||
|
@ -269,46 +221,4 @@ public class AdminEventBuilder {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getResourcePath(Object model) {
|
|
||||||
|
|
||||||
StringBuilder sb = new StringBuilder();
|
|
||||||
|
|
||||||
if (model instanceof RealmModel) {
|
|
||||||
RealmModel realm = (RealmModel) model;
|
|
||||||
sb.append("realms/" + realm.getId());
|
|
||||||
} else if (model instanceof ClientModel) {
|
|
||||||
ClientModel client = (ClientModel) model;
|
|
||||||
sb.append("clients/" + client.getId());
|
|
||||||
} else if (model instanceof UserModel) {
|
|
||||||
UserModel user = (UserModel) model;
|
|
||||||
sb.append("users/" + user.getId());
|
|
||||||
|
|
||||||
} else if (model instanceof IdentityProviderModel) {
|
|
||||||
IdentityProviderModel provider = (IdentityProviderModel) model;
|
|
||||||
sb.append("identity-Providers/" + provider.getProviderId());
|
|
||||||
} else if (model instanceof IdentityProviderRepresentation) {
|
|
||||||
IdentityProviderRepresentation provider = (IdentityProviderRepresentation) model;
|
|
||||||
sb.append("identity-Providers/" + provider.getProviderId());
|
|
||||||
} else if (model instanceof IdentityProviderMapperModel) {
|
|
||||||
IdentityProviderMapperModel provider = (IdentityProviderMapperModel) model;
|
|
||||||
sb.append("identity-Provider-Mappers/" + provider.getId());
|
|
||||||
} else if (model instanceof IdentityProviderFactory) {
|
|
||||||
IdentityProviderFactory provider = (IdentityProviderFactory) model;
|
|
||||||
sb.append("identity-Provider-Factory/" + provider.getId());
|
|
||||||
|
|
||||||
} else if (model instanceof ProtocolMapperModel) {
|
|
||||||
ProtocolMapperModel mapper = (ProtocolMapperModel) model;
|
|
||||||
sb.append("protocol-Mappers/" + mapper.getId());
|
|
||||||
|
|
||||||
} else if (model instanceof UserFederationProviderModel) {
|
|
||||||
UserFederationProviderModel provider = (UserFederationProviderModel) model;
|
|
||||||
sb.append("user-Federation-Providers/" + provider.getId());
|
|
||||||
|
|
||||||
} else if (model instanceof RoleModel) {
|
|
||||||
RoleModel role = (RoleModel) model;
|
|
||||||
sb.append("roles/" + role.getId());
|
|
||||||
}
|
|
||||||
|
|
||||||
return sb.toString();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -138,8 +138,7 @@ public class ClientAttributeCertificateResource {
|
||||||
info.setCertificate(client.getAttribute(certificateAttribute));
|
info.setCertificate(client.getAttribute(certificateAttribute));
|
||||||
info.setPrivateKey(client.getAttribute(privateAttribute));
|
info.setPrivateKey(client.getAttribute(privateAttribute));
|
||||||
|
|
||||||
adminEvent.operation(OperationType.ACTION)
|
adminEvent.operation(OperationType.ACTION).resourcePath(session.getContext().getUri()).representation(info).success();
|
||||||
.resourcePath(client, session.getContext().getUri().getPath()).representation(info).success();
|
|
||||||
|
|
||||||
return info;
|
return info;
|
||||||
}
|
}
|
||||||
|
@ -198,7 +197,7 @@ public class ClientAttributeCertificateResource {
|
||||||
info.setCertificate(certPem);
|
info.setCertificate(certPem);
|
||||||
}
|
}
|
||||||
|
|
||||||
adminEvent.operation(OperationType.ACTION).resourcePath(client, uriInfo.getPath()).representation(info).success();
|
adminEvent.operation(OperationType.ACTION).resourcePath(session.getContext().getUri()).representation(info).success();
|
||||||
return info;
|
return info;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -324,10 +323,6 @@ public class ClientAttributeCertificateResource {
|
||||||
stream.flush();
|
stream.flush();
|
||||||
stream.close();
|
stream.close();
|
||||||
byte[] rtn = stream.toByteArray();
|
byte[] rtn = stream.toByteArray();
|
||||||
|
|
||||||
adminEvent.operation(OperationType.ACTION)
|
|
||||||
.resourcePath(client, session.getContext().getUri().getPath()).success();
|
|
||||||
|
|
||||||
return rtn;
|
return rtn;
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
|
|
|
@ -102,7 +102,7 @@ public class ClientResource {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
RepresentationToModel.updateClient(rep, client);
|
RepresentationToModel.updateClient(rep, client);
|
||||||
adminEvent.operation(OperationType.UPDATE).resourcePath(client).representation(rep).success();
|
adminEvent.operation(OperationType.UPDATE).resourcePath(uriInfo).representation(rep).success();
|
||||||
return Response.noContent().build();
|
return Response.noContent().build();
|
||||||
} catch (ModelDuplicateException e) {
|
} catch (ModelDuplicateException e) {
|
||||||
return ErrorResponse.exists("Client " + rep.getClientId() + " already exists");
|
return ErrorResponse.exists("Client " + rep.getClientId() + " already exists");
|
||||||
|
@ -150,8 +150,6 @@ public class ClientResource {
|
||||||
ClientManager clientManager = new ClientManager(new RealmManager(session));
|
ClientManager clientManager = new ClientManager(new RealmManager(session));
|
||||||
Object rep = clientManager.toInstallationRepresentation(realm, client, getKeycloakApplication().getBaseUri(uriInfo));
|
Object rep = clientManager.toInstallationRepresentation(realm, client, getKeycloakApplication().getBaseUri(uriInfo));
|
||||||
|
|
||||||
adminEvent.operation(OperationType.ACTION).resourcePath(client, uriInfo.getPath(), true).success();
|
|
||||||
|
|
||||||
// TODO Temporary solution to pretty-print
|
// TODO Temporary solution to pretty-print
|
||||||
return JsonSerialization.mapper.writerWithDefaultPrettyPrinter().writeValueAsString(rep);
|
return JsonSerialization.mapper.writerWithDefaultPrettyPrinter().writeValueAsString(rep);
|
||||||
}
|
}
|
||||||
|
@ -170,9 +168,6 @@ public class ClientResource {
|
||||||
auth.requireView();
|
auth.requireView();
|
||||||
|
|
||||||
ClientManager clientManager = new ClientManager(new RealmManager(session));
|
ClientManager clientManager = new ClientManager(new RealmManager(session));
|
||||||
|
|
||||||
adminEvent.operation(OperationType.ACTION).resourcePath(client, uriInfo.getPath(), true).success();
|
|
||||||
|
|
||||||
return clientManager.toJBossSubsystemConfig(realm, client, getKeycloakApplication().getBaseUri(uriInfo));
|
return clientManager.toJBossSubsystemConfig(realm, client, getKeycloakApplication().getBaseUri(uriInfo));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -185,7 +180,7 @@ public class ClientResource {
|
||||||
public void deleteClient() {
|
public void deleteClient() {
|
||||||
auth.requireManage();
|
auth.requireManage();
|
||||||
new ClientManager(new RealmManager(session)).removeClient(realm, client);
|
new ClientManager(new RealmManager(session)).removeClient(realm, client);
|
||||||
adminEvent.operation(OperationType.DELETE).resourcePath(client).success();
|
adminEvent.operation(OperationType.DELETE).resourcePath(uriInfo).success();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -204,7 +199,7 @@ public class ClientResource {
|
||||||
logger.debug("regenerateSecret");
|
logger.debug("regenerateSecret");
|
||||||
UserCredentialModel cred = KeycloakModelUtils.generateSecret(client);
|
UserCredentialModel cred = KeycloakModelUtils.generateSecret(client);
|
||||||
CredentialRepresentation rep = ModelToRepresentation.toRepresentation(cred);
|
CredentialRepresentation rep = ModelToRepresentation.toRepresentation(cred);
|
||||||
adminEvent.operation(OperationType.ACTION).resourcePath(client, uriInfo.getPath()).representation(rep).success();
|
adminEvent.operation(OperationType.ACTION).resourcePath(uriInfo).representation(rep).success();
|
||||||
return rep;
|
return rep;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -238,7 +233,7 @@ public class ClientResource {
|
||||||
|
|
||||||
@Path("roles")
|
@Path("roles")
|
||||||
public RoleContainerResource getRoleContainerResource() {
|
public RoleContainerResource getRoleContainerResource() {
|
||||||
return new RoleContainerResource(realm, auth, client, adminEvent);
|
return new RoleContainerResource(uriInfo, realm, auth, client, adminEvent);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -271,7 +266,7 @@ public class ClientResource {
|
||||||
auth.requireManage();
|
auth.requireManage();
|
||||||
|
|
||||||
client.setWebOrigins(allowedOrigins);
|
client.setWebOrigins(allowedOrigins);
|
||||||
adminEvent.operation(OperationType.UPDATE).resourcePath(client, uriInfo.getPath()).representation(client).success();
|
adminEvent.operation(OperationType.UPDATE).resourcePath(uriInfo).representation(client).success();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -290,7 +285,7 @@ public class ClientResource {
|
||||||
for (String origin : allowedOrigins) {
|
for (String origin : allowedOrigins) {
|
||||||
client.removeWebOrigin(origin);
|
client.removeWebOrigin(origin);
|
||||||
}
|
}
|
||||||
adminEvent.operation(OperationType.DELETE).resourcePath(client, uriInfo.getPath()).success();
|
adminEvent.operation(OperationType.DELETE).resourcePath(uriInfo).success();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -301,7 +296,7 @@ public class ClientResource {
|
||||||
@POST
|
@POST
|
||||||
public GlobalRequestResult pushRevocation() {
|
public GlobalRequestResult pushRevocation() {
|
||||||
auth.requireManage();
|
auth.requireManage();
|
||||||
adminEvent.operation(OperationType.ACTION).resourcePath(client, uriInfo.getPath()).success();
|
adminEvent.operation(OperationType.ACTION).resourcePath(uriInfo).success();
|
||||||
return new ResourceAdminManager(session).pushClientRevocationPolicy(uriInfo.getRequestUri(), realm, client);
|
return new ResourceAdminManager(session).pushClientRevocationPolicy(uriInfo.getRequestUri(), realm, client);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -355,7 +350,7 @@ public class ClientResource {
|
||||||
@POST
|
@POST
|
||||||
public GlobalRequestResult logoutAll() {
|
public GlobalRequestResult logoutAll() {
|
||||||
auth.requireManage();
|
auth.requireManage();
|
||||||
adminEvent.operation(OperationType.ACTION).resourcePath(client, uriInfo.getPath()).success();
|
adminEvent.operation(OperationType.ACTION).resourcePath(uriInfo).success();
|
||||||
return new ResourceAdminManager(session).logoutClient(uriInfo.getRequestUri(), realm, client);
|
return new ResourceAdminManager(session).logoutClient(uriInfo.getRequestUri(), realm, client);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -372,7 +367,7 @@ public class ClientResource {
|
||||||
if (user == null) {
|
if (user == null) {
|
||||||
throw new NotFoundException("User not found");
|
throw new NotFoundException("User not found");
|
||||||
}
|
}
|
||||||
adminEvent.operation(OperationType.ACTION).resourcePath(client, uriInfo.getPath(), true).success();
|
adminEvent.operation(OperationType.ACTION).resourcePath(uriInfo).success();
|
||||||
new ResourceAdminManager(session).logoutUserFromClient(uriInfo.getRequestUri(), realm, client, user);
|
new ResourceAdminManager(session).logoutUserFromClient(uriInfo.getRequestUri(), realm, client, user);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -394,7 +389,7 @@ public class ClientResource {
|
||||||
}
|
}
|
||||||
if (logger.isDebugEnabled()) logger.debug("Register node: " + node);
|
if (logger.isDebugEnabled()) logger.debug("Register node: " + node);
|
||||||
client.registerNode(node, Time.currentTime());
|
client.registerNode(node, Time.currentTime());
|
||||||
adminEvent.operation(OperationType.ACTION).resourcePath(client, uriInfo.getPath()).success();
|
adminEvent.operation(OperationType.ACTION).resourcePath(uriInfo).success();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -414,7 +409,7 @@ public class ClientResource {
|
||||||
throw new NotFoundException("Client does not have a node " + node);
|
throw new NotFoundException("Client does not have a node " + node);
|
||||||
}
|
}
|
||||||
client.unregisterNode(node);
|
client.unregisterNode(node);
|
||||||
adminEvent.operation(OperationType.DELETE).resourcePath(client, uriInfo.getPath(), true).success();
|
adminEvent.operation(OperationType.DELETE).resourcePath(uriInfo).success();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -428,7 +423,7 @@ public class ClientResource {
|
||||||
public GlobalRequestResult testNodesAvailable() {
|
public GlobalRequestResult testNodesAvailable() {
|
||||||
auth.requireManage();
|
auth.requireManage();
|
||||||
logger.debug("Test availability of cluster nodes");
|
logger.debug("Test availability of cluster nodes");
|
||||||
adminEvent.operation(OperationType.ACTION).resourcePath(client, uriInfo.getPath()).success();
|
adminEvent.operation(OperationType.ACTION).resourcePath(uriInfo).success();
|
||||||
return new ResourceAdminManager(session).testNodesAvailability(uriInfo.getRequestUri(), realm, client);
|
return new ResourceAdminManager(session).testNodesAvailability(uriInfo.getRequestUri(), realm, client);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -94,7 +94,7 @@ public class ClientsResource {
|
||||||
try {
|
try {
|
||||||
ClientModel clientModel = RepresentationToModel.createClient(session, realm, rep, true);
|
ClientModel clientModel = RepresentationToModel.createClient(session, realm, rep, true);
|
||||||
|
|
||||||
adminEvent.operation(OperationType.CREATE).resourcePath(clientModel).representation(rep).success();
|
adminEvent.operation(OperationType.CREATE).resourcePath(uriInfo, clientModel.getId()).representation(rep).success();
|
||||||
|
|
||||||
return Response.created(uriInfo.getAbsolutePathBuilder().path(getClientPath(clientModel)).build()).build();
|
return Response.created(uriInfo.getAbsolutePathBuilder().path(getClientPath(clientModel)).build()).build();
|
||||||
} catch (ModelDuplicateException e) {
|
} catch (ModelDuplicateException e) {
|
||||||
|
|
|
@ -86,7 +86,7 @@ public class IdentityProviderResource {
|
||||||
|
|
||||||
this.realm.removeIdentityProviderByAlias(this.identityProviderModel.getAlias());
|
this.realm.removeIdentityProviderByAlias(this.identityProviderModel.getAlias());
|
||||||
|
|
||||||
adminEvent.operation(OperationType.DELETE).resourcePath(identityProviderModel).success();
|
adminEvent.operation(OperationType.DELETE).resourcePath(uriInfo).success();
|
||||||
|
|
||||||
return Response.noContent().build();
|
return Response.noContent().build();
|
||||||
}
|
}
|
||||||
|
@ -112,7 +112,7 @@ public class IdentityProviderResource {
|
||||||
updateUsersAfterProviderAliasChange(this.session.users().getUsers(this.realm), oldProviderId, newProviderId);
|
updateUsersAfterProviderAliasChange(this.session.users().getUsers(this.realm), oldProviderId, newProviderId);
|
||||||
}
|
}
|
||||||
|
|
||||||
adminEvent.operation(OperationType.UPDATE).resourcePath(providerRep).representation(providerRep).success();
|
adminEvent.operation(OperationType.UPDATE).resourcePath(uriInfo).representation(providerRep).success();
|
||||||
|
|
||||||
return Response.noContent().build();
|
return Response.noContent().build();
|
||||||
} catch (ModelDuplicateException e) {
|
} catch (ModelDuplicateException e) {
|
||||||
|
@ -169,7 +169,6 @@ public class IdentityProviderResource {
|
||||||
try {
|
try {
|
||||||
this.auth.requireView();
|
this.auth.requireView();
|
||||||
IdentityProviderFactory factory = getIdentityProviderFactory();
|
IdentityProviderFactory factory = getIdentityProviderFactory();
|
||||||
adminEvent.operation(OperationType.ACTION).resourcePath(identityProviderModel, uriInfo.getPath()).success();
|
|
||||||
return factory.create(identityProviderModel).export(uriInfo, realm, format);
|
return factory.create(identityProviderModel).export(uriInfo, realm, format);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
return ErrorResponse.error("Could not export public broker configuration for identity provider [" + identityProviderModel.getProviderId() + "].", Response.Status.NOT_FOUND);
|
return ErrorResponse.error("Could not export public broker configuration for identity provider [" + identityProviderModel.getProviderId() + "].", Response.Status.NOT_FOUND);
|
||||||
|
@ -232,7 +231,7 @@ public class IdentityProviderResource {
|
||||||
IdentityProviderMapperModel model = RepresentationToModel.toModel(mapper);
|
IdentityProviderMapperModel model = RepresentationToModel.toModel(mapper);
|
||||||
model = realm.addIdentityProviderMapper(model);
|
model = realm.addIdentityProviderMapper(model);
|
||||||
|
|
||||||
adminEvent.operation(OperationType.CREATE).resourcePath(model, uriInfo.getPath())
|
adminEvent.operation(OperationType.CREATE).resourcePath(uriInfo, model.getId())
|
||||||
.representation(mapper).success();
|
.representation(mapper).success();
|
||||||
|
|
||||||
return Response.created(uriInfo.getAbsolutePathBuilder().path(model.getId()).build()).build();
|
return Response.created(uriInfo.getAbsolutePathBuilder().path(model.getId()).build()).build();
|
||||||
|
@ -260,7 +259,7 @@ public class IdentityProviderResource {
|
||||||
if (model == null) throw new NotFoundException("Model not found");
|
if (model == null) throw new NotFoundException("Model not found");
|
||||||
model = RepresentationToModel.toModel(rep);
|
model = RepresentationToModel.toModel(rep);
|
||||||
realm.updateIdentityProviderMapper(model);
|
realm.updateIdentityProviderMapper(model);
|
||||||
adminEvent.operation(OperationType.UPDATE).resourcePath(model).representation(rep).success();
|
adminEvent.operation(OperationType.UPDATE).resourcePath(uriInfo).representation(rep).success();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -272,7 +271,7 @@ public class IdentityProviderResource {
|
||||||
IdentityProviderMapperModel model = realm.getIdentityProviderMapperById(id);
|
IdentityProviderMapperModel model = realm.getIdentityProviderMapperById(id);
|
||||||
if (model == null) throw new NotFoundException("Model not found");
|
if (model == null) throw new NotFoundException("Model not found");
|
||||||
realm.removeIdentityProviderMapper(model);
|
realm.removeIdentityProviderMapper(model);
|
||||||
adminEvent.operation(OperationType.DELETE).resourcePath(model).success();
|
adminEvent.operation(OperationType.DELETE).resourcePath(uriInfo).success();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -82,9 +82,6 @@ public class IdentityProvidersResource {
|
||||||
InputStream inputStream = file.getBody(InputStream.class, null);
|
InputStream inputStream = file.getBody(InputStream.class, null);
|
||||||
IdentityProviderFactory providerFactory = getProviderFactorytById(providerId);
|
IdentityProviderFactory providerFactory = getProviderFactorytById(providerId);
|
||||||
Map<String, String> config = providerFactory.parseConfig(inputStream);
|
Map<String, String> config = providerFactory.parseConfig(inputStream);
|
||||||
|
|
||||||
adminEvent.operation(OperationType.CREATE).resourcePath(providerFactory, uriInfo.getPath()).representation(config).success();
|
|
||||||
|
|
||||||
return config;
|
return config;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -102,7 +99,6 @@ public class IdentityProvidersResource {
|
||||||
IdentityProviderFactory providerFactory = getProviderFactorytById(providerId);
|
IdentityProviderFactory providerFactory = getProviderFactorytById(providerId);
|
||||||
Map<String, String> config;
|
Map<String, String> config;
|
||||||
config = providerFactory.parseConfig(inputStream);
|
config = providerFactory.parseConfig(inputStream);
|
||||||
adminEvent.operation(OperationType.CREATE).resourcePath(providerFactory, uriInfo.getPath()).representation(config).success();
|
|
||||||
return config;
|
return config;
|
||||||
} finally {
|
} finally {
|
||||||
try {
|
try {
|
||||||
|
@ -137,7 +133,7 @@ public class IdentityProvidersResource {
|
||||||
IdentityProviderModel identityProvider = RepresentationToModel.toModel(representation);
|
IdentityProviderModel identityProvider = RepresentationToModel.toModel(representation);
|
||||||
this.realm.addIdentityProvider(identityProvider);
|
this.realm.addIdentityProvider(identityProvider);
|
||||||
|
|
||||||
adminEvent.operation(OperationType.CREATE).resourcePath(identityProvider)
|
adminEvent.operation(OperationType.CREATE).resourcePath(uriInfo, identityProvider.getInternalId())
|
||||||
.representation(representation).success();
|
.representation(representation).success();
|
||||||
|
|
||||||
return Response.created(uriInfo.getAbsolutePathBuilder().path(representation.getProviderId()).build()).build();
|
return Response.created(uriInfo.getAbsolutePathBuilder().path(representation.getProviderId()).build()).build();
|
||||||
|
|
|
@ -89,7 +89,7 @@ public class ProtocolMappersResource {
|
||||||
auth.requireManage();
|
auth.requireManage();
|
||||||
ProtocolMapperModel model = RepresentationToModel.toModel(rep);
|
ProtocolMapperModel model = RepresentationToModel.toModel(rep);
|
||||||
model = client.addProtocolMapper(model);
|
model = client.addProtocolMapper(model);
|
||||||
adminEvent.operation(OperationType.CREATE).resourcePath(model).representation(rep).success();
|
adminEvent.operation(OperationType.CREATE).resourcePath(uriInfo, model.getId()).representation(rep).success();
|
||||||
return Response.created(uriInfo.getAbsolutePathBuilder().path(model.getId()).build()).build();
|
return Response.created(uriInfo.getAbsolutePathBuilder().path(model.getId()).build()).build();
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
|
@ -107,7 +107,7 @@ public class ProtocolMappersResource {
|
||||||
model = RepresentationToModel.toModel(rep);
|
model = RepresentationToModel.toModel(rep);
|
||||||
model = client.addProtocolMapper(model);
|
model = client.addProtocolMapper(model);
|
||||||
}
|
}
|
||||||
adminEvent.operation(OperationType.CREATE).resourcePath(uriInfo.getPath(), false).representation(reps).success();
|
adminEvent.operation(OperationType.CREATE).resourcePath(uriInfo).representation(reps).success();
|
||||||
}
|
}
|
||||||
|
|
||||||
@GET
|
@GET
|
||||||
|
@ -144,7 +144,7 @@ public class ProtocolMappersResource {
|
||||||
if (model == null) throw new NotFoundException("Model not found");
|
if (model == null) throw new NotFoundException("Model not found");
|
||||||
model = RepresentationToModel.toModel(rep);
|
model = RepresentationToModel.toModel(rep);
|
||||||
client.updateProtocolMapper(model);
|
client.updateProtocolMapper(model);
|
||||||
adminEvent.operation(OperationType.UPDATE).resourcePath(model).representation(rep).success();
|
adminEvent.operation(OperationType.UPDATE).resourcePath(uriInfo).representation(rep).success();
|
||||||
}
|
}
|
||||||
|
|
||||||
@DELETE
|
@DELETE
|
||||||
|
@ -155,7 +155,7 @@ public class ProtocolMappersResource {
|
||||||
ProtocolMapperModel model = client.getProtocolMapperById(id);
|
ProtocolMapperModel model = client.getProtocolMapperById(id);
|
||||||
if (model == null) throw new NotFoundException("Model not found");
|
if (model == null) throw new NotFoundException("Model not found");
|
||||||
client.removeProtocolMapper(model);
|
client.removeProtocolMapper(model);
|
||||||
adminEvent.operation(OperationType.DELETE).resourcePath(model).success();
|
adminEvent.operation(OperationType.DELETE).resourcePath(uriInfo).success();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -132,7 +132,7 @@ public class RealmAdminResource {
|
||||||
*/
|
*/
|
||||||
@Path("roles")
|
@Path("roles")
|
||||||
public RoleContainerResource getRoleContainerResource() {
|
public RoleContainerResource getRoleContainerResource() {
|
||||||
return new RoleContainerResource(realm, auth, realm, adminEvent);
|
return new RoleContainerResource(uriInfo, realm, auth, realm, adminEvent);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -263,7 +263,7 @@ public class RealmAdminResource {
|
||||||
@POST
|
@POST
|
||||||
public GlobalRequestResult pushRevocation() {
|
public GlobalRequestResult pushRevocation() {
|
||||||
auth.requireManage();
|
auth.requireManage();
|
||||||
adminEvent.operation(OperationType.ACTION).resourcePath(uriInfo.getPath(), false).success();
|
adminEvent.operation(OperationType.ACTION).resourcePath(uriInfo).success();
|
||||||
return new ResourceAdminManager(session).pushRealmRevocationPolicy(uriInfo.getRequestUri(), realm);
|
return new ResourceAdminManager(session).pushRealmRevocationPolicy(uriInfo.getRequestUri(), realm);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -276,7 +276,7 @@ public class RealmAdminResource {
|
||||||
@POST
|
@POST
|
||||||
public GlobalRequestResult logoutAll() {
|
public GlobalRequestResult logoutAll() {
|
||||||
session.sessions().removeUserSessions(realm);
|
session.sessions().removeUserSessions(realm);
|
||||||
adminEvent.operation(OperationType.ACTION).resourcePath(uriInfo.getPath(), false).success();
|
adminEvent.operation(OperationType.ACTION).resourcePath(uriInfo).success();
|
||||||
return new ResourceAdminManager(session).logoutAll(uriInfo.getRequestUri(), realm);
|
return new ResourceAdminManager(session).logoutAll(uriInfo.getRequestUri(), realm);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -292,7 +292,7 @@ public class RealmAdminResource {
|
||||||
UserSessionModel userSession = session.sessions().getUserSession(realm, sessionId);
|
UserSessionModel userSession = session.sessions().getUserSession(realm, sessionId);
|
||||||
if (userSession == null) throw new NotFoundException("Sesssion not found");
|
if (userSession == null) throw new NotFoundException("Sesssion not found");
|
||||||
AuthenticationManager.backchannelLogout(session, realm, userSession, uriInfo, connection, headers, true);
|
AuthenticationManager.backchannelLogout(session, realm, userSession, uriInfo, connection, headers, true);
|
||||||
adminEvent.operation(OperationType.DELETE).resourcePath(uriInfo.getPath(), true).success();
|
adminEvent.operation(OperationType.DELETE).resourcePath(uriInfo).success();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -39,7 +39,10 @@ public class RoleByIdResource extends RoleResource {
|
||||||
private AdminEventBuilder adminEvent;
|
private AdminEventBuilder adminEvent;
|
||||||
|
|
||||||
@Context
|
@Context
|
||||||
protected KeycloakSession session;
|
private KeycloakSession session;
|
||||||
|
|
||||||
|
@Context
|
||||||
|
private UriInfo uriInfo;
|
||||||
|
|
||||||
public RoleByIdResource(RealmModel realm, RealmAuth auth, AdminEventBuilder adminEvent) {
|
public RoleByIdResource(RealmModel realm, RealmAuth auth, AdminEventBuilder adminEvent) {
|
||||||
super(realm);
|
super(realm);
|
||||||
|
@ -95,7 +98,7 @@ public class RoleByIdResource extends RoleResource {
|
||||||
RoleModel role = getRoleModel(id);
|
RoleModel role = getRoleModel(id);
|
||||||
auth.requireManage();
|
auth.requireManage();
|
||||||
deleteRole(role);
|
deleteRole(role);
|
||||||
adminEvent.operation(OperationType.DELETE).resourcePath(role).success();
|
adminEvent.operation(OperationType.DELETE).resourcePath(uriInfo).success();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -111,7 +114,7 @@ public class RoleByIdResource extends RoleResource {
|
||||||
RoleModel role = getRoleModel(id);
|
RoleModel role = getRoleModel(id);
|
||||||
auth.requireManage();
|
auth.requireManage();
|
||||||
updateRole(rep, role);
|
updateRole(rep, role);
|
||||||
adminEvent.operation(OperationType.UPDATE).resourcePath(role).representation(rep).success();
|
adminEvent.operation(OperationType.UPDATE).resourcePath(uriInfo).representation(rep).success();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -126,11 +129,7 @@ public class RoleByIdResource extends RoleResource {
|
||||||
public void addComposites(final @PathParam("role-id") String id, List<RoleRepresentation> roles) {
|
public void addComposites(final @PathParam("role-id") String id, List<RoleRepresentation> roles) {
|
||||||
RoleModel role = getRoleModel(id);
|
RoleModel role = getRoleModel(id);
|
||||||
auth.requireManage();
|
auth.requireManage();
|
||||||
addComposites(roles, role);
|
addComposites(adminEvent, uriInfo, roles, role);
|
||||||
|
|
||||||
adminEvent.operation(OperationType.ACTION)
|
|
||||||
.resourcePath(role, session.getContext().getUri().getPath()).representation(roles).success();
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -227,8 +226,7 @@ public class RoleByIdResource extends RoleResource {
|
||||||
auth.requireManage();
|
auth.requireManage();
|
||||||
deleteComposites(roles, role);
|
deleteComposites(roles, role);
|
||||||
|
|
||||||
adminEvent.operation(OperationType.DELETE)
|
adminEvent.operation(OperationType.DELETE).resourcePath(uriInfo).representation(roles).success();
|
||||||
.resourcePath(role, session.getContext().getUri().getPath()).representation(roles).success();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -39,9 +39,11 @@ public class RoleContainerResource extends RoleResource {
|
||||||
private final RealmAuth auth;
|
private final RealmAuth auth;
|
||||||
protected RoleContainerModel roleContainer;
|
protected RoleContainerModel roleContainer;
|
||||||
private AdminEventBuilder adminEvent;
|
private AdminEventBuilder adminEvent;
|
||||||
|
private UriInfo uriInfo;
|
||||||
|
|
||||||
public RoleContainerResource(RealmModel realm, RealmAuth auth, RoleContainerModel roleContainer, AdminEventBuilder adminEvent) {
|
public RoleContainerResource(UriInfo uriInfo, RealmModel realm, RealmAuth auth, RoleContainerModel roleContainer, AdminEventBuilder adminEvent) {
|
||||||
super(realm);
|
super(realm);
|
||||||
|
this.uriInfo = uriInfo;
|
||||||
this.realm = realm;
|
this.realm = realm;
|
||||||
this.auth = auth;
|
this.auth = auth;
|
||||||
this.roleContainer = roleContainer;
|
this.roleContainer = roleContainer;
|
||||||
|
@ -56,7 +58,7 @@ public class RoleContainerResource extends RoleResource {
|
||||||
@GET
|
@GET
|
||||||
@NoCache
|
@NoCache
|
||||||
@Produces(MediaType.APPLICATION_JSON)
|
@Produces(MediaType.APPLICATION_JSON)
|
||||||
public List<RoleRepresentation> getRoles(@Context final UriInfo uriInfo) {
|
public List<RoleRepresentation> getRoles() {
|
||||||
auth.requireAny();
|
auth.requireAny();
|
||||||
|
|
||||||
Set<RoleModel> roleModels = roleContainer.getRoles();
|
Set<RoleModel> roleModels = roleContainer.getRoles();
|
||||||
|
@ -70,20 +72,19 @@ public class RoleContainerResource extends RoleResource {
|
||||||
/**
|
/**
|
||||||
* Create a new role for this realm or client
|
* Create a new role for this realm or client
|
||||||
*
|
*
|
||||||
* @param uriInfo
|
|
||||||
* @param rep
|
* @param rep
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@POST
|
@POST
|
||||||
@Consumes(MediaType.APPLICATION_JSON)
|
@Consumes(MediaType.APPLICATION_JSON)
|
||||||
public Response createRole(final @Context UriInfo uriInfo, final RoleRepresentation rep) {
|
public Response createRole(final RoleRepresentation rep) {
|
||||||
auth.requireManage();
|
auth.requireManage();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
RoleModel role = roleContainer.addRole(rep.getName());
|
RoleModel role = roleContainer.addRole(rep.getName());
|
||||||
role.setDescription(rep.getDescription());
|
role.setDescription(rep.getDescription());
|
||||||
|
|
||||||
adminEvent.operation(OperationType.CREATE).resourcePath(role).representation(rep).success();
|
adminEvent.operation(OperationType.CREATE).resourcePath(uriInfo, role.getId()).representation(rep).success();
|
||||||
|
|
||||||
return Response.created(uriInfo.getAbsolutePathBuilder().path(role.getName()).build()).build();
|
return Response.created(uriInfo.getAbsolutePathBuilder().path(role.getName()).build()).build();
|
||||||
} catch (ModelDuplicateException e) {
|
} catch (ModelDuplicateException e) {
|
||||||
|
@ -101,7 +102,7 @@ public class RoleContainerResource extends RoleResource {
|
||||||
@GET
|
@GET
|
||||||
@NoCache
|
@NoCache
|
||||||
@Produces(MediaType.APPLICATION_JSON)
|
@Produces(MediaType.APPLICATION_JSON)
|
||||||
public RoleRepresentation getRole(@Context final UriInfo uriInfo, final @PathParam("role-name") String roleName) {
|
public RoleRepresentation getRole(final @PathParam("role-name") String roleName) {
|
||||||
auth.requireView();
|
auth.requireView();
|
||||||
|
|
||||||
RoleModel roleModel = roleContainer.getRole(roleName);
|
RoleModel roleModel = roleContainer.getRole(roleName);
|
||||||
|
@ -120,17 +121,17 @@ public class RoleContainerResource extends RoleResource {
|
||||||
@Path("{role-name}")
|
@Path("{role-name}")
|
||||||
@DELETE
|
@DELETE
|
||||||
@NoCache
|
@NoCache
|
||||||
public void deleteRole(@Context final UriInfo uriInfo, final @PathParam("role-name") String roleName) {
|
public void deleteRole(final @PathParam("role-name") String roleName) {
|
||||||
auth.requireManage();
|
auth.requireManage();
|
||||||
|
|
||||||
RoleRepresentation rep = getRole(uriInfo, roleName);
|
RoleRepresentation rep = getRole(roleName);
|
||||||
RoleModel role = roleContainer.getRole(roleName);
|
RoleModel role = roleContainer.getRole(roleName);
|
||||||
if (role == null) {
|
if (role == null) {
|
||||||
throw new NotFoundException("Could not find role: " + roleName);
|
throw new NotFoundException("Could not find role: " + roleName);
|
||||||
}
|
}
|
||||||
deleteRole(role);
|
deleteRole(role);
|
||||||
|
|
||||||
adminEvent.operation(OperationType.DELETE).resourcePath(role).success();
|
adminEvent.operation(OperationType.DELETE).resourcePath(uriInfo).success();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -144,7 +145,7 @@ public class RoleContainerResource extends RoleResource {
|
||||||
@Path("{role-name}")
|
@Path("{role-name}")
|
||||||
@PUT
|
@PUT
|
||||||
@Consumes(MediaType.APPLICATION_JSON)
|
@Consumes(MediaType.APPLICATION_JSON)
|
||||||
public Response updateRole(@Context final UriInfo uriInfo, final @PathParam("role-name") String roleName, final RoleRepresentation rep) {
|
public Response updateRole(final @PathParam("role-name") String roleName, final RoleRepresentation rep) {
|
||||||
auth.requireManage();
|
auth.requireManage();
|
||||||
|
|
||||||
RoleModel role = roleContainer.getRole(roleName);
|
RoleModel role = roleContainer.getRole(roleName);
|
||||||
|
@ -154,7 +155,7 @@ public class RoleContainerResource extends RoleResource {
|
||||||
try {
|
try {
|
||||||
updateRole(rep, role);
|
updateRole(rep, role);
|
||||||
|
|
||||||
adminEvent.operation(OperationType.UPDATE).resourcePath(role).representation(rep).success();
|
adminEvent.operation(OperationType.UPDATE).resourcePath(uriInfo).representation(rep).success();
|
||||||
|
|
||||||
return Response.noContent().build();
|
return Response.noContent().build();
|
||||||
} catch (ModelDuplicateException e) {
|
} catch (ModelDuplicateException e) {
|
||||||
|
@ -171,16 +172,14 @@ public class RoleContainerResource extends RoleResource {
|
||||||
@Path("{role-name}/composites")
|
@Path("{role-name}/composites")
|
||||||
@POST
|
@POST
|
||||||
@Consumes(MediaType.APPLICATION_JSON)
|
@Consumes(MediaType.APPLICATION_JSON)
|
||||||
public void addComposites(@Context final UriInfo uriInfo, final @PathParam("role-name") String roleName, List<RoleRepresentation> roles) {
|
public void addComposites(final @PathParam("role-name") String roleName, List<RoleRepresentation> roles) {
|
||||||
auth.requireManage();
|
auth.requireManage();
|
||||||
|
|
||||||
RoleModel role = roleContainer.getRole(roleName);
|
RoleModel role = roleContainer.getRole(roleName);
|
||||||
if (role == null) {
|
if (role == null) {
|
||||||
throw new NotFoundException("Could not find role: " + roleName);
|
throw new NotFoundException("Could not find role: " + roleName);
|
||||||
}
|
}
|
||||||
addComposites(roles, role);
|
addComposites(adminEvent, uriInfo, roles, role);
|
||||||
adminEvent.operation(OperationType.ACTION).resourcePath(role, uriInfo.getPath()).representation(roles).success();
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -193,7 +192,7 @@ public class RoleContainerResource extends RoleResource {
|
||||||
@GET
|
@GET
|
||||||
@NoCache
|
@NoCache
|
||||||
@Produces(MediaType.APPLICATION_JSON)
|
@Produces(MediaType.APPLICATION_JSON)
|
||||||
public Set<RoleRepresentation> getRoleComposites(@Context final UriInfo uriInfo, final @PathParam("role-name") String roleName) {
|
public Set<RoleRepresentation> getRoleComposites(final @PathParam("role-name") String roleName) {
|
||||||
auth.requireManage();
|
auth.requireManage();
|
||||||
|
|
||||||
RoleModel role = roleContainer.getRole(roleName);
|
RoleModel role = roleContainer.getRole(roleName);
|
||||||
|
@ -213,7 +212,7 @@ public class RoleContainerResource extends RoleResource {
|
||||||
@GET
|
@GET
|
||||||
@NoCache
|
@NoCache
|
||||||
@Produces(MediaType.APPLICATION_JSON)
|
@Produces(MediaType.APPLICATION_JSON)
|
||||||
public Set<RoleRepresentation> getRealmRoleComposites(@Context final UriInfo uriInfo, final @PathParam("role-name") String roleName) {
|
public Set<RoleRepresentation> getRealmRoleComposites(final @PathParam("role-name") String roleName) {
|
||||||
auth.requireManage();
|
auth.requireManage();
|
||||||
|
|
||||||
RoleModel role = roleContainer.getRole(roleName);
|
RoleModel role = roleContainer.getRole(roleName);
|
||||||
|
@ -234,7 +233,7 @@ public class RoleContainerResource extends RoleResource {
|
||||||
@GET
|
@GET
|
||||||
@NoCache
|
@NoCache
|
||||||
@Produces(MediaType.APPLICATION_JSON)
|
@Produces(MediaType.APPLICATION_JSON)
|
||||||
public Set<RoleRepresentation> getClientRoleComposites(@Context final UriInfo uriInfo,
|
public Set<RoleRepresentation> getClientRoleComposites(
|
||||||
final @PathParam("role-name") String roleName,
|
final @PathParam("role-name") String roleName,
|
||||||
final @PathParam("clientId") String clientId) {
|
final @PathParam("clientId") String clientId) {
|
||||||
auth.requireManage();
|
auth.requireManage();
|
||||||
|
@ -290,7 +289,7 @@ public class RoleContainerResource extends RoleResource {
|
||||||
@Path("{role-name}/composites")
|
@Path("{role-name}/composites")
|
||||||
@DELETE
|
@DELETE
|
||||||
@Consumes(MediaType.APPLICATION_JSON)
|
@Consumes(MediaType.APPLICATION_JSON)
|
||||||
public void deleteComposites(@Context final UriInfo uriInfo,
|
public void deleteComposites(
|
||||||
final @PathParam("role-name") String roleName,
|
final @PathParam("role-name") String roleName,
|
||||||
List<RoleRepresentation> roles) {
|
List<RoleRepresentation> roles) {
|
||||||
auth.requireManage();
|
auth.requireManage();
|
||||||
|
@ -300,7 +299,7 @@ public class RoleContainerResource extends RoleResource {
|
||||||
throw new NotFoundException("Could not find role: " + roleName);
|
throw new NotFoundException("Could not find role: " + roleName);
|
||||||
}
|
}
|
||||||
deleteComposites(roles, role);
|
deleteComposites(roles, role);
|
||||||
adminEvent.operation(OperationType.DELETE).resourcePath(role, uriInfo.getPath()).success();
|
adminEvent.operation(OperationType.DELETE).resourcePath(uriInfo).success();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,12 +1,14 @@
|
||||||
package org.keycloak.services.resources.admin;
|
package org.keycloak.services.resources.admin;
|
||||||
|
|
||||||
import org.jboss.resteasy.spi.NotFoundException;
|
import org.jboss.resteasy.spi.NotFoundException;
|
||||||
|
import org.keycloak.events.admin.OperationType;
|
||||||
import org.keycloak.models.ClientModel;
|
import org.keycloak.models.ClientModel;
|
||||||
import org.keycloak.models.RealmModel;
|
import org.keycloak.models.RealmModel;
|
||||||
import org.keycloak.models.RoleModel;
|
import org.keycloak.models.RoleModel;
|
||||||
import org.keycloak.models.utils.ModelToRepresentation;
|
import org.keycloak.models.utils.ModelToRepresentation;
|
||||||
import org.keycloak.representations.idm.RoleRepresentation;
|
import org.keycloak.representations.idm.RoleRepresentation;
|
||||||
|
|
||||||
|
import javax.ws.rs.core.UriInfo;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -38,13 +40,15 @@ public abstract class RoleResource {
|
||||||
role.setDescription(rep.getDescription());
|
role.setDescription(rep.getDescription());
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void addComposites(List<RoleRepresentation> roles, RoleModel role) {
|
protected void addComposites(AdminEventBuilder adminEvent, UriInfo uriInfo, List<RoleRepresentation> roles, RoleModel role) {
|
||||||
for (RoleRepresentation rep : roles) {
|
for (RoleRepresentation rep : roles) {
|
||||||
RoleModel composite = realm.getRoleById(rep.getId());
|
RoleModel composite = realm.getRoleById(rep.getId());
|
||||||
if (composite == null) {
|
if (composite == null) {
|
||||||
throw new NotFoundException("Could not find composite role: " + rep.getName());
|
throw new NotFoundException("Could not find composite role: " + rep.getName());
|
||||||
}
|
}
|
||||||
role.addCompositeRole(composite);
|
role.addCompositeRole(composite);
|
||||||
|
|
||||||
|
adminEvent.operation(OperationType.CREATE).resourcePath(uriInfo, rep.getId()).representation(roles).success();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -110,7 +110,7 @@ public class ScopeMappedClientResource {
|
||||||
throw new NotFoundException("Role not found");
|
throw new NotFoundException("Role not found");
|
||||||
}
|
}
|
||||||
client.addScopeMapping(roleModel);
|
client.addScopeMapping(roleModel);
|
||||||
adminEvent.operation(OperationType.CREATE).resourcePath(client, "/roles").representation(roles).success();
|
adminEvent.operation(OperationType.CREATE).resourcePath(session.getContext().getUri(), roleModel.getId()).representation(roles).success();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -129,7 +129,7 @@ public class ScopeMappedClientResource {
|
||||||
for (RoleModel roleModel : roleModels) {
|
for (RoleModel roleModel : roleModels) {
|
||||||
client.deleteScopeMapping(roleModel);
|
client.deleteScopeMapping(roleModel);
|
||||||
}
|
}
|
||||||
|
adminEvent.operation(OperationType.DELETE).resourcePath(session.getContext().getUri()).representation(roles).success();
|
||||||
} else {
|
} else {
|
||||||
for (RoleRepresentation role : roles) {
|
for (RoleRepresentation role : roles) {
|
||||||
RoleModel roleModel = scopedClient.getRole(role.getName());
|
RoleModel roleModel = scopedClient.getRole(role.getName());
|
||||||
|
@ -137,8 +137,8 @@ public class ScopeMappedClientResource {
|
||||||
throw new NotFoundException("Role not found");
|
throw new NotFoundException("Role not found");
|
||||||
}
|
}
|
||||||
client.deleteScopeMapping(roleModel);
|
client.deleteScopeMapping(roleModel);
|
||||||
|
adminEvent.operation(OperationType.DELETE).resourcePath(session.getContext().getUri(), roleModel.getId()).representation(roles).success();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
adminEvent.operation(OperationType.DELETE).resourcePath(client, "/roles").representation(roles).success();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -181,9 +181,8 @@ public class ScopeMappedResource {
|
||||||
throw new NotFoundException("Role not found");
|
throw new NotFoundException("Role not found");
|
||||||
}
|
}
|
||||||
client.addScopeMapping(roleModel);
|
client.addScopeMapping(roleModel);
|
||||||
|
adminEvent.operation(OperationType.CREATE).resourcePath(session.getContext().getUri(), role.getId()).representation(roles).success();
|
||||||
}
|
}
|
||||||
adminEvent.operation(OperationType.CREATE).resourcePath(client, "/roles").representation(roles).success();
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -202,7 +201,7 @@ public class ScopeMappedResource {
|
||||||
for (RoleModel roleModel : roleModels) {
|
for (RoleModel roleModel : roleModels) {
|
||||||
client.deleteScopeMapping(roleModel);
|
client.deleteScopeMapping(roleModel);
|
||||||
}
|
}
|
||||||
|
adminEvent.operation(OperationType.DELETE).resourcePath(session.getContext().getUri()).representation(roles).success();
|
||||||
} else {
|
} else {
|
||||||
for (RoleRepresentation role : roles) {
|
for (RoleRepresentation role : roles) {
|
||||||
RoleModel roleModel = realm.getRoleById(role.getId());
|
RoleModel roleModel = realm.getRoleById(role.getId());
|
||||||
|
@ -210,9 +209,9 @@ public class ScopeMappedResource {
|
||||||
throw new NotFoundException("Client not found");
|
throw new NotFoundException("Client not found");
|
||||||
}
|
}
|
||||||
client.deleteScopeMapping(roleModel);
|
client.deleteScopeMapping(roleModel);
|
||||||
|
adminEvent.operation(OperationType.DELETE).resourcePath(session.getContext().getUri(), roleModel.getId()).representation(roles).success();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
adminEvent.operation(OperationType.DELETE).resourcePath(client, "/roles").representation(roles).success();
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -39,12 +39,10 @@ public class UserClientRoleMappingsResource {
|
||||||
protected UserModel user;
|
protected UserModel user;
|
||||||
protected ClientModel client;
|
protected ClientModel client;
|
||||||
protected AdminEventBuilder adminEvent;
|
protected AdminEventBuilder adminEvent;
|
||||||
|
private UriInfo uriInfo;
|
||||||
|
|
||||||
@Context
|
public UserClientRoleMappingsResource(UriInfo uriInfo, RealmModel realm, RealmAuth auth, UserModel user, ClientModel client, AdminEventBuilder adminEvent) {
|
||||||
protected KeycloakSession session;
|
this.uriInfo = uriInfo;
|
||||||
|
|
||||||
|
|
||||||
public UserClientRoleMappingsResource(RealmModel realm, RealmAuth auth, UserModel user, ClientModel client, AdminEventBuilder adminEvent) {
|
|
||||||
this.realm = realm;
|
this.realm = realm;
|
||||||
this.auth = auth;
|
this.auth = auth;
|
||||||
this.user = user;
|
this.user = user;
|
||||||
|
@ -138,7 +136,7 @@ public class UserClientRoleMappingsResource {
|
||||||
}
|
}
|
||||||
user.grantRole(roleModel);
|
user.grantRole(roleModel);
|
||||||
}
|
}
|
||||||
adminEvent.operation(OperationType.CREATE).resourcePath(client, user, "/roles/").representation(roles).success();
|
adminEvent.operation(OperationType.CREATE).resourcePath(uriInfo).representation(roles).success();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -171,6 +169,6 @@ public class UserClientRoleMappingsResource {
|
||||||
user.deleteRoleMapping(roleModel);
|
user.deleteRoleMapping(roleModel);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
adminEvent.operation(OperationType.DELETE).resourcePath(client, user, "/roles/").representation(roles).success();
|
adminEvent.operation(OperationType.DELETE).resourcePath(uriInfo).representation(roles).success();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -131,7 +131,7 @@ public class UserFederationResource {
|
||||||
new UsersSyncManager().refreshPeriodicSyncForProvider(session.getKeycloakSessionFactory(), session.getProvider(TimerProvider.class), model, realm.getId());
|
new UsersSyncManager().refreshPeriodicSyncForProvider(session.getKeycloakSessionFactory(), session.getProvider(TimerProvider.class), model, realm.getId());
|
||||||
checkKerberosCredential(model);
|
checkKerberosCredential(model);
|
||||||
|
|
||||||
adminEvent.operation(OperationType.CREATE).resourcePath(model).representation(rep).success();
|
adminEvent.operation(OperationType.CREATE).resourcePath(uriInfo).representation(rep).success();
|
||||||
|
|
||||||
return Response.created(uriInfo.getAbsolutePathBuilder().path(model.getId()).build()).build();
|
return Response.created(uriInfo.getAbsolutePathBuilder().path(model.getId()).build()).build();
|
||||||
}
|
}
|
||||||
|
@ -157,7 +157,7 @@ public class UserFederationResource {
|
||||||
new UsersSyncManager().refreshPeriodicSyncForProvider(session.getKeycloakSessionFactory(), session.getProvider(TimerProvider.class), model, realm.getId());
|
new UsersSyncManager().refreshPeriodicSyncForProvider(session.getKeycloakSessionFactory(), session.getProvider(TimerProvider.class), model, realm.getId());
|
||||||
checkKerberosCredential(model);
|
checkKerberosCredential(model);
|
||||||
|
|
||||||
adminEvent.operation(OperationType.UPDATE).resourcePath(model).representation(rep).success();
|
adminEvent.operation(OperationType.UPDATE).resourcePath(uriInfo).representation(rep).success();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -195,7 +195,7 @@ public class UserFederationResource {
|
||||||
realm.removeUserFederationProvider(model);
|
realm.removeUserFederationProvider(model);
|
||||||
new UsersSyncManager().removePeriodicSyncForProvider(session.getProvider(TimerProvider.class), model);
|
new UsersSyncManager().removePeriodicSyncForProvider(session.getProvider(TimerProvider.class), model);
|
||||||
|
|
||||||
adminEvent.operation(OperationType.DELETE).resourcePath(model).success();
|
adminEvent.operation(OperationType.DELETE).resourcePath(uriInfo).success();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -239,7 +239,7 @@ public class UserFederationResource {
|
||||||
} else if ("triggerChangedUsersSync".equals(action)) {
|
} else if ("triggerChangedUsersSync".equals(action)) {
|
||||||
syncManager.syncChangedUsers(session.getKeycloakSessionFactory(), realm.getId(), model);
|
syncManager.syncChangedUsers(session.getKeycloakSessionFactory(), realm.getId(), model);
|
||||||
}
|
}
|
||||||
adminEvent.operation(OperationType.ACTION).resourcePath(model, "/sync").success();
|
adminEvent.operation(OperationType.ACTION).resourcePath(uriInfo).success();
|
||||||
return Response.noContent().build();
|
return Response.noContent().build();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -121,7 +121,7 @@ public class UsersResource {
|
||||||
throw new NotFoundException("User not found");
|
throw new NotFoundException("User not found");
|
||||||
}
|
}
|
||||||
updateUserFromRep(user, rep);
|
updateUserFromRep(user, rep);
|
||||||
adminEvent.operation(OperationType.UPDATE).resourcePath(user).representation(rep).success();
|
adminEvent.operation(OperationType.UPDATE).resourcePath(uriInfo).representation(rep).success();
|
||||||
|
|
||||||
if (session.getTransaction().isActive()) {
|
if (session.getTransaction().isActive()) {
|
||||||
session.getTransaction().commit();
|
session.getTransaction().commit();
|
||||||
|
@ -158,7 +158,7 @@ public class UsersResource {
|
||||||
UserModel user = session.users().addUser(realm, rep.getUsername());
|
UserModel user = session.users().addUser(realm, rep.getUsername());
|
||||||
updateUserFromRep(user, rep);
|
updateUserFromRep(user, rep);
|
||||||
|
|
||||||
adminEvent.operation(OperationType.CREATE).resourcePath(user).representation(rep).success();
|
adminEvent.operation(OperationType.CREATE).resourcePath(uriInfo, user.getId()).representation(rep).success();
|
||||||
|
|
||||||
if (session.getTransaction().isActive()) {
|
if (session.getTransaction().isActive()) {
|
||||||
session.getTransaction().commit();
|
session.getTransaction().commit();
|
||||||
|
@ -312,7 +312,7 @@ public class UsersResource {
|
||||||
|
|
||||||
FederatedIdentityModel socialLink = new FederatedIdentityModel(provider, rep.getUserId(), rep.getUserName());
|
FederatedIdentityModel socialLink = new FederatedIdentityModel(provider, rep.getUserId(), rep.getUserName());
|
||||||
session.users().addFederatedIdentity(realm, user, socialLink);
|
session.users().addFederatedIdentity(realm, user, socialLink);
|
||||||
adminEvent.operation(OperationType.CREATE).resourcePath(user, uriInfo.getPath(), true).representation(rep).success();
|
adminEvent.operation(OperationType.CREATE).resourcePath(uriInfo).representation(rep).success();
|
||||||
return Response.noContent().build();
|
return Response.noContent().build();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -328,7 +328,7 @@ public class UsersResource {
|
||||||
if (!session.users().removeFederatedIdentity(realm, user, provider)) {
|
if (!session.users().removeFederatedIdentity(realm, user, provider)) {
|
||||||
throw new NotFoundException("Link not found");
|
throw new NotFoundException("Link not found");
|
||||||
}
|
}
|
||||||
adminEvent.operation(OperationType.DELETE).resourcePath(user, uriInfo.getPath(), true).success();
|
adminEvent.operation(OperationType.DELETE).resourcePath(uriInfo).success();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -382,7 +382,7 @@ public class UsersResource {
|
||||||
} else {
|
} else {
|
||||||
throw new NotFoundException("Consent not found for user " + username + " and client " + clientId);
|
throw new NotFoundException("Consent not found for user " + username + " and client " + clientId);
|
||||||
}
|
}
|
||||||
adminEvent.operation(OperationType.ACTION).resourcePath(user, client, uriInfo.getPath()).success();
|
adminEvent.operation(OperationType.ACTION).resourcePath(uriInfo).success();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -404,7 +404,7 @@ public class UsersResource {
|
||||||
for (UserSessionModel userSession : userSessions) {
|
for (UserSessionModel userSession : userSessions) {
|
||||||
AuthenticationManager.backchannelLogout(session, realm, userSession, uriInfo, clientConnection, headers, true);
|
AuthenticationManager.backchannelLogout(session, realm, userSession, uriInfo, clientConnection, headers, true);
|
||||||
}
|
}
|
||||||
adminEvent.operation(OperationType.ACTION).resourcePath(user, uriInfo.getPath()).success();
|
adminEvent.operation(OperationType.ACTION).resourcePath(uriInfo).success();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -426,7 +426,7 @@ public class UsersResource {
|
||||||
|
|
||||||
boolean removed = new UserManager(session).removeUser(realm, user);
|
boolean removed = new UserManager(session).removeUser(realm, user);
|
||||||
if (removed) {
|
if (removed) {
|
||||||
adminEvent.operation(OperationType.DELETE).resourcePath(user).success();
|
adminEvent.operation(OperationType.DELETE).resourcePath(uriInfo).success();
|
||||||
return Response.noContent().build();
|
return Response.noContent().build();
|
||||||
} else {
|
} else {
|
||||||
return ErrorResponse.error("User couldn't be deleted", Response.Status.BAD_REQUEST);
|
return ErrorResponse.error("User couldn't be deleted", Response.Status.BAD_REQUEST);
|
||||||
|
@ -638,10 +638,8 @@ public class UsersResource {
|
||||||
throw new NotFoundException("Role not found");
|
throw new NotFoundException("Role not found");
|
||||||
}
|
}
|
||||||
user.grantRole(roleModel);
|
user.grantRole(roleModel);
|
||||||
|
adminEvent.operation(OperationType.CREATE).resourcePath(uriInfo, role.getId()).representation(roles).success();
|
||||||
}
|
}
|
||||||
|
|
||||||
adminEvent.operation(OperationType.CREATE).resourcePath(user, realm, uriInfo.getPath()).representation(roles).success();
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -667,7 +665,7 @@ public class UsersResource {
|
||||||
for (RoleModel roleModel : roleModels) {
|
for (RoleModel roleModel : roleModels) {
|
||||||
user.deleteRoleMapping(roleModel);
|
user.deleteRoleMapping(roleModel);
|
||||||
}
|
}
|
||||||
|
adminEvent.operation(OperationType.CREATE).resourcePath(uriInfo).representation(roles).success();
|
||||||
} else {
|
} else {
|
||||||
for (RoleRepresentation role : roles) {
|
for (RoleRepresentation role : roles) {
|
||||||
RoleModel roleModel = realm.getRole(role.getName());
|
RoleModel roleModel = realm.getRole(role.getName());
|
||||||
|
@ -675,10 +673,11 @@ public class UsersResource {
|
||||||
throw new NotFoundException("Role not found");
|
throw new NotFoundException("Role not found");
|
||||||
}
|
}
|
||||||
user.deleteRoleMapping(roleModel);
|
user.deleteRoleMapping(roleModel);
|
||||||
|
|
||||||
|
adminEvent.operation(OperationType.DELETE).resourcePath(uriInfo, role.getId()).representation(roles).success();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
adminEvent.operation(OperationType.DELETE).resourcePath(user, realm, uriInfo.getPath()).representation(roles).success();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Path("{username}/role-mappings/clients/{clientId}")
|
@Path("{username}/role-mappings/clients/{clientId}")
|
||||||
|
@ -693,7 +692,7 @@ public class UsersResource {
|
||||||
if (client == null) {
|
if (client == null) {
|
||||||
throw new NotFoundException("Client not found");
|
throw new NotFoundException("Client not found");
|
||||||
}
|
}
|
||||||
return new UserClientRoleMappingsResource(realm, auth, user, client, adminEvent);
|
return new UserClientRoleMappingsResource(uriInfo, realm, auth, user, client, adminEvent);
|
||||||
|
|
||||||
}
|
}
|
||||||
@Path("{username}/role-mappings/clients-by-id/{id}")
|
@Path("{username}/role-mappings/clients-by-id/{id}")
|
||||||
|
@ -709,7 +708,7 @@ public class UsersResource {
|
||||||
throw new NotFoundException("Client not found");
|
throw new NotFoundException("Client not found");
|
||||||
}
|
}
|
||||||
|
|
||||||
return new UserClientRoleMappingsResource(realm, auth, user, client, adminEvent);
|
return new UserClientRoleMappingsResource(uriInfo, realm, auth, user, client, adminEvent);
|
||||||
|
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
|
@ -743,7 +742,7 @@ public class UsersResource {
|
||||||
}
|
}
|
||||||
if (pass.isTemporary()) user.addRequiredAction(UserModel.RequiredAction.UPDATE_PASSWORD);
|
if (pass.isTemporary()) user.addRequiredAction(UserModel.RequiredAction.UPDATE_PASSWORD);
|
||||||
|
|
||||||
adminEvent.operation(OperationType.ACTION).resourcePath(user, uriInfo.getPath()).success();
|
adminEvent.operation(OperationType.ACTION).resourcePath(uriInfo).success();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -763,7 +762,7 @@ public class UsersResource {
|
||||||
}
|
}
|
||||||
|
|
||||||
user.setTotp(false);
|
user.setTotp(false);
|
||||||
adminEvent.operation(OperationType.ACTION).resourcePath(user, uriInfo.getPath()).success();
|
adminEvent.operation(OperationType.ACTION).resourcePath(uriInfo).success();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -840,7 +839,7 @@ public class UsersResource {
|
||||||
|
|
||||||
//audit.user(user).detail(Details.EMAIL, user.getEmail()).detail(Details.CODE_ID, accessCode.getCodeId()).success();
|
//audit.user(user).detail(Details.EMAIL, user.getEmail()).detail(Details.CODE_ID, accessCode.getCodeId()).success();
|
||||||
|
|
||||||
adminEvent.operation(OperationType.ACTION).resourcePath(user, uriInfo.getPath()).success();
|
adminEvent.operation(OperationType.ACTION).resourcePath(uriInfo).success();
|
||||||
|
|
||||||
return Response.ok().build();
|
return Response.ok().build();
|
||||||
} catch (EmailException e) {
|
} catch (EmailException e) {
|
||||||
|
|
Loading…
Reference in a new issue