Skip to content

Conversation

@nodece
Copy link
Member

@nodece nodece commented Apr 19, 2023

Fixes #20066

Motivation

When a role wants to use the resource, the role needs to have resource permissions. If a role is a super user or tenant admin we should allow this request immediately, otherwise go to call the AuthorizationProvider to check the permission.

We currently have superuser/tenant administrator checks in PulsarAuthorizationProvider and AuthorizationService, there is confusion so the #20066 issue is introduced. So I suggest unifying superuser/tenantAdmin checks in the AuthorizationService, and then the AuthorizationProvider only needs to consider their business permissions.

Modifications

  • Move superuser/tenantAdmin checks to AuthorizationService from PulsarAuthorizationProvider

Verifying this change

  • Make sure that the change passes the CI checks.

Documentation

  • doc
  • doc-required
  • doc-not-needed
  • doc-complete

@github-actions github-actions bot added the doc-not-needed Your PR changes do not impact docs label Apr 19, 2023
Copy link
Member

@michaeljmarshall michaeljmarshall left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for putting together this PR, @nodece . I think we are coming at this from two different angles. I do not think we should remove logic from the AuthorizationProvider in this way. Let me know your thoughts on the comments. Thanks!

}
return provider.allowTopicOperationAsync(topicName, role, TopicOperation.PRODUCE, authenticationData);

return isSuperUserOrAdmin(topicName.getTenant(), role, authenticationData)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I do not think we should move in this direction. I think our target design should be to let the AuthorizationProvider implementation decide what level of permission is required. This line here removes that abstraction from the AuthorizationProvider and puts it in the AuthorizationService. I concede that there are some places where we use these checks outside of the AuthorizationProvider, however, those are legacy details that we have to support until we find a way to move them into the AuthorizationProvider.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think our target design should be to let the AuthorizationProvider implementation decide what level of permission is required

We have isTenantAdmin and isSuperUser methods in the AuthorizationProvider. The user just overrides that to decide what level of permission is required. When isTenantAdmin and isSuperUser return false, the AuthorizationService call to the AuthorizationProvider.

There is another reason that I think plugin authors should not pay attention to isTenantAdmin and isSuperUser details.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have isTenantAdmin and isSuperUser methods in the AuthorizationProvider.

That is a fair point. I think I've been operating under the assumption that these are a bit of an anti-pattern with the idea that it is better to give users the ability to configure granular permissions.

I think plugin authors should not pay attention to isTenantAdmin and isSuperUser details.

I agree with this, and this is part of why I do not think we should create new dependencies on these methods. When I added isSuperUserOrAdmin recently, I did so because it was necessary to consolidate existing logic. I made it private in an attempt to prevent new usage, but of course that wouldn't stop the AuthorizationService from using it.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When isTenantAdmin and isSuperUser return false, the AuthorizationService call to the AuthorizationProvider.

My primary objection to moving this logic out of the AuthorizationProvider is that implementations have almost certainly already accounted for the fact that this method (and all of the similar ones modified in this PR) do not themselves check if the client is a super user or a tenant admin. As such, we could be creating unnecessary overhead by moving this logic out of the AuthorizationProvider and into the AuthorizationService.

These are my initial thoughts. I'll continue to think about this more. Thanks for the discussion!

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@michaeljmarshall Do you have a new idea? IMO, I think this change makes sense.

log.debug("Check allowNamespaceOperationAsync [{}] on [{}].", operation.name(), namespaceName);
}

return validateTenantAdminAccess(namespaceName.getTenant(), role, authData)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this call rightly belongs in the AuthorizationProvider impelmentation.

@nodece
Copy link
Member Author

nodece commented Apr 20, 2023

/pulsarbot rerun-failure-checks

@github-actions
Copy link

The pr had no activity for 30 days, mark with Stale label.

@github-actions github-actions bot added the Stale label Jun 12, 2023
@Technoboy- Technoboy- added this to the 3.2.0 milestone Jul 31, 2023
@Technoboy- Technoboy- modified the milestones: 3.2.0, 3.3.0 Dec 22, 2023
@coderzc coderzc modified the milestones: 3.3.0, 3.4.0 May 8, 2024
@lhotari lhotari modified the milestones: 4.0.0, 4.1.0 Oct 14, 2024
@lhotari lhotari removed this from the 4.1.0 milestone Jan 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

doc-not-needed Your PR changes do not impact docs ready-to-test Stale

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] [broker] Producer and consumer will all be disconnected while using tenant admin to produce/consume

5 participants