Skip to content

Commit

Permalink
[pulsar-admin] allow tenant admin to manage subscription permission (a…
Browse files Browse the repository at this point in the history
…pache#6122)

### Motivation
In apache#2981, we have added support to grant subscriber-permission to manage subscription based apis. However, grant-subscription-permission api requires super-user access and it creates too much dependency on system-admin when many tenants want to grant subscription permission.
So, allow each tenant to manage subscription permission in order to reduce administrative efforts for super user.
  • Loading branch information
rdhabalia committed Mar 18, 2020
1 parent 40995a0 commit 254e54b
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -375,8 +375,7 @@ protected void internalGrantPermissionOnNamespace(String role, Set<AuthAction> a


protected void internalGrantPermissionOnSubscription(String subscription, Set<String> roles) {
/** controlled by system-admin(super-user) to prevent metadata footprint size */
validateSuperUserAccess();
validateAdminAccessForTenant(namespaceName.getTenant());

try {
AuthorizationService authService = pulsar().getBrokerService().getAuthorizationService();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,8 @@ public void grantPermissionOnNamespace(@PathParam("property") String property, @

@POST
@Path("/{property}/{cluster}/{namespace}/permissions/subscription/{subscription}")
@ApiOperation(hidden = true, value = "Grant a new permission to roles for a subscription.")
@ApiOperation(hidden = true, value = "Grant a new permission to roles for a subscription. "
+ "[Tenant admin is allowed to perform this operation]")
@ApiResponses(value = { @ApiResponse(code = 403, message = "Don't have admin permission"),
@ApiResponse(code = 404, message = "Property or cluster or namespace doesn't exist"),
@ApiResponse(code = 409, message = "Concurrent modification"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,8 @@ public void grantPermissionOnNamespace(@PathParam("tenant") String tenant,

@POST
@Path("/{property}/{namespace}/permissions/subscription/{subscription}")
@ApiOperation(hidden = true, value = "Grant a new permission to roles for a subscription.")
@ApiOperation(hidden = true, value = "Grant a new permission to roles for a subscription."
+ "[Tenant admin is allowed to perform this operation]")
@ApiResponses(value = { @ApiResponse(code = 403, message = "Don't have admin permission"),
@ApiResponse(code = 404, message = "Property or cluster or namespace doesn't exist"),
@ApiResponse(code = 409, message = "Concurrent modification"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ public void testSubscriberPermission() throws Exception {

// grant subscription access to specific different role and only that role can access the subscription
String otherPrincipal = "Principal-1-to-access-sub";
superAdmin.namespaces().grantPermissionOnSubscription(namespace, subscriptionName,
tenantAdmin.namespaces().grantPermissionOnSubscription(namespace, subscriptionName,
Collections.singleton(otherPrincipal));

// now, subscriptionRole doesn't have subscription level access so, it will fail to access subscription
Expand Down

0 comments on commit 254e54b

Please sign in to comment.