Skip to content

Commit

Permalink
add create_topic auth action on ns
Browse files Browse the repository at this point in the history
  • Loading branch information
KannarFr committed Sep 1, 2022
1 parent f2a5ba0 commit 241ccc0
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -488,6 +488,8 @@ public CompletableFuture<Boolean> allowNamespaceOperationAsync(NamespaceName nam
return allowTheSpecifiedActionOpsAsync(
namespaceName, role, authData, AuthAction.consume);
case CREATE_TOPIC:
return allowTheSpecifiedActionOpsAsync(
namespaceName, role, authData, AuthAction.create_topic);
case DELETE_TOPIC:
case ADD_BUNDLE:
case DELETE_BUNDLE:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,10 @@ public void testSubscriberPermission() throws Exception {
"Unauthorized to validateTopicOperation for operation"));
}

// grant namespace create_topic authorization to the subscriptionRole
tenantAdmin.namespaces().grantPermissionOnNamespace(namespace, subscriptionRole,
Collections.singleton(AuthAction.create_topic));

// grant topic consume authorization to the subscriptionRole
tenantAdmin.topics().grantPermission(topicName, subscriptionRole,
Collections.singleton(AuthAction.consume));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@
* Authorization action for Pulsar policies.
*/
public enum AuthAction {
/** Permission to create topic. */
create_topic,

/** Permission to produce/publish messages. */
produce,

Expand Down

0 comments on commit 241ccc0

Please sign in to comment.