Skip to content

Commit

Permalink
Merge pull request #145 from OpsMx/OP-11599-RBAC-analytics-api
Browse files Browse the repository at this point in the history
RBAC added for analytics APIs
  • Loading branch information
ramyaravi-opsmx authored Feb 21, 2022
2 parents 04baed1 + bda9796 commit dd50db3
Showing 1 changed file with 132 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ public class ApplicationFeatureRbac {
populatePlatformServiceApis();
populateVisibilityServiceApis();
populateSaporServiceApis();
populateAnalyticServiceApis();
}

public void authorizeUserForFeatureVisibility(String userName) {
Expand Down Expand Up @@ -153,6 +154,9 @@ private Integer getApplicationId(String endpoint) {
} else if (pathComps.contains("deleteApplication")) {
int index = pathComps.indexOf("deleteApplication");
applicationId = Integer.parseInt(pathComps.get(index + 1));
} else if (pathComps.contains("template")) {
int index = pathComps.indexOf("template");
applicationId = Integer.parseInt(pathComps.get(index + 1));
}

if (applicationId == null || applicationId.equals(0)) {
Expand Down Expand Up @@ -485,6 +489,12 @@ private Integer getGateId(String endpoint) {
} else if (pathComps.contains("gate")) {
int index = pathComps.indexOf("gate");
gateId = Integer.parseInt(pathComps.get(index + 1));
} else if (pathComps.contains("serviceGates")) {
int index = pathComps.indexOf("serviceGates");
gateId = Integer.parseInt(pathComps.get(index + 1));
} else if (pathComps.contains("serviceGate")) {
int index = pathComps.indexOf("serviceGate");
gateId = Integer.parseInt(pathComps.get(index + 1));
}

if (gateId == null || gateId.equals(0)) {
Expand Down Expand Up @@ -1392,4 +1402,126 @@ private static void populateSaporServiceApis() {
endpointsWithGateId.add("/oes/policy/gate/{gateId}");
endpointsWithGateId.add("/oes/policy/gate/{gateId}/status");
}

private static void populateAnalyticServiceApis() {

applicationFeatureRbacEndpoints.add("/autopilot/api/v1/applications/latestcanary");
applicationFeatureRbacEndpoints.add("/autopilot/api/v1/dashboardservice/applications");
applicationFeatureRbacEndpoints.add("/autopilot/api/v1/applications/{applicationId}");
applicationFeatureRbacEndpoints.add("/autopilot/api/v1/applications/{id}");
applicationFeatureRbacEndpoints.add(
"/autopilot/api/v1/dashboardservice/applications/{applicationId}");
applicationFeatureRbacEndpoints.add("/autopilot/api/v1/applications");
applicationFeatureRbacEndpoints.add("/autopilot/api/v1/applications/{id}");
applicationFeatureRbacEndpoints.add("/autopilot/api/v1/applications/{applicationId}/details");
applicationFeatureRbacEndpoints.add("/autopilot/canaries/applicationNames");
applicationFeatureRbacEndpoints.add("/autopilot/canaries/applicationServiceNames");
applicationFeatureRbacEndpoints.add("/autopilot/canaries/verification/getVerificationSummary");
applicationFeatureRbacEndpoints.add("/autopilot/canaries/verification/getVerificationHistory");
applicationFeatureRbacEndpoints.add(
"/autopilot/api/v1/correlation/log/{riskAnalysisId}/{serviceId}");
applicationFeatureRbacEndpoints.add(
"/autopilot/api/v1/correlation/metric/{riskAnalysisId}/{serviceId}");
applicationFeatureRbacEndpoints.add(
"/autopilot/api/v1/correlation/log/{riskAnalysisId}/{serviceId}/{clusterId}");
applicationFeatureRbacEndpoints.add("/autopilot/api/v1/applications/{applicationId}/tags/{id}");
applicationFeatureRbacEndpoints.add(
"/autopilot/api/v1/applications/{applicationId}/service/{serviceId}");
applicationFeatureRbacEndpoints.add("/autopilot/api/v1/applications/{applicationId}/tags");
applicationFeatureRbacEndpoints.add("/autopilot/api/v1/applications/{applicationId}/tags/{id}");
applicationFeatureRbacEndpoints.add(
"/autopilot/api/v1/applications/{applicationId}/logTemplates/{logTemplateName}");
applicationFeatureRbacEndpoints.add(
"/autopilot/api/v1/applications/{applicationId}/metricTemplates/{metricTemplateName}");
applicationFeatureRbacEndpoints.add(
"/autopilot/api/v1/applications/{applicationId}/deleteMetricTemplate/{templateName}");
applicationFeatureRbacEndpoints.add(
"/autopilot/api/v1/applications/{applicationId}/metricTemplates");
applicationFeatureRbacEndpoints.add(
"/autopilot/api/v1/applications/{applicationId}/service/{serviceId}/template");
applicationFeatureRbacEndpoints.add(
"/autopilot/api/v1/applications/{applicationId}/service/{serviceId}");
applicationFeatureRbacEndpoints.add(
"/autopilot/api/v1/applications/{applicationId}/logTemplates");
applicationFeatureRbacEndpoints.add(
"/autopilot/api/v1/applications/{applicationId}/logTemplates/{logTemplateName}");
applicationFeatureRbacEndpoints.add(
"/autopilot/api/v1/applications/{applicationId}/metricTemplates");
applicationFeatureRbacEndpoints.add(
"/autopilot/api/v1/applications/{applicationId}/deleteLogTemplate/{templateName}");
applicationFeatureRbacEndpoints.add("/autopilot/logs/template/{applicationId}/{templateId}");
applicationFeatureRbacEndpoints.add("/autopilot/api/v2/applications/getApplicationHealth");
applicationFeatureRbacEndpoints.add("/autopilot/api/v2/serviceGates/{gateId}");
applicationFeatureRbacEndpoints.add("/autopilot/api/v2/applications/{id}");
applicationFeatureRbacEndpoints.add(
"/autopilot/api/v2/applications/{applicationId}/service/{serviceId}/gates/{id}");
applicationFeatureRbacEndpoints.add("/autopilot/api/v2/applications/{id}/failures_count");
applicationFeatureRbacEndpoints.add(
"/autopilot/api/v2/applications/{applicationId}/service/{serviceId}/gates/{id}/score");
applicationFeatureRbacEndpoints.add(
"/autopilot/api/v2/applications/{applicationId}/services/{serviceId}/failures_count");
applicationFeatureRbacEndpoints.add(
"/autopilot/api/v2/applications/{applicationId}/service/{serviceId}/template");
applicationFeatureRbacEndpoints.add("/autopilot/api/v3/applications/{applicationId}/details");
applicationFeatureRbacEndpoints.add(
"/autopilot/api/v3/applications/{applicationId}/service/{serviceId}");
applicationFeatureRbacEndpoints.add(
"/autopilot/api/v3/applications/{applicationId}/gates/{gateId}");
applicationFeatureRbacEndpoints.add("/autopilot/api/v3/applications/{applicationId}/service");
applicationFeatureRbacEndpoints.add(
"/autopilot/api/v3/applications/{applicationId}/services/{serviceId}/images");
applicationFeatureRbacEndpoints.add("/autopilot/api/v3/applications/{applicationId}/gates");
applicationFeatureRbacEndpoints.add(
"/autopilot/api/v3/applications/{applicationId}/service/{serviceId}/gates/{gateId}/images/score");

endpointsWithApplicationId.add("/autopilot/api/v1/applications/{applicationId}");
endpointsWithApplicationId.add("/autopilot/api/v1/applications/{id}");
endpointsWithApplicationId.add(
"/autopilot/api/v1/dashboardservice/applications/{applicationId}");
endpointsWithApplicationId.add("/autopilot/api/v1/applications/{applicationId}/details");
endpointsWithApplicationId.add("/autopilot/api/v1/applications/{applicationId}/tags/{id}");
endpointsWithApplicationId.add(
"/autopilot/api/v1/applications/{applicationId}/service/{serviceId}");
endpointsWithApplicationId.add("/autopilot/api/v1/applications/{applicationId}/tags");
endpointsWithApplicationId.add(
"/autopilot/api/v1/applications/{applicationId}/logTemplates/{logTemplateName}");
endpointsWithApplicationId.add(
"/autopilot/api/v1/applications/{applicationId}/metricTemplates/{metricTemplateName}");
endpointsWithApplicationId.add(
"/autopilot/api/v1/applications/{applicationId}/deleteMetricTemplate/{templateName}");
endpointsWithApplicationId.add(
"/autopilot/api/v1/applications/{applicationId}/metricTemplates");
endpointsWithApplicationId.add(
"/autopilot/api/v1/applications/{applicationId}/service/{serviceId}/template");
endpointsWithApplicationId.add(
"/autopilot/api/v1/applications/{applicationId}/service/{serviceId}");
endpointsWithApplicationId.add("/autopilot/api/v1/applications/{applicationId}/logTemplates");
endpointsWithApplicationId.add(
"/autopilot/api/v1/applications/{applicationId}/logTemplates/{logTemplateName}");
endpointsWithApplicationId.add(
"/autopilot/api/v1/applications/{applicationId}/deleteLogTemplate/{templateName}");
endpointsWithApplicationId.add("/autopilot/logs/template/{applicationId}/{templateId}");
endpointsWithApplicationId.add("/autopilot/api/v2/applications/{id}");
endpointsWithApplicationId.add(
"/autopilot/api/v2/applications/{applicationId}/service/{serviceId}/gates/{id}");
endpointsWithApplicationId.add("/autopilot/api/v2/applications/{id}/failures_count");
endpointsWithApplicationId.add(
"/autopilot/api/v2/applications/{applicationId}/service/{serviceId}/gates/{id}/score");
endpointsWithApplicationId.add(
"/autopilot/api/v2/applications/{applicationId}/services/{serviceId}/failures_count");
endpointsWithApplicationId.add(
"/autopilot/api/v2/applications/{applicationId}/service/{serviceId}/template");
endpointsWithApplicationId.add("/autopilot/api/v3/applications/{applicationId}/details");
endpointsWithApplicationId.add(
"/autopilot/api/v3/applications/{applicationId}/service/{serviceId}");
endpointsWithApplicationId.add("/autopilot/api/v3/applications/{applicationId}/gates/{gateId}");
endpointsWithApplicationId.add("/autopilot/api/v3/applications/{applicationId}/service");
endpointsWithApplicationId.add(
"/autopilot/api/v3/applications/{applicationId}/services/{serviceId}/images");
endpointsWithApplicationId.add("/autopilot/api/v3/applications/{applicationId}/gates");
endpointsWithApplicationId.add(
"/autopilot/api/v3/applications/{applicationId}/service/{serviceId}/gates/{gateId}/images/score");

endpointsWithGateId.add("/autopilot/api/v2/serviceGates/{gateId}");
}
}

0 comments on commit dd50db3

Please sign in to comment.