kumaab commented on code in PR #1120:
URL: https://github.com/apache/ranger/pull/1120#discussion_r3708305466
##########
security-admin/src/main/java/org/apache/ranger/util/RangerServerHealthUtil.java:
##########
@@ -98,4 +136,44 @@ private Map<String, Object> getDbStatus(String dbVersion) {
return ret;
}
+
+ public List<String> getServiceDefNames() {
+ LOG.debug("==> RangerServerHealthUtil.getServiceDefNames()");
+
+ if (!bizUtil.isHealthCheckUser(resolveAuthenticatedLoginId())) {
+ throw
restErrorUtil.createRESTException(HttpServletResponse.SC_FORBIDDEN,
+ "Only the healthcheck user may query service-def names via
this path.", true);
+ }
+
+ List<String> ret = serviceDefService.getAllServiceDefNames();
+
+ LOG.debug("<== RangerServerHealthUtil.getServiceDefNames(): count={}",
(ret == null ? 0 : ret.size()));
+
+ return ret;
+ }
+
+ /**
+ * Header-based auth sets {@link RangerAuthenticationToken} before Ranger
+ * {@link UserSessionBase} is available. Fall back to that token when the
Ranger session
+ * has not been materialized yet (e.g. healthcheck user not in DB).
+ */
+ private String resolveAuthenticatedLoginId() {
Review Comment:
I see, added a cursor rule as well.
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]