You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ranger.apache.org by "kumaab (via GitHub)" <gi...@apache.org> on 2023/05/11 07:08:27 UTC

[GitHub] [ranger] kumaab commented on a diff in pull request #253: RANGER-4230: Add REST APIs to delete all external users & groups

kumaab commented on code in PR #253:
URL: https://github.com/apache/ranger/pull/253#discussion_r1190725954


##########
security-admin/src/main/java/org/apache/ranger/rest/XUserREST.java:
##########
@@ -863,6 +868,49 @@ public void deleteXUserByUserName(@PathParam("userName") String userName,
 		xUserMgr.deleteXUser(vxUser.getId(), forceDelete);
 	}
 
+
+	/**
+	 * Proceed with caution: Force deletes users in bulk from the ranger db,
+	 * essentially serves as a cleanup Op for external users.
+	 * <tt>Delete</tt> happens one at a time with immediate commit on the transaction.
+	 */
+	@DELETE
+	@Path("/delete/external/users")
+	@PreAuthorize("hasRole('ROLE_SYS_ADMIN')")
+	@Produces({ "application/json" })
+	public Response deleteXUsers() {
+		if (!usersDeletionInProgress){
+			synchronized (XUserREST.class) {
+				usersDeletionInProgress = true;
+				xUserMgr.bulkDeleteUsers();
+				usersDeletionInProgress = false;
+			}
+			return Response.ok("External users deleted successfully").build();
+		}
+		return Response.ok("Users Deletion in progress, check ranger admin logs!").build();
+	}
+
+	/**
+	 * Proceed with caution: Force deletes groups in bulk from the ranger db,
+	 * essentially serves as a cleanup Op for external groups.
+	 * <tt>Delete</tt> happens one at a time with immediate commit on the transaction.
+	 */
+	@DELETE
+	@Path("/delete/external/groups")
+	@PreAuthorize("hasRole('ROLE_SYS_ADMIN')")
+	@Produces({ "application/json" })
+	public Response deleteXGroups() {

Review Comment:
   thanks for the suggestion, changes included in the latest patch. 



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@ranger.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org