Skip to content

Commit

Permalink
fix(datahub-gms) usage stats queryRange API's Authorization error for…
Browse files Browse the repository at this point in the history
… Dataset Owners (datahub-project#8819)

Co-authored-by: si-chakraborty <[email protected]>
  • Loading branch information
siladitya2 and si-chakraborty authored Sep 20, 2023
1 parent 35eb194 commit 9fdfa49
Showing 1 changed file with 3 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -380,8 +380,10 @@ public Task<UsageQueryResult> query(@ActionParam(PARAM_RESOURCE) @Nonnull String
public Task<UsageQueryResult> queryRange(@ActionParam(PARAM_RESOURCE) @Nonnull String resource,
@ActionParam(PARAM_DURATION) @Nonnull WindowDuration duration, @ActionParam(PARAM_RANGE) UsageTimeRange range) {
Authentication auth = AuthenticationContext.getAuthentication();
Urn resourceUrn = UrnUtils.getUrn(resource);
if (Boolean.parseBoolean(System.getenv(REST_API_AUTHORIZATION_ENABLED_ENV))
&& !isAuthorized(auth, _authorizer, ImmutableList.of(PoliciesConfig.VIEW_DATASET_USAGE_PRIVILEGE), (ResourceSpec) null)) {
&& !isAuthorized(auth, _authorizer, ImmutableList.of(PoliciesConfig.VIEW_DATASET_USAGE_PRIVILEGE),
new ResourceSpec(resourceUrn.getEntityType(), resourceUrn.toString()))) {
throw new RestLiServiceException(HttpStatus.S_401_UNAUTHORIZED,
"User is unauthorized to query usage.");
}
Expand Down

0 comments on commit 9fdfa49

Please sign in to comment.