Skip to content

Commit

Permalink
fix(operations): fix authorizer on operations controller (datahub-pro…
Browse files Browse the repository at this point in the history
  • Loading branch information
david-leifker authored Jun 13, 2024
1 parent 6329153 commit 50ab79e
Showing 1 changed file with 6 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import com.datahub.authentication.Authentication;
import com.datahub.authentication.AuthenticationContext;
import com.datahub.authorization.AuthUtil;
import com.datahub.plugins.auth.authorization.Authorizer;
import com.datahub.authorization.AuthorizerChain;
import com.linkedin.common.urn.UrnUtils;
import com.linkedin.metadata.authorization.PoliciesConfig;
import com.linkedin.metadata.entity.EntityService;
Expand Down Expand Up @@ -54,7 +54,7 @@
name = "ElasticSearchOperations",
description = "An API for managing your elasticsearch instance")
public class OperationsController {
private final Authorizer authorizerChain;
private final AuthorizerChain authorizerChain;
private final OperationContext systemOperationContext;
private final SystemMetadataService systemMetadataService;
private final TimeseriesAspectService timeseriesAspectService;
Expand All @@ -66,9 +66,10 @@ public OperationsController(
SystemMetadataService systemMetadataService,
TimeseriesAspectService timeseriesAspectService,
EntitySearchService searchService,
EntityService<?> entityService) {
EntityService<?> entityService,
AuthorizerChain authorizerChain) {
this.systemOperationContext = systemOperationContext;
this.authorizerChain = systemOperationContext.getAuthorizerContext().getAuthorizer();
this.authorizerChain = authorizerChain;
this.systemMetadataService = systemMetadataService;
this.timeseriesAspectService = timeseriesAspectService;
this.searchService = searchService;
Expand Down Expand Up @@ -229,7 +230,7 @@ public ResponseEntity<ExplainResponse> explainSearchQuery(

if (!AuthUtil.isAPIAuthorized(
authentication, authorizerChain, PoliciesConfig.ES_EXPLAIN_QUERY_PRIVILEGE)) {
log.error("{} is not authorized to get timeseries index sizes", actorUrnStr);
log.error("{} is not authorized to get explain queries", actorUrnStr);
return ResponseEntity.status(HttpStatus.FORBIDDEN).body(null);
}
OperationContext opContext =
Expand Down

0 comments on commit 50ab79e

Please sign in to comment.