Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(datahub-gms) usage stats queryRange API's Authorization error for Dataset Owners #8819

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
Loading