Skip to content

Conversation

@Technoboy-
Copy link
Contributor

Fixes #14191

Master Issue: #14191

Motivation

As #14191 described, users may get confused about the current permission.
First, we only define the below actions in the grant-permission interface:

produce,consume,sources,sinks,functions,packages

Though we grant all the actions to some roles like below (myuser is not admin, only a normal user):

$ pulsar-admin namespaces grant-permission public/default --role myuser --actions produce,consume,sources,sinks,functions,packages

But when we list topics under a namespace:

$ pulsar-admin --admin-url https://dev.pulsar.xyz.com:8081 --auth-plugin "org.apache.pulsar.client.impl.auth.AuthenticationToken" --auth-params "token:<token>" topics list public/default

We will get the below error message :

HTTP 403 : Unauthorized to validateNamespaceOperation for operation [GET_BUNDLE] on namespace [mytenant/np1]

Because when listing topics, we will search all the topics including non-persistent topics which will validate GET_BUNDLE operation, but we don't have this action in auth action, and it's not good to add to AuthAction, for it's duplicate with NamespaceOperation. So we'd better map this to consume operation to solve the problem.

Documentation

  • no-need-doc
    (Please explain why)

@Technoboy- Technoboy- self-assigned this May 9, 2022
@Technoboy- Technoboy- added this to the 2.11.0 milestone May 9, 2022
@github-actions github-actions bot added the doc-not-needed Your PR changes do not impact docs label May 9, 2022
@Technoboy- Technoboy- added type/bug The PR fixed a bug or issue reported a bug area/security release/2.9.3 release/2.8.4 release/2.10.1 and removed doc-not-needed Your PR changes do not impact docs labels May 9, 2022
@Technoboy- Technoboy- changed the title Fix grant all permissions but can't list topic. [fix][security] Fix grant all permissions but can't list topic. May 9, 2022
@github-actions
Copy link

github-actions bot commented May 9, 2022

@Technoboy-:Thanks for your contribution. For this PR, do we need to update docs?
(The PR template contains info about doc, which helps others know more about the changes. Can you provide doc-related info in this and future PR descriptions? Thanks)

@nicoloboschi nicoloboschi requested review from eolivelli and lhotari May 9, 2022 12:32
@codelipenghui codelipenghui merged commit 5155b1d into apache:master May 9, 2022
@nicoloboschi
Copy link
Contributor

@Technoboy- the patch doesn't apply cleanly to 2.10. Would you mind to provide it in another pull?

@Technoboy-
Copy link
Contributor Author

@Technoboy- the patch doesn't apply cleanly to 2.10. Would you mind to provide it in another pull?

Ok.

codelipenghui pushed a commit that referenced this pull request May 20, 2022
nicoloboschi pushed a commit to datastax/pulsar that referenced this pull request May 23, 2022
(cherry picked from commit 5155b1d)
(cherry picked from commit 3dcdf2a)
@mattisonchao mattisonchao added the cherry-picked/branch-2.9 Archived: 2.9 is end of life label Jun 13, 2022
mattisonchao pushed a commit that referenced this pull request Jun 13, 2022
@BewareMyPower
Copy link
Contributor

@Technoboy- Could you create another PR to migrate this PR to branch-2.8? The allowNamespaceOperationAsync method is very different in branch-2.8.

public CompletableFuture<Boolean> allowNamespaceOperationAsync(NamespaceName namespaceName,
String role,
NamespaceOperation operation,
AuthenticationDataSource authData) {
CompletableFuture<Boolean> isAuthorizedFuture;
switch (operation) {
case PACKAGES:
isAuthorizedFuture = allowTheSpecifiedActionOpsAsync(namespaceName, role, authData, AuthAction.packages);
break;
case GET_TOPICS:
case UNSUBSCRIBE:
case CLEAR_BACKLOG:
isAuthorizedFuture = allowTheSpecifiedActionOpsAsync(namespaceName, role, authData, AuthAction.consume);
break;
default:
isAuthorizedFuture = CompletableFuture.completedFuture(false);
}
CompletableFuture<Boolean> isTenantAdminFuture = validateTenantAdminAccess(namespaceName.getTenant(), role, authData);
return isTenantAdminFuture.thenCombine(isAuthorizedFuture, (isTenantAdmin, isAuthorized) -> {
if (log.isDebugEnabled()) {
log.debug("Verify if role {} is allowed to {} to topic {}: isTenantAdmin={}, isAuthorized={}",
role, operation, namespaceName, isTenantAdmin, isAuthorized);
}
return isTenantAdmin || isAuthorized;
});
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

NonPersistentTopics - [myuser] Failed to get list of topics under namespace public/default

5 participants